From 6219de7ca9a8625fa88b02414477f4fe7cc891a8 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 10 Dec 2025 11:36:07 -0700 Subject: [PATCH] feat(mcp-config): add list of disabled_tools (#1533) --- README.md | 22 ++++++++++++++++++++++ internal/agent/coordinator.go | 6 ++++++ internal/config/config.go | 17 +++++++++-------- schema.json | 23 +++++++++++++++++------ 4 files changed, 54 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 32d7ebd50a8dc7762a52539831948be9e19e46ed..e25c99a5cb84372414d68a63a511eba824ac9b76 100644 --- a/README.md +++ b/README.md @@ -275,6 +275,7 @@ using `$(echo $VAR)` syntax. "args": ["/path/to/mcp-server.js"], "timeout": 120, "disabled": false, + "disabled_tools": ["some-tool-name"], "env": { "NODE_ENV": "production" } @@ -284,6 +285,7 @@ using `$(echo $VAR)` syntax. "url": "https://api.githubcopilot.com/mcp/", "timeout": 120, "disabled": false, + "disabled_tools": ["create_issue", "create_pull_request"], "headers": { "Authorization": "Bearer $GH_PAT" } @@ -335,6 +337,26 @@ permissions. Use this with care. You can also skip all permission prompts entirely by running Crush with the `--yolo` flag. Be very, very careful with this feature. +### Disabling Built-In Tools + +If you'd like to prevent Crush from using certain built-in tools entirely, you +can disable them via the `options.disabled_tools` list. Disabled tools are +completely hidden from the agent. + +```json +{ + "$schema": "https://charm.land/crush.json", + "options": { + "disabled_tools": [ + "bash", + "sourcegraph" + ] + } +} +``` + +To disable tools from MCP servers, see the [MCP config section](#mcps). + ### Initialization When you initialize a project, Crush analyzes your codebase and creates diff --git a/internal/agent/coordinator.go b/internal/agent/coordinator.go index 436aa27d95e4b86f83c20c3f46b2e1434986e89d..285fa2ff96b15e24f205fb764457854581a8aa75 100644 --- a/internal/agent/coordinator.go +++ b/internal/agent/coordinator.go @@ -388,6 +388,12 @@ func (c *coordinator) buildTools(ctx context.Context, agent config.Agent) ([]fan } for _, tool := range tools.GetMCPTools(c.permissions, c.cfg.WorkingDir()) { + // Check MCP-specific disabled tools. + if mcpCfg, ok := c.cfg.MCP[tool.MCP()]; ok { + if slices.Contains(mcpCfg.DisabledTools, tool.MCPToolName()) { + continue + } + } if agent.AllowedMCP == nil { // No MCP restrictions filteredTools = append(filteredTools, tool) diff --git a/internal/config/config.go b/internal/config/config.go index 4c9dc7bafe83ff0b75b0a0238fcd71ba9e63a3bf..b8f1fcd0dbbef7e5d5d70e2c99515db6d1f6d7b5 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -144,13 +144,14 @@ const ( ) type MCPConfig struct { - Command string `json:"command,omitempty" jsonschema:"description=Command to execute for stdio MCP servers,example=npx"` - Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set for the MCP server"` - Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the MCP server command"` - Type MCPType `json:"type" jsonschema:"required,description=Type of MCP connection,enum=stdio,enum=sse,enum=http,default=stdio"` - URL string `json:"url,omitempty" jsonschema:"description=URL for HTTP or SSE MCP servers,format=uri,example=http://localhost:3000/mcp"` - Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this MCP server is disabled,default=false"` - Timeout int `json:"timeout,omitempty" jsonschema:"description=Timeout in seconds for MCP server connections,default=15,example=30,example=60,example=120"` + Command string `json:"command,omitempty" jsonschema:"description=Command to execute for stdio MCP servers,example=npx"` + Env map[string]string `json:"env,omitempty" jsonschema:"description=Environment variables to set for the MCP server"` + Args []string `json:"args,omitempty" jsonschema:"description=Arguments to pass to the MCP server command"` + Type MCPType `json:"type" jsonschema:"required,description=Type of MCP connection,enum=stdio,enum=sse,enum=http,default=stdio"` + URL string `json:"url,omitempty" jsonschema:"description=URL for HTTP or SSE MCP servers,format=uri,example=http://localhost:3000/mcp"` + Disabled bool `json:"disabled,omitempty" jsonschema:"description=Whether this MCP server is disabled,default=false"` + DisabledTools []string `json:"disabled_tools,omitempty" jsonschema:"description=List of tools from this MCP server to disable,example=get-library-doc"` + Timeout int `json:"timeout,omitempty" jsonschema:"description=Timeout in seconds for MCP server connections,default=15,example=30,example=60,example=120"` // TODO: maybe make it possible to get the value from the env Headers map[string]string `json:"headers,omitempty" jsonschema:"description=HTTP headers for HTTP/SSE MCP servers"` @@ -221,7 +222,7 @@ type Options struct { DebugLSP bool `json:"debug_lsp,omitempty" jsonschema:"description=Enable debug logging for LSP servers,default=false"` DisableAutoSummarize bool `json:"disable_auto_summarize,omitempty" jsonschema:"description=Disable automatic conversation summarization,default=false"` DataDirectory string `json:"data_directory,omitempty" jsonschema:"description=Directory for storing application data (relative to working directory),default=.crush,example=.crush"` // Relative to the cwd - DisabledTools []string `json:"disabled_tools" jsonschema:"description=Tools to disable"` + DisabledTools []string `json:"disabled_tools,omitempty" jsonschema:"description=List of built-in tools to disable and hide from the agent,example=bash,example=sourcegraph"` DisableProviderAutoUpdate bool `json:"disable_provider_auto_update,omitempty" jsonschema:"description=Disable providers auto-update,default=false"` Attribution *Attribution `json:"attribution,omitempty" jsonschema:"description=Attribution settings for generated content"` DisableMetrics bool `json:"disable_metrics,omitempty" jsonschema:"description=Disable sending metrics,default=false"` diff --git a/schema.json b/schema.json index 47740b9c18c8d2807c74557ffd9e21b5b6658ceb..974200854d28bb300c94613328485ea5a3e2165d 100644 --- a/schema.json +++ b/schema.json @@ -229,6 +229,16 @@ "description": "Whether this MCP server is disabled", "default": false }, + "disabled_tools": { + "items": { + "type": "string", + "examples": [ + "get-library-doc" + ] + }, + "type": "array", + "description": "List of tools from this MCP server to disable" + }, "timeout": { "type": "integer", "description": "Timeout in seconds for MCP server connections", @@ -386,10 +396,14 @@ }, "disabled_tools": { "items": { - "type": "string" + "type": "string", + "examples": [ + "bash", + "sourcegraph" + ] }, "type": "array", - "description": "Tools to disable" + "description": "List of built-in tools to disable and hide from the agent" }, "disable_provider_auto_update": { "type": "boolean", @@ -418,10 +432,7 @@ } }, "additionalProperties": false, - "type": "object", - "required": [ - "disabled_tools" - ] + "type": "object" }, "Permissions": { "properties": {