Skip to main content

mcpatom

A minimal Python MCP Server SDK.

From Greek atomos: indivisible. The whole library is a single file, mcpatom.py, consumable two ways:

  • Copy the file into your project. No dependency, no lockfile entry.
  • Install the package: pip install mcpatom - the file itself is the installed module.

Scope

  • Tools, resources, and prompts, over stdio or streamable HTTP.
  • Protocol versions 2026-07-28 (stateless, per-request _meta) and the initialize-handshake versions 2025-11-25 and 2025-06-18, served side by side.
  • stdlib-only Python >= 3.10, no dependencies, ever.

Everything else (sampling, elicitation, subscriptions, auth, etc.) is deliberately omitted.

Usage

from mcpatom import Server

srv = Server("my-server")


@srv.tool
def greet(name: str, excited: bool = False) -> str:
    """Return a greeting for the given name."""
    return f"Hello, {name}{'!' if excited else '.'}"


@srv.resource("data://motd")
def motd() -> str:
    """Message of the day."""
    return "Be indivisible."


@srv.prompt
def haiku(topic: str) -> str:
    """Ask for a haiku."""
    return f"Write a haiku about {topic}."


srv.serve_stdio()

For streamable HTTP instead of stdio, end with:

srv.serve_http(8388)  # http://127.0.0.1:8388/mcp

serve_http accepts only localhost (and the bind host) as Origin/Host; allowed_origins=["*.example.com"] replaces that list, ["*"] allows any origin, and host="0.0.0.0" requires it.

More runnable servers in examples/.

Schemas and return types

Each function's name, docstring, and annotations become the tool's name, description, and schema; @srv.tool(name=, description=, input_schema=, output_schema=) override generation, and extra= merges raw fields into the listing. Server() also takes version= and instructions=. Parameters may be annotated with any of these:

  • str
  • int
  • float
  • bool
  • list[X] (or bare list)
  • Literal[...]
  • TypedDict
  • X | None of any of the above

Annotated[X, "text"] adds a description the model sees. A parameter's default is published in the schema when it is JSON-representable; a None default is omitted unless null is a selectable Literal value.

A tool may return:

  • str - one text block
  • dict - JSON text plus structuredContent; a TypedDict return annotation publishes the matching outputSchema
  • Image(data, mime_type) / Audio(data, mime_type) - one binary block (raw bytes in, base64 on the wire)
  • a tuple - one block per item: str text, Image/Audio media, a dict whose "type" names a spec block type verbatim (e.g. resource_link)
  • None - empty content; any other JSON value - text

Raising is the error API: any exception becomes isError content the model can read and correct.

Resources return str (text) or bytes (base64 blob).

Prompts take only str arguments and return a str user message, or a list of message dicts passed through verbatim.

Wiring it up

claude mcp add my-server -- /abs/path/.venv/bin/python /abs/path/server.py

or in any mcpServers config:

{"mcpServers": {"my-server": {"command": "/abs/path/.venv/bin/python", "args": ["/abs/path/server.py"]}}}

Smoke test without a client:

echo '{"jsonrpc":"2.0","id":1,"method":"server/discover"}' | python server.py
# {"jsonrpc":"2.0","id":1,"result":{"resultType":"complete","_meta":{...},"supportedVersions":[...],"capabilities":{"tools":{}},"ttlMs":0,"cacheScope":"private"}}

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcpatom-0.3.0.tar.gz (30.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcpatom-0.3.0-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file mcpatom-0.3.0.tar.gz.

File metadata

  • Download URL: mcpatom-0.3.0.tar.gz
  • Upload date:
  • Size: 30.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcpatom-0.3.0.tar.gz
Algorithm Hash digest
SHA256 3f981c9e6d087b24fb26c5dcf613149af9562c84cd4bea668dc75d0285f86f6a
MD5 e2643cc12f8f197c273c5f5a3ac76d10
BLAKE2b-256 38110613a030ac6ddc5ac8083daf4a391fa76389bfea18f65f1a99970c655b1f

See more details on using hashes here.

File details

Details for the file mcpatom-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: mcpatom-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.10 {"installer":{"name":"uv","version":"0.12.10","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mcpatom-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fcff626a16b0faad3a63163066fe6a1a9bbf039e2bb1769467e63f36aece399
MD5 eba7bc171c3b27c32a598466bbe454c3
BLAKE2b-256 f0ac9ce497c3d80a2e0e35940ae1b8ebee70b4d72fab94110fbcd9ef62b502bc

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page