mirror of
https://github.com/anthropics/claude-code-sdk-python.git
synced 2025-12-23 09:19:52 +00:00
## 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>
107 lines
No EOL
2.4 KiB
TOML
107 lines
No EOL
2.4 KiB
TOML
[build-system]
|
|
requires = ["hatchling"]
|
|
build-backend = "hatchling.build"
|
|
|
|
[project]
|
|
name = "claude-code-sdk"
|
|
version = "0.0.20"
|
|
description = "Python SDK for Claude Code"
|
|
readme = "README.md"
|
|
requires-python = ">=3.10"
|
|
license = {text = "MIT"}
|
|
authors = [
|
|
{name = "Anthropic", email = "support@anthropic.com"},
|
|
]
|
|
classifiers = [
|
|
"Development Status :: 3 - Alpha",
|
|
"Intended Audience :: Developers",
|
|
"License :: OSI Approved :: MIT License",
|
|
"Programming Language :: Python :: 3",
|
|
"Programming Language :: Python :: 3.10",
|
|
"Programming Language :: Python :: 3.11",
|
|
"Programming Language :: Python :: 3.12",
|
|
"Programming Language :: Python :: 3.13",
|
|
"Typing :: Typed",
|
|
]
|
|
keywords = ["claude", "ai", "sdk", "anthropic"]
|
|
dependencies = [
|
|
"anyio>=4.0.0",
|
|
"typing_extensions>=4.0.0; python_version<'3.11'",
|
|
"mcp>=0.1.0",
|
|
]
|
|
|
|
[project.optional-dependencies]
|
|
dev = [
|
|
"pytest>=7.0.0",
|
|
"pytest-asyncio>=0.20.0",
|
|
"anyio[trio]>=4.0.0",
|
|
"pytest-cov>=4.0.0",
|
|
"mypy>=1.0.0",
|
|
"ruff>=0.1.0",
|
|
]
|
|
|
|
[project.urls]
|
|
Homepage = "https://github.com/anthropics/claude-code-sdk-python"
|
|
Documentation = "https://docs.anthropic.com/en/docs/claude-code/sdk"
|
|
Issues = "https://github.com/anthropics/claude-code-sdk-python/issues"
|
|
|
|
[tool.hatch.build.targets.wheel]
|
|
packages = ["src/claude_code_sdk"]
|
|
|
|
[tool.hatch.build.targets.sdist]
|
|
include = [
|
|
"/src",
|
|
"/tests",
|
|
"/README.md",
|
|
"/LICENSE",
|
|
]
|
|
|
|
[tool.pytest.ini_options]
|
|
testpaths = ["tests"]
|
|
pythonpath = ["src"]
|
|
addopts = [
|
|
"--import-mode=importlib",
|
|
]
|
|
|
|
[tool.pytest-asyncio]
|
|
asyncio_mode = "auto"
|
|
|
|
[tool.mypy]
|
|
python_version = "3.10"
|
|
strict = true
|
|
warn_return_any = true
|
|
warn_unused_configs = true
|
|
disallow_untyped_defs = true
|
|
disallow_incomplete_defs = true
|
|
check_untyped_defs = true
|
|
disallow_untyped_decorators = true
|
|
no_implicit_optional = true
|
|
warn_redundant_casts = true
|
|
warn_unused_ignores = true
|
|
warn_no_return = true
|
|
warn_unreachable = true
|
|
strict_equality = true
|
|
|
|
[tool.ruff]
|
|
target-version = "py310"
|
|
line-length = 88
|
|
|
|
[tool.ruff.lint]
|
|
select = [
|
|
"E", # pycodestyle errors
|
|
"W", # pycodestyle warnings
|
|
"F", # pyflakes
|
|
"I", # isort
|
|
"N", # pep8-naming
|
|
"UP", # pyupgrade
|
|
"B", # flake8-bugbear
|
|
"C4", # flake8-comprehensions
|
|
"PTH", # flake8-use-pathlib
|
|
"SIM", # flake8-simplify
|
|
]
|
|
ignore = [
|
|
"E501", # line too long (handled by formatter)
|
|
]
|
|
|
|
[tool.ruff.lint.isort]
|
|
known-first-party = ["claude_code_sdk"] |