MCPcopy Create free account
hub / github.com/damms005/devdb-vscode / validateQuery

Function validateQuery

src/services/mcp/query-validator.ts:22–49  ·  view source on GitHub ↗
(query: string)

Source from the content-addressed store, hash-verified

20};
21
22export function validateQuery(query: string): QueryValidationResult {
23 for (const pattern of BLOCKED_PATTERNS) {
24 if (pattern.test(query)) {
25 return {
26 allowed: false,
27 warning: `Query blocked: ${query.trim().split(/\s+/).slice(0, 3).join(' ').toUpperCase()} is not allowed via MCP`,
28 };
29 }
30 }
31
32 if (DELETE_WITHOUT_WHERE.test(query)) {
33 return {
34 allowed: true,
35 warning: 'Warning: DELETE without WHERE clause detected',
36 };
37 }
38
39 for (const { pattern, label } of WARNING_PATTERNS) {
40 if (pattern.test(query)) {
41 return {
42 allowed: true,
43 warning: `Warning: ${label} statement detected`,
44 };
45 }
46 }
47
48 return { allowed: true };
49}
50
51export function getQueryType(query: string): string {
52 const match = query.trim().match(/^\s*(\w+)/);

Callers 3

startHttpServerFunction · 0.90
server.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected