Skip to content

Commit e2e5c65

Browse files
committed
feat: disable built-in claude-code tools in favor of Code Interpreter
Disable Bash, Write, Read, Edit, NotebookEdit, WebFetch, Glob, Grep, EnterWorktree, and Skill via disallowed_tools in ClaudeAgentOptions. The agent now operates exclusively through Code Interpreter MCP tools and Gateway tools. Added documentation explaining the configuration and how to re-enable tools.
1 parent fd81f91 commit e2e5c65

4 files changed

Lines changed: 66 additions & 0 deletions

File tree

patterns/claude-agent-sdk-multi-agent/README.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,39 @@ patterns/claude-agent-sdk-multi-agent/
5959
| `Task` || Spawn a subagent for focused subtasks |
6060
| Gateway tools | `mcp__gateway__*` | Lambda-based tools via AgentCore Gateway |
6161

62+
## Built-in Tool Configuration
63+
64+
The Claude Agent SDK includes built-in tools from claude-code (Bash, Read, Write, etc.). This pattern disables most of them so the agent operates exclusively through Code Interpreter and Gateway MCP tools.
65+
66+
**Disabled built-in tools** (`disallowed_tools` in `ClaudeAgentOptions`):
67+
68+
| Tool | Why disabled |
69+
|------|-------------|
70+
| `Bash` | Use `mcp__codeint__execute_command` instead (sandboxed Code Interpreter) |
71+
| `Write` | Use `mcp__codeint__write_files` instead (sandboxed Code Interpreter) |
72+
| `Read` | Use `mcp__codeint__read_files` instead (sandboxed Code Interpreter) |
73+
| `Edit` | Use Code Interpreter file operations instead |
74+
| `NotebookEdit` | Use Code Interpreter for notebook-style execution |
75+
| `WebFetch` | Not needed for this pattern |
76+
| `Glob` | Use Code Interpreter for file discovery |
77+
| `Grep` | Use Code Interpreter for content searching |
78+
| `EnterWorktree` | Not applicable in this deployment context |
79+
| `Skill` | Not applicable in this deployment context |
80+
81+
**To re-enable a built-in tool**, remove it from the `disallowed_tools` list in the `_build_options()` function in `agent.py`:
82+
83+
```python
84+
# Before: tool is disabled
85+
disallowed_tools=["Bash", "Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
86+
87+
# After: Bash re-enabled
88+
disallowed_tools=["Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
89+
```
90+
91+
If you also want the agent to proactively use the re-enabled tool, add it to the `allowed_tools` list and mention it in the `system_prompt`.
92+
93+
**Note**: Subagents inherit the parent's MCP server configuration but have their own `tools` list defined in `agents/subagents.py`. The `disallowed_tools` setting on the parent does not automatically apply to subagents — update their tool lists separately if needed.
94+
6295
## Models
6396

6497
- **Main agent**: `us.anthropic.claude-opus-4-6-v1`

patterns/claude-agent-sdk-multi-agent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ def _build_options(resume_id: str | None) -> ClaudeAgentOptions:
107107
mcp_servers=mcp_servers,
108108
model="us.anthropic.claude-opus-4-6-v1",
109109
allowed_tools=allowed_tools,
110+
disallowed_tools=["Bash", "Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
110111
agents=subagents,
111112
resume=resume_id,
112113
thinking={"type": "adaptive"},

patterns/claude-agent-sdk-single-agent/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,37 @@ patterns/claude-agent-sdk-single-agent/
5050
| `read_files` | `mcp__codeint__` | Read files from the Code Interpreter session |
5151
| Gateway tools | `mcp__gateway__*` | Lambda-based tools via AgentCore Gateway |
5252

53+
## Built-in Tool Configuration
54+
55+
The Claude Agent SDK includes built-in tools from claude-code (Bash, Read, Write, etc.). This pattern disables most of them so the agent operates exclusively through Code Interpreter and Gateway MCP tools.
56+
57+
**Disabled built-in tools** (`disallowed_tools` in `ClaudeAgentOptions`):
58+
59+
| Tool | Why disabled |
60+
|------|-------------|
61+
| `Bash` | Use `mcp__codeint__execute_command` instead (sandboxed Code Interpreter) |
62+
| `Write` | Use `mcp__codeint__write_files` instead (sandboxed Code Interpreter) |
63+
| `Read` | Use `mcp__codeint__read_files` instead (sandboxed Code Interpreter) |
64+
| `Edit` | Use Code Interpreter file operations instead |
65+
| `NotebookEdit` | Use Code Interpreter for notebook-style execution |
66+
| `WebFetch` | Not needed for this pattern |
67+
| `Glob` | Use Code Interpreter for file discovery |
68+
| `Grep` | Use Code Interpreter for content searching |
69+
| `EnterWorktree` | Not applicable in this deployment context |
70+
| `Skill` | Not applicable in this deployment context |
71+
72+
**To re-enable a built-in tool**, remove it from the `disallowed_tools` list in the `_build_options()` function in `agent.py`:
73+
74+
```python
75+
# Before: tool is disabled
76+
disallowed_tools=["Bash", "Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
77+
78+
# After: Bash re-enabled
79+
disallowed_tools=["Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
80+
```
81+
82+
If you also want the agent to proactively use the re-enabled tool, add it to the `allowed_tools` list and mention it in the `system_prompt`.
83+
5384
## Models
5485

5586
- **Main agent**: `us.anthropic.claude-opus-4-6-v1`

patterns/claude-agent-sdk-single-agent/agent.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def _build_options(resume_id: str | None) -> ClaudeAgentOptions:
100100
mcp_servers=mcp_servers,
101101
model="us.anthropic.claude-opus-4-6-v1",
102102
allowed_tools=allowed_tools,
103+
disallowed_tools=["Bash", "Write", "NotebookEdit", "Edit", "WebFetch", "Read", "Glob", "Grep", "EnterWorktree", "Skill"],
103104
resume=resume_id,
104105
thinking={"type": "adaptive"},
105106
cli_path="/usr/bin/claude",

0 commit comments

Comments
 (0)