[project] name = "mcp" dynamic = ["version"] description = "Model Context Protocol SDK" readme = "README.md" requires-python = ">=3.10" authors = [{ name = "Model Context Protocol a Series of LF Projects, LLC." }] maintainers = [ { name = "David Soria Parra", email = "davidsp@anthropic.com" }, { name = "Marcelo Trylesinski", email = "marcelotryle@gmail.com" }, { name = "Max Isbey", email = "maxisbey@anthropic.com" }, { name = "Felix Weinberger", email = "fweinberger@anthropic.com" }, ] keywords = ["git", "mcp", "llm", "automation"] license = { text = "MIT" } classifiers = [ "Development Status :: 4 - Beta", "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", "Programming Language :: Python :: 3.14", ] dependencies = [ "anyio>=4.9", "httpx>=0.27.1", "httpx-sse>=0.4", "pydantic>=2.12.0", "starlette>=0.48.0; python_version >= '3.14'", "starlette>=0.27; python_version < '3.14'", "python-multipart>=0.0.9", "sse-starlette>=3.0.0", "pydantic-settings>=2.5.2", "uvicorn>=0.31.1; sys_platform != 'emscripten'", "jsonschema>=4.20.0", "pywin32>=311; sys_platform == 'win32'", "pyjwt[crypto]>=2.10.1", "typing-extensions>=4.13.0", "typing-inspection>=0.4.1", ] [project.optional-dependencies] rich = ["rich>=13.9.4"] cli = ["typer>=0.16.0", "python-dotenv>=1.0.0"] ws = ["websockets>=15.0.1"] [project.scripts] mcp = "mcp.cli:app [cli]" [tool.uv] default-groups = ["dev", "docs"] required-version = ">=0.9.5" [dependency-groups] dev = [ # We add mcp[cli,ws] so `uv sync` considers the extras. "mcp[cli,ws]", "pyright>=1.1.400", "pytest>=8.3.4", "ruff>=0.8.5", "trio>=0.26.2", "pytest-flakefinder>=1.1.0", "pytest-xdist>=3.6.1", "pytest-examples>=0.0.14", "pytest-pretty>=1.2.0", "inline-snapshot>=0.23.0", "dirty-equals>=0.9.0", "coverage[toml]>=7.10.7,<=7.13", "pillow>=12.0", "strict-no-cover", ] docs = [ "mkdocs>=1.6.1", "mkdocs-gen-files>=0.5.0", "mkdocs-glightbox>=0.4.0", "mkdocs-literate-nav>=0.6.1", "mkdocs-material[imaging]>=9.5.45", "mkdocstrings-python>=2.0.1", ] [build-system] requires = ["hatchling", "uv-dynamic-versioning"] build-backend = "hatchling.build" [tool.hatch.version] source = "uv-dynamic-versioning" [tool.uv-dynamic-versioning] vcs = "git" style = "pep440" bump = true [project.urls] Homepage = "https://modelcontextprotocol.io" Repository = "https://github.com/modelcontextprotocol/python-sdk" Issues = "https://github.com/modelcontextprotocol/python-sdk/issues" [tool.hatch.build.targets.wheel] packages = ["src/mcp"] [tool.pyright] typeCheckingMode = "strict" include = [ "src/mcp", "tests", "examples/servers", "examples/snippets", "examples/clients", ] venvPath = "." venv = ".venv" # The FastAPI style of using decorators in tests gives a `reportUnusedFunction` error. # See https://github.com/microsoft/pyright/issues/7771 for more details. # TODO(Marcelo): We should remove `reportPrivateUsage = false`. The idea is that we should test the workflow that uses # those private functions instead of testing the private functions directly. It makes it easier to maintain the code source # and refactor code that is not public. executionEnvironments = [ { root = "tests", extraPaths = [ ".", ], reportUnusedFunction = false, reportPrivateUsage = false }, { root = "examples/servers", reportUnusedFunction = false }, ] [tool.ruff] line-length = 120 target-version = "py310" extend-exclude = ["README.md", "README.v2.md"] [tool.ruff.lint] select = [ "ANN", # flake8-annotations "C4", # flake8-comprehensions "C90", # mccabe "D212", # pydocstyle: multi-line docstring summary should start at the first line "E", # pycodestyle "F", # pyflakes "I", # isort "PERF", # Perflint "UP", # pyupgrade "TID251", # https://docs.astral.sh/ruff/rules/banned-api/ ] ignore = [ "ANN204", # special methods (__init__, __enter__, etc.) have well-known return types "ANN401", # `Any` is sometimes the right type; pyright strict handles real misuse "PERF203", ] [tool.ruff.lint.flake8-annotations] allow-star-arg-any = true [tool.ruff.lint.flake8-tidy-imports.banned-api] "pydantic.RootModel".msg = "Use `pydantic.TypeAdapter` instead." [tool.ruff.lint.mccabe] max-complexity = 24 # Default is 10 [tool.ruff.lint.per-file-ignores] "__init__.py" = ["F401"] "tests/**" = ["ANN"] "tests/server/mcpserver/test_func_metadata.py" = ["E501"] "tests/shared/test_progress_notifications.py" = ["PLW0603"] [tool.ruff.lint.pylint] allow-magic-value-types = ["bytes", "float", "int", "str"] max-args = 23 # Default is 5 max-branches = 23 # Default is 12 max-returns = 13 # Default is 6 max-statements = 102 # Default is 50 [tool.uv.workspace] members = ["examples/clients/*", "examples/servers/*", "examples/snippets"] [tool.uv.sources] mcp = { workspace = true } strict-no-cover = { git = "https://github.com/pydantic/strict-no-cover" } [tool.pytest.ini_options] log_cli = true xfail_strict = true addopts = """ --color=yes --capture=fd -p anyio -p examples """ filterwarnings = [ "error", # This should be fixed on Uvicorn's side. "ignore::DeprecationWarning:websockets", "ignore:websockets.server.WebSocketServerProtocol is deprecated:DeprecationWarning", "ignore:Returning str or bytes.*:DeprecationWarning:mcp.server.lowlevel", # pywin32 internal deprecation warning "ignore:getargs.*The 'u' format is deprecated:DeprecationWarning", ] [tool.markdown.lint] default = true MD004 = false # ul-style - Unordered list style MD007.indent = 2 # ul-indent - Unordered list indentation MD013 = false # line-length - Line length MD029 = false # ol-prefix - Ordered list item prefix MD033 = false # no-inline-html Inline HTML MD041 = false # first-line-heading/first-line-h1 MD046 = false # indented-code-blocks MD059 = false # descriptive-link-text # https://coverage.readthedocs.io/en/latest/config.html#run [tool.coverage.run] branch = true patch = ["subprocess"] concurrency = ["multiprocessing", "thread"] source = ["src", "tests"] omit = [ "src/mcp/client/__main__.py", "src/mcp/server/__main__.py", "src/mcp/os/posix/utilities.py", "src/mcp/os/win32/utilities.py", ] # https://coverage.readthedocs.io/en/latest/config.html#report [tool.coverage.report] fail_under = 100 skip_covered = true show_missing = true ignore_errors = true precision = 2 exclude_lines = [ "pragma: no cover", "pragma: lax no cover", "if TYPE_CHECKING:", "@overload", "raise NotImplementedError", "^\\s*\\.\\.\\.\\s*$", ] # https://coverage.readthedocs.io/en/latest/config.html#paths [tool.coverage.paths] source = [ "src/", "/home/runner/work/python-sdk/python-sdk/src/", 'D:\a\python-sdk\python-sdk\src', ] [tool.inline-snapshot] default-flags = ["disable"] format-command = "ruff format --stdin-filename {filename}"