Skip to content

Implementated selective disable of tools to spare with the schema size#1023

Open
kecsap wants to merge 1 commit intooptave:mainfrom
kecsap:main
Open

Implementated selective disable of tools to spare with the schema size#1023
kecsap wants to merge 1 commit intooptave:mainfrom
kecsap:main

Conversation

@kecsap
Copy link
Copy Markdown

@kecsap kecsap commented Apr 28, 2026

Implements #1022

@github-actions
Copy link
Copy Markdown
Contributor


Thank you for your submission, we really appreciate it. Like many open-source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution. You can sign the CLA by just posting a Pull Request Comment same as the below format.


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-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 28, 2026

Greptile Summary

This PR adds selective tool disabling to the MCP server: a disabledTools string array in config.mcp is normalized (prefix-stripped, lowercased) and used to filter the tool list returned by ListTools and to gate execution in CallTool. Both single- and multi-repo modes are handled, and the feature is covered by new unit tests.

Confidence Score: 4/5

Safe 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

Filename Overview
src/mcp/tool-registry.ts Adds buildDisabledToolSet and normalizeToolName helpers; updates buildToolList to accept and apply a disabled-tools list with prefix-stripping support.
src/mcp/server.ts Reads disabledTools from config, passes enabled tool set to both the list and call handlers; disabled-tool guard runs after validateMultiRepoAccess (ordering issue flagged).
src/types.ts Adds disabledTools: string[] to CodegraphConfig.mcp; should be optional to match the defensive runtime handling in server.ts.
src/infrastructure/config.ts Adds disabledTools: [] as string[] to the DEFAULTS object so the field is always present after config merge.
tests/unit/mcp.test.ts Adds unit tests for disabled-tool filtering in both single- and multi-repo modes, and an integration-style test verifying both list and call handlers respect disabledTools.
tests/unit/config.test.ts Adds a simple assertion that DEFAULTS.mcp.disabledTools is an empty array.

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]
Loading

Fix All in Claude Code

Reviews (1): Last reviewed commit: "Implementated selective disable of tools..." | Re-trigger Greptile

Comment thread src/mcp/server.ts
Comment on lines 171 to +175
validateMultiRepoAccess(multiRepo, name, args);

if (!enabledToolNames.has(name)) {
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
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);

Fix in Claude Code

Comment thread src/types.ts
Comment on lines 1202 to 1205
mcp: {
defaults: McpDefaults;
disabledTools: string[];
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 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.

Suggested change
mcp: {
defaults: McpDefaults;
disabledTools: string[];
};
mcp: {
defaults: McpDefaults;
disabledTools?: string[];
};

Fix in Claude Code

@kecsap
Copy link
Copy Markdown
Author

kecsap commented Apr 28, 2026

I have read the CLA Document and I hereby sign the CLA

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant