claude-code-sdk-python/tests
kashyap murali 9ef57859af
feat: Add in-process SDK MCP server support (#142)
## Summary

Adds in-process SDK MCP server support to the Python SDK, building on
the control protocol from #139.

**Note: Targets `dickson/control` branch (PR #139), not `main`.**

## Key Changes

- Added `@tool` decorator and `create_sdk_mcp_server()` API for defining
in-process MCP servers
- SDK MCP servers run directly in the Python process (no subprocess
overhead)
- Moved SDK MCP handling from Transport to Query class for proper
architectural layering
- Added `McpSdkServerConfig` type and integrated with control protocol

## Example

```python
from claude_code_sdk import tool, create_sdk_mcp_server

@tool("greet", "Greet a user", {"name": str})
async def greet_user(args):
    return {"content": [{"type": "text", "text": f"Hello, {args['name']}!"}]}

server = create_sdk_mcp_server(name="my-tools", tools=[greet_user])

options = ClaudeCodeOptions(mcp_servers={"tools": server})
```

## Testing

- Added integration tests in `test_sdk_mcp_integration.py`
- Added example calculator server in `examples/mcp_calculator.py`

---------

Co-authored-by: Dickson Tsai <dickson@anthropic.com>
Co-authored-by: Ashwin Bhat <ashwin@anthropic.com>
Co-authored-by: Claude <noreply@anthropic.com>
2025-09-03 08:29:32 -07:00
..
conftest.py Initial Python SDK import 2025-06-12 00:16:19 -07:00
test_changelog.py Add changelog and changelog format check (#77) 2025-07-21 10:53:01 -07:00
test_client.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_errors.py Initial Python SDK import 2025-06-12 00:16:19 -07:00
test_integration.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_message_parser.py Move thinking block parsing from user to assistant messages (#119) 2025-08-19 13:36:12 -07:00
test_sdk_mcp_integration.py feat: Add in-process SDK MCP server support (#142) 2025-09-03 08:29:32 -07:00
test_streaming_client.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_subprocess_buffering.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_transport.py Implement control protocol support for Python SDK (#139) 2025-09-01 23:04:22 -07:00
test_types.py Add support for plan permission mode (#116) 2025-08-07 13:06:05 -07:00