{"id":45869898,"url":"https://github.com/mrexodia/zeromcp","last_synced_at":"2026-02-27T09:45:29.465Z","repository":{"id":324448054,"uuid":"1097300098","full_name":"mrexodia/zeromcp","owner":"mrexodia","description":"Zero-dependency MCP server implementation.","archived":false,"fork":false,"pushed_at":"2026-02-23T01:13:01.000Z","size":199,"stargazers_count":59,"open_issues_count":4,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2026-02-23T07:27:05.917Z","etag":null,"topics":["mcp","mcp-sdk","modelcontextprotocol","python","python-mcp"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/zeromcp/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mrexodia.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-15T22:49:35.000Z","updated_at":"2026-02-23T01:13:05.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mrexodia/zeromcp","commit_stats":null,"previous_names":["mrexodia/zeromcp"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/mrexodia/zeromcp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzeromcp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzeromcp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzeromcp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzeromcp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mrexodia","download_url":"https://codeload.github.com/mrexodia/zeromcp/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mrexodia%2Fzeromcp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29889931,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-27T08:34:21.514Z","status":"ssl_error","status_checked_at":"2026-02-27T08:32:38.035Z","response_time":57,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["mcp","mcp-sdk","modelcontextprotocol","python","python-mcp"],"created_at":"2026-02-27T09:45:28.847Z","updated_at":"2026-02-27T09:45:29.460Z","avatar_url":"https://github.com/mrexodia.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zeromcp\n\n**Minimal MCP server implementation in pure Python.**\n\nA lightweight, handcrafted implementation of the [Model Context Protocol](https://modelcontextprotocol.io/) focused on what most users actually need: exposing tools with clean Python type annotations.\n\n## Features\n\n- ✨ **Zero dependencies** - Pure Python, standard library only\n- 🎯 **Type-safe** - Native Python type annotations for everything\n- 🚀 **Fast** - Minimal overhead, maximum performance\n- 🛠️ **Handcrafted** - Written by a human\u003csup\u003e[1](#ai-usage)\u003c/sup\u003e, verified against the spec\n- 🌐 **HTTP/SSE transport** - Streamable responses\n- 📡 **Stdio transport** - For legacy clients\n- 📦 **Tiny** - Less than 1,000 lines of code\n\n## Installation\n\n```bash\npip install zeromcp\n```\n\nOr with uv:\n\n```bash\nuv add zeromcp\n```\n\n## Quick Start\n\n```python\nfrom typing import Annotated\nfrom zeromcp import McpServer\n\nmcp = McpServer(\"my-server\")\n\n@mcp.tool\ndef greet(\n    name: Annotated[str, \"Name to greet\"],\n    age: Annotated[int | None, \"Age of person\"] = None\n) -\u003e str:\n    \"\"\"Generate a greeting message\"\"\"\n    if age:\n        return f\"Hello, {name}! You are {age} years old.\"\n    return f\"Hello, {name}!\"\n\nif __name__ == \"__main__\":\n    mcp.serve(\"127.0.0.1\", 8000)\n```\n\nThen manually test your MCP server with the [inspector](https://github.com/modelcontextprotocol/inspector):\n\n```bash\nnpx -y @modelcontextprotocol/inspector\n```\n\nOnce things are working you can configure the `mcp.json`:\n\n```json\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"type\": \"http\",\n      \"url\": \"http://127.0.0.1:8000/mcp\"\n    }\n  }\n}\n```\n\n## Stdio Transport\n\nFor MCP clients that only support stdio transport:\n\n```python\nfrom zeromcp import McpServer\n\nmcp = McpServer(\"my-server\")\n\n@mcp.tool\ndef greet(name: str) -\u003e str:\n    \"\"\"Generate a greeting\"\"\"\n    return f\"Hello, {name}!\"\n\nif __name__ == \"__main__\":\n    mcp.stdio()\n```\n\nThen configure in `mcp.json` (different for every client):\n\n```json\n{\n  \"mcpServers\": {\n    \"my-server\": {\n      \"command\": \"python\",\n      \"args\": [\"path/to/server.py\"]\n    }\n  }\n}\n```\n\n## Type Annotations\n\nzeromcp uses native Python `Annotated` types for schema generation:\n\n```python\nfrom typing import Annotated, Optional, TypedDict, NotRequired\n\nclass GreetingResponse(TypedDict):\n    message: Annotated[str, \"Greeting message\"]\n    name: Annotated[str, \"Name that was greeted\"]\n    age: Annotated[NotRequired[int], \"Age if provided\"]\n\n@mcp.tool\ndef greet(\n    name: Annotated[str, \"Name to greet\"],\n    age: Annotated[Optional[int], \"Age of person\"] = None\n) -\u003e GreetingResponse:\n    \"\"\"Generate a greeting message\"\"\"\n    if age is not None:\n        return {\n            \"message\": f\"Hello, {name}! You are {age} years old.\",\n            \"name\": name,\n            \"age\": age\n        }\n    return {\n        \"message\": f\"Hello, {name}!\",\n        \"name\": name\n    }\n```\n\n## Union Types\n\nTools can accept multiple input types:\n\n```python\nfrom typing import Annotated, TypedDict\n\nclass StructInfo(TypedDict):\n    name: Annotated[str, \"Structure name\"]\n    size: Annotated[int, \"Structure size in bytes\"]\n    fields: Annotated[list[str], \"List of field names\"]\n\n@mcp.tool\ndef struct_get(\n    names: Annotated[list[str], \"Array of structure names\"]\n         | Annotated[str, \"Single structure name\"]\n) -\u003e list[StructInfo]:\n    \"\"\"Retrieve structure information by names\"\"\"\n    return [\n        {\n            \"name\": name,\n            \"size\": 128,\n            \"fields\": [\"field1\", \"field2\", \"field3\"]\n        }\n        for name in (names if isinstance(names, list) else [names])\n    ]\n```\n\n## Error Handling\n\n```python\nfrom zeromcp import McpToolError\n\n@mcp.tool\ndef divide(\n    numerator: Annotated[float, \"Numerator\"],\n    denominator: Annotated[float, \"Denominator\"]\n) -\u003e float:\n    \"\"\"Divide two numbers\"\"\"\n    if denominator == 0:\n        raise McpToolError(\"Division by zero\")\n    return numerator / denominator\n```\n\n## Resources\n\nExpose read-only data via URI patterns. Resources are serialized as JSON.\n\n```python\nfrom typing import Annotated\n\n@mcp.resource(\"file://data.txt\")\ndef read_file() -\u003e dict:\n    \"\"\"Get information about data.txt\"\"\"\n    return {\"name\": \"data.txt\", \"size\": 1024}\n\n@mcp.resource(\"file://{filename}\")\ndef read_any_file(\n    filename: Annotated[str, \"Name of file to read\"]\n) -\u003e dict:\n    \"\"\"Get information about any file\"\"\"\n    return {\"name\": filename, \"size\": 2048}\n```\n\n## Prompts\n\nExpose reusable prompt templates with typed arguments.\n\n```python\nfrom typing import Annotated\n\n@mcp.prompt\ndef code_review(\n    code: Annotated[str, \"Code to review\"],\n    language: Annotated[str, \"Programming language\"] = \"python\"\n) -\u003e str:\n    \"\"\"Review code for bugs and improvements\"\"\"\n    return f\"Please review this {language} code:\\n\\n```{language}\\n{code}\\n```\"\n```\n\n## CORS\n\nBy default, zeromcp allows CORS requests from localhost origins (`localhost`, `127.0.0.1`, `::1`) on **any port**. This allows tools like the MCP Inspector or local AI tools to communicate with your MCP server.\n\n```python\nfrom zeromcp import McpServer\n\nmcp = McpServer(\"my-server\")\n\n# Default: allow localhost on any port\nmcp.cors_allowed_origins = mcp.cors_localhost\n\n# Allow all origins (use with caution)\nmcp.cors_allowed_origins = \"*\"\n\n# Allow specific origins\nmcp.cors_allowed_origins = [\n    \"http://localhost:3000\",\n    \"https://myapp.example.com\",\n]\n\n# Disable CORS (blocks all browser cross-origin requests)\nmcp.cors_allowed_origins = None\n\n# Custom logic\nmcp.cors_allowed_origins = lambda origin: origin.endswith(\".example.com\")\n```\n\nNote: CORS only affects browser-based requests. Non-browser clients like `curl` or MCP desktop apps are unaffected by this setting.\n\n## Supported clients\n\nThe following clients have been tested:\n\n- [Claude Code](https://code.claude.com/docs/en/mcp#installing-mcp-servers)\n- [Claude Desktop](https://modelcontextprotocol.io/docs/develop/connect-local-servers#installing-the-filesystem-server) (_stdio only_)\n- [Visual Studio Code](https://code.visualstudio.com/docs/copilot/customization/mcp-servers)\n- [Roo Code](https://docs.roocode.com/features/mcp/using-mcp-in-roo) / [Cline](https://docs.cline.bot/mcp/configuring-mcp-servers) / [Kilo Code](https://kilocode.ai/docs/features/mcp/using-mcp-in-kilo-code)\n- [LM Studio](https://lmstudio.ai/docs/app/mcp)\n- [Jan](https://www.jan.ai/docs/desktop/mcp#configure-and-use-mcps-within-jan)\n- [Gemini CLI](https://geminicli.com/docs/tools/mcp-server/#how-to-set-up-your-mcp-server)\n- [Cursor](https://cursor.com/docs/context/mcp)\n- [Windsurf](https://docs.windsurf.com/windsurf/cascade/mcp)\n- [Zed](https://zed.dev/docs/ai/mcp) (_stdio only_)\n- [Warp](https://docs.warp.dev/knowledge-and-collaboration/mcp#adding-an-mcp-server)\n\n_Note_: generally the `/mcp` endpoint is preferred, but not all clients support it correctly.\n\n\u003ca name=\"ai-usage\"\u003e\u003c/a\u003e\n\u003csup\u003e1\u003c/sup\u003eREADME and some of the tests written by Claude\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrexodia%2Fzeromcp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmrexodia%2Fzeromcp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmrexodia%2Fzeromcp/lists"}