Skip to main content

No project description provided

Project description

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 2025-06-18 and 2025-11-25.
  • 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 binds to loopback and rejects DNS-rebinding requests; host="0.0.0.0" widens the bind and switches those checks off.

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":"ping"}' | python server.py
# {"jsonrpc":"2.0","id":1,"result":{}}

Project details


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.2.0.tar.gz (27.7 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.2.0-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mcpatom-0.2.0.tar.gz
  • Upload date:
  • Size: 27.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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.2.0.tar.gz
Algorithm Hash digest
SHA256 92b2f4f7870a1f0bfac8b074cbfa231f4c129fd748b23ed978d70b3fc81e8494
MD5 a160a1c9dfe0007595c27f656428960b
BLAKE2b-256 c7495b8d4711ccf260a9d44aed00dc2da00585f10ec0f7e084f8beed9d20176a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mcpatom-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.29 {"installer":{"name":"uv","version":"0.11.29","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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 391218fbb9c9cf6a6bfd212349adef86f77177862b6b71183a7555ea5bf074c2
MD5 b9e513e5b3ef905456ecbe704c81335e
BLAKE2b-256 6d4fa1b59e61ebab1d6cfdfbf0381668284a4d60ecf6dbd3ad724e7215b91a66

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page