Skip to content

Commit e4feaf2

Browse files
ashwin-antclaude
andauthored
Remove unstable public APIs from SDK (#151)
Hide hooks, tool permission callbacks, and SDK MCP server APIs from public interface while keeping implementation code intact. These features are not yet stable and should not be documented or exposed to users. Changes: - Remove hook-related exports (HookCallback, HookContext, HookMatcher) from __all__ - Remove tool permission exports (CanUseTool, ToolPermissionContext) from __all__ - Remove SDK MCP exports (tool, create_sdk_mcp_server, SdkMcpTool) from __all__ - Delete examples using unstable APIs (tool_permission_callback.py, mcp_calculator.py) - Remove SDK MCP server documentation from README 🤖 Generated with [Claude Code](https://claude.ai/code) --------- Co-authored-by: Claude <[email protected]>
1 parent 99d1371 commit e4feaf2

File tree

5 files changed

+1
-727
lines changed

5 files changed

+1
-727
lines changed

README.md

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -76,90 +76,6 @@ options = ClaudeCodeOptions(
7676
)
7777
```
7878

79-
### SDK MCP Servers (In-Process)
80-
81-
The SDK now supports in-process MCP servers that run directly within your Python application, eliminating the need for separate processes.
82-
83-
#### Creating a Simple Tool
84-
85-
```python
86-
from claude_code_sdk import tool, create_sdk_mcp_server
87-
88-
# Define a tool using the @tool decorator
89-
@tool("greet", "Greet a user", {"name": str})
90-
async def greet_user(args):
91-
return {
92-
"content": [
93-
{"type": "text", "text": f"Hello, {args['name']}!"}
94-
]
95-
}
96-
97-
# Create an SDK MCP server
98-
server = create_sdk_mcp_server(
99-
name="my-tools",
100-
version="1.0.0",
101-
tools=[greet_user]
102-
)
103-
104-
# Use it with Claude
105-
options = ClaudeCodeOptions(
106-
mcp_servers={"tools": server}
107-
)
108-
109-
async for message in query(prompt="Greet Alice", options=options):
110-
print(message)
111-
```
112-
113-
#### Benefits Over External MCP Servers
114-
115-
- **No subprocess management** - Runs in the same process as your application
116-
- **Better performance** - No IPC overhead for tool calls
117-
- **Simpler deployment** - Single Python process instead of multiple
118-
- **Easier debugging** - All code runs in the same process
119-
- **Type safety** - Direct Python function calls with type hints
120-
121-
#### Migration from External Servers
122-
123-
```python
124-
# BEFORE: External MCP server (separate process)
125-
options = ClaudeCodeOptions(
126-
mcp_servers={
127-
"calculator": {
128-
"type": "stdio",
129-
"command": "python",
130-
"args": ["-m", "calculator_server"]
131-
}
132-
}
133-
)
134-
135-
# AFTER: SDK MCP server (in-process)
136-
from my_tools import add, subtract # Your tool functions
137-
138-
calculator = create_sdk_mcp_server(
139-
name="calculator",
140-
tools=[add, subtract]
141-
)
142-
143-
options = ClaudeCodeOptions(
144-
mcp_servers={"calculator": calculator}
145-
)
146-
```
147-
148-
#### Mixed Server Support
149-
150-
You can use both SDK and external MCP servers together:
151-
152-
```python
153-
options = ClaudeCodeOptions(
154-
mcp_servers={
155-
"internal": sdk_server, # In-process SDK server
156-
"external": { # External subprocess server
157-
"type": "stdio",
158-
"command": "external-server"
159-
}
160-
}
161-
)
162-
```
16379

16480
## API Reference
16581

examples/mcp_calculator.py

Lines changed: 0 additions & 181 deletions
This file was deleted.

0 commit comments

Comments
 (0)