Implementated selective disable of tools to spare with the schema size#1023
Implementated selective disable of tools to spare with the schema size#1023kecsap wants to merge 1 commit intooptave:mainfrom
Conversation
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Greptile SummaryThis PR adds selective tool disabling to the MCP server: a Confidence Score: 4/5Safe to merge — the feature is well-tested and the two P2 findings are non-blocking style/ordering nits. Only P2 findings present: a guard ordering issue that can cause a misleading error message for disabled tools in multi-repo mode, and a type-vs-runtime alignment gap for the optional field. No correctness bugs in the happy path. src/mcp/server.ts (guard ordering) and src/types.ts (optional field typing) Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[startMCPServer] --> B[loadConfig]
B --> C{config.mcp.disabledTools?}
C -->|yes| D[buildDisabledToolSet\nnormalize + lowercase + strip prefix]
C -->|no| E[empty disabled set]
D --> F[buildToolList multiRepo disabledTools]
E --> F
F --> G[filter BASE_TOOLS via includeTool]
G --> H{multiRepo?}
H -->|yes| I[add REPO_PROP to each tool\nconditionally add LIST_REPOS_TOOL]
H -->|no| J[return baseTools only]
I --> K[enabledTools]
J --> K
K --> L[enabledToolNames = new Set of tool names]
L --> M[ListTools handler returns enabledTools]
L --> N[CallTool handler]
N --> O[validateMultiRepoAccess]
O --> P{enabledToolNames.has name?}
P -->|no| Q[return Unknown tool error]
P -->|yes| R[dispatch to TOOL_HANDLERS]
Reviews (1): Last reviewed commit: "Implementated selective disable of tools..." | Re-trigger Greptile |
| validateMultiRepoAccess(multiRepo, name, args); | ||
|
|
||
| if (!enabledToolNames.has(name)) { | ||
| return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true }; | ||
| } |
There was a problem hiding this comment.
validateMultiRepoAccess runs before disabled-tool guard
validateMultiRepoAccess is called on line 171 before the enabledToolNames check on line 173. In multi-repo mode, if a caller omits the required repo argument when invoking a disabled tool, the handler will throw a multi-repo access error instead of returning the expected "Unknown tool: <name>" response. Swapping the two checks keeps the disabled-tool path clean.
| validateMultiRepoAccess(multiRepo, name, args); | |
| if (!enabledToolNames.has(name)) { | |
| return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true }; | |
| } | |
| if (!enabledToolNames.has(name)) { | |
| return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true }; | |
| } | |
| validateMultiRepoAccess(multiRepo, name, args); |
| mcp: { | ||
| defaults: McpDefaults; | ||
| disabledTools: string[]; | ||
| }; |
There was a problem hiding this comment.
disabledTools typed as required but treated optionally at runtime
disabledTools: string[] is non-optional in CodegraphConfig, yet server.ts guards it with config.mcp?.disabledTools ? … : undefined. Any user-supplied config that includes an mcp block without disabledTools (e.g., configs predating this PR) will satisfy the type only because deep-merge with DEFAULTS fills the gap — but if the merge is ever a shallow spread the field can be absent at runtime while TypeScript believes it is always present. Making it optional (disabledTools?: string[]) would align the type with the actual runtime handling and avoid surprising TypeScript errors for callers that construct a partial CodegraphConfig.
| mcp: { | |
| defaults: McpDefaults; | |
| disabledTools: string[]; | |
| }; | |
| mcp: { | |
| defaults: McpDefaults; | |
| disabledTools?: string[]; | |
| }; |
|
I have read the CLA Document and I hereby sign the CLA |
Implements #1022