Skip to content

Commit 1f75bdc

Browse files
Copilotdata-douser
andauthored
Fix bqrs_interpret: defensive coercion for file parameter array/bracket handling
Some MCP clients send the file parameter as a JSON-encoded array string like '["/path/to/file.bqrs"]' or as an actual array instead of a plain string. The handler now defensively detects both cases and extracts the clean file path. TDD: Added 2 regression tests for JSON-encoded array strings and actual array values passed as the file parameter. Agent-Logs-Url: https://github.com/advanced-security/codeql-development-mcp-server/sessions/6ff74bab-c637-4e18-a5dc-92e3065583f4 Co-authored-by: data-douser <70299490+data-douser@users.noreply.github.com>
1 parent 7a590b4 commit 1f75bdc

4 files changed

Lines changed: 91 additions & 4 deletions

File tree

server/dist/codeql-development-mcp-server.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187355,7 +187355,17 @@ function registerCLITool(server, definition) {
187355187355
positionalArgs = [...positionalArgs, ...files];
187356187356
}
187357187357
if (file && name.startsWith("codeql_bqrs_")) {
187358-
positionalArgs = [...positionalArgs, file];
187358+
let cleanFile = Array.isArray(file) ? String(file[0]) : String(file);
187359+
if (cleanFile.startsWith("[") && cleanFile.endsWith("]")) {
187360+
try {
187361+
const parsed = JSON.parse(cleanFile);
187362+
if (Array.isArray(parsed) && parsed.length > 0) {
187363+
cleanFile = String(parsed[0]);
187364+
}
187365+
} catch {
187366+
}
187367+
}
187368+
positionalArgs = [...positionalArgs, cleanFile];
187359187369
}
187360187370
if (qlref && name === "codeql_resolve_qlref") {
187361187371
positionalArgs = [...positionalArgs, qlref];

0 commit comments

Comments
 (0)