Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions extensions/vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ esbuild.config.js
coverage/**

# Build artifacts that shouldn't be in the VSIX
.tmp/**
**/.codeql/**
**/.tmp/**
**/*.test.ts
**/*.test.js
**/*.test.cjs
**/*.map
dist/test/**
**/dist/test/**

# Bundled server: exclude test/examples content
server/ql/*/tools/test/**
Expand Down
52 changes: 22 additions & 30 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 30 additions & 2 deletions server/dist/codeql-development-mcp-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -58042,6 +58042,34 @@ function registerCLITool(server, definition) {
mkdirSync5(outputDir, { recursive: true });
}
}
const rawAdditionalArgs = Array.isArray(options.additionalArgs) ? options.additionalArgs : [];
delete options.additionalArgs;
const managedFlagNames = /* @__PURE__ */ new Set([
"evaluator-log",
"logdir",
"output",
"tuple-counting",
"verbosity"
]);
const userAdditionalArgs = queryLogDir ? (() => {
const filteredAdditionalArgs = [];
for (let i = 0; i < rawAdditionalArgs.length; i += 1) {
const arg = rawAdditionalArgs[i];
const m = arg.match(/^--(?:no-)?([^=]+)(?:=.*)?$/);
if (m && managedFlagNames.has(m[1])) {
logger.warn(
`Ignoring "${arg}" from additionalArgs for ${name}: this flag is managed internally. Use the corresponding named parameter instead.`
);
const hasInlineValue = arg.includes("=");
if (!hasInlineValue && i + 1 < rawAdditionalArgs.length) {
i += 1;
}
continue;
}
filteredAdditionalArgs.push(arg);
}
return filteredAdditionalArgs;
})() : rawAdditionalArgs;
let result;
if (command === "codeql") {
let cwd;
Expand All @@ -58058,9 +58086,9 @@ function registerCLITool(server, definition) {
if (name === "codeql_test_run") {
options["keep-databases"] = true;
}
result = await executeCodeQLCommand(subcommand, options, positionalArgs, cwd);
result = await executeCodeQLCommand(subcommand, options, [...positionalArgs, ...userAdditionalArgs], cwd);
} else if (command === "qlt") {
result = await executeQLTCommand(subcommand, options, positionalArgs);
result = await executeQLTCommand(subcommand, options, [...positionalArgs, ...userAdditionalArgs]);
} else {
throw new Error(`Unsupported command: ${command}`);
}
Expand Down
4 changes: 2 additions & 2 deletions server/dist/codeql-development-mcp-server.js.map

Large diffs are not rendered by default.

60 changes: 58 additions & 2 deletions server/src/lib/cli-tool-registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,62 @@ export function registerCLITool(server: McpServer, definition: CLIToolDefinition
}
}

// Extract additionalArgs from options so they are passed as raw CLI
// arguments instead of being transformed into --additionalArgs=value
// by buildCodeQLArgs.
const rawAdditionalArgs = Array.isArray(options.additionalArgs)
? options.additionalArgs as string[]
: [];
delete options.additionalArgs;

// For tools with post-execution processing (query run, test run,
// database analyze), certain CLI flags are set internally and their
// values are read back after execution (e.g. --evaluator-log for log
// summary generation, --output for SARIF interpretation). If a user
// passes these flags via additionalArgs the CLI would receive
// conflicting duplicates and the post-processing would use stale
// values from the options object. Filter them out and log a warning
// directing the user to the corresponding named parameter instead.
const managedFlagNames = new Set([
'evaluator-log',
'logdir',
'output',
'tuple-counting',
'verbosity',
]);
const userAdditionalArgs = queryLogDir
? (() => {
const filteredAdditionalArgs: string[] = [];

for (let i = 0; i < rawAdditionalArgs.length; i += 1) {
const arg = rawAdditionalArgs[i];
const m = arg.match(/^--(?:no-)?([^=]+)(?:=.*)?$/);

if (m && managedFlagNames.has(m[1])) {
logger.warn(
`Ignoring "${arg}" from additionalArgs for ${name}: ` +
'this flag is managed internally. Use the corresponding named parameter instead.'
);

// Always skip the managed flag itself. If it is provided in
// space-separated form (e.g. ["--output", "file.sarif"]),
// also skip the following token as its value so it does not
// become a stray positional argument.
const hasInlineValue = arg.includes('=');
if (!hasInlineValue && i + 1 < rawAdditionalArgs.length) {
i += 1;
}

continue;
}

filteredAdditionalArgs.push(arg);
}

return filteredAdditionalArgs;
})()
: rawAdditionalArgs;

let result: CLIExecutionResult;

if (command === 'codeql') {
Expand Down Expand Up @@ -507,9 +563,9 @@ export function registerCLITool(server: McpServer, definition: CLIToolDefinition
options['keep-databases'] = true;
}

result = await executeCodeQLCommand(subcommand, options, positionalArgs, cwd);
result = await executeCodeQLCommand(subcommand, options, [...positionalArgs, ...userAdditionalArgs], cwd);
} else if (command === 'qlt') {
result = await executeQLTCommand(subcommand, options, positionalArgs);
result = await executeQLTCommand(subcommand, options, [...positionalArgs, ...userAdditionalArgs]);
Comment thread
data-douser marked this conversation as resolved.
} else {
throw new Error(`Unsupported command: ${command}`);
}
Expand Down
Loading
Loading