Skip to content
Open
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
1 change: 0 additions & 1 deletion package-lock.json

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

23 changes: 17 additions & 6 deletions src/mcp/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -873,15 +873,26 @@ export class ToolHandler {
name: string,
maxLength: number = MAX_INPUT_LENGTH
): string | ToolResult {
if (typeof value !== 'string' || value.length === 0) {
return this.errorResult(`${name} must be a non-empty string`);
// Accept common MCP-client aliases: if `task` is missing but `query`
// was supplied (or vice-versa), the caller already resolves the
// fallback via `args.task ?? args.query`. Here we only validate.
if (typeof value !== 'string') {
const got = value === undefined ? 'undefined' : typeof value;
return this.errorResult(
`${name} must be a non-empty string (got ${got}). ` +
`Make sure to pass the \`${name}\` parameter directly — not wrapped in an object or nested.`
);
}
if (value.length > maxLength) {
const trimmed = value.trim();
if (trimmed.length === 0) {
return this.errorResult(`${name} must be a non-empty string (received whitespace only)`);
}
if (trimmed.length > maxLength) {
return this.errorResult(
`${name} exceeds maximum length of ${maxLength} characters (got ${value.length})`
`${name} exceeds maximum length of ${maxLength} characters (got ${trimmed.length})`
);
}
return value;
return trimmed;
}

/**
Expand Down Expand Up @@ -1147,7 +1158,7 @@ export class ToolHandler {
* Handle codegraph_context
*/
private async handleContext(args: Record<string, unknown>): Promise<ToolResult> {
const task = this.validateString(args.task, 'task');
const task = this.validateString(args.task ?? args.query, 'task');
if (typeof task !== 'string') return task;

// Mark session as consulted (enables Grep/Glob/Bash)
Expand Down