Skip to content

feat: add Python MCP server template - #353

Merged
ChiragAgg5k merged 5 commits into
appwrite:mainfrom
ChiragAgg5k:feat-352-mcp-server
Aug 3, 2026
Merged

feat: add Python MCP server template#353
ChiragAgg5k merged 5 commits into
appwrite:mainfrom
ChiragAgg5k:feat-352-mcp-server

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

What

Adds a Python MCP server template for Appwrite Functions (python/mcp-server).

Stateless Model Context Protocol over HTTPS using the official Python SDK (mcp==2.0.0). Demo tools: echo, add. Optional bearer auth. Soft timeout before the 30s domain hard-cap.

Appwrite Functions cannot run MCPServer.streamable_http_app() — there is no Starlette lifespan, so StreamableHTTPSessionManager raises RuntimeError: Task group is not initialized. This template drives the SDK's buffered entry points instead:

  • legacy handshake → serve_one + Connection.from_envelope
  • modern (2026-07-28) → handle_modern_request (ASGI scope/receive/send shim)

src/appwrite_mcp/ is kept as a package (not flattened) so modules like auth / dispatch / transport do not sit at the front of sys.path next to Open Runtimes' top-level server module.

Also adds mcp: "MCP" to the README table generator overrideWords so the template titles as MCP Server. The root README table is intentionally left unchanged; the existing workflow regenerates it after merge.

Related: #352

Live demo

Demo: initialize, list tools, call echo/add against the hosted MCP

claude mcp add --transport http appwrite-mcp-demo https://mcp-example.sgp.appwrite.run

Or Cursor / Claude Desktop mcp.json:

{
  "mcpServers": {
    "appwrite-mcp-demo": {
      "url": "https://mcp-example.sgp.appwrite.run"
    }
  }
}

Standalone reference (tests, local dev server, more examples): https://github.com/ChiragAgg5k/appwrite-mcp-template

Testing

  • Deployed to Appwrite Cloud (python-3.12), domain https://mcp-example.sgp.appwrite.run
  • Smoke: initializenotifications/initialized (202) → tools/listtools/call echo
  • Connected Claude Code / Cursor via Streamable HTTP URL
  • Local adapter unit tests in the reference repo (uv run pytest — 14 passed)
  • Reviewer: pip install -r requirements.txt in python/mcp-server, push as a Function, point a client at the domain

Notes for reviewers

  • Pins mcp==2.0.0 exactly — uses private helpers (_streamable_http_modern, _lowlevel_server) that can move.
  • Requires Python ≥3.10 (SDK floor); README targets Python 3.12.
  • Stateless JSON only — no SSE, no progress streaming, no sampling back-channel.
  • Console registry entry (appwrite/appwritefunction.php) intentionally deferred; many templates ship without one.

Stateless MCP over Appwrite Functions using the official Python SDK
(mcp==2.0.0) with a buffered Streamable HTTP adapter. Also teach the
README table generator to title-case "mcp" as "MCP".

Closes appwrite#352

Co-authored-by: Cursor <cursoragent@cursor.com>
@greptile-apps

greptile-apps Bot commented Aug 1, 2026

Copy link
Copy Markdown

Greptile Summary

Adds a Python MCP server template for Appwrite Functions, implementing stateless JSON-RPC transport over the MCP Python SDK.

  • Adds optional bearer authentication and configurable request timeouts.
  • Supports legacy and modern MCP request dispatch without a Starlette lifespan.
  • Adds example echo and add tools, deployment documentation, and MCP title capitalization.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains; the previously reported invalid timeout configuration is now caught and replaced with the documented default.

Important Files Changed

Filename Overview
python/mcp-server/src/appwrite_mcp/transport.py Adapts Appwrite requests and responses to MCP dispatch, with the previously reported invalid-timeout crash now handled by falling back to 25 seconds.
python/mcp-server/src/appwrite_mcp/dispatch.py Implements buffered legacy and modern MCP dispatch, JSON-RPC error handling, and response sanitization.
python/mcp-server/src/appwrite_mcp/auth.py Adds optional bearer authentication with constant-time token comparison and structured error responses.
python/mcp-server/src/app.py Defines the example MCP server and its echo and addition tools.
python/mcp-server/src/main.py Adds the Appwrite Function entrypoint and delegates requests to the MCP transport.
python/mcp-server/requirements.txt Pins the MCP SDK version required by the template's private integration points.
python/mcp-server/README.md Documents deployment, protocol behavior, authentication, timeout configuration, and client setup.
.github/workflows/markdown-table-workflow/index.js Preserves uppercase MCP branding when generating template titles.

Reviews (4): Last reviewed commit: "docs: clarify MCP server purpose in READ..." | Re-trigger Greptile

Comment thread python/mcp-server/src/appwrite_mcp/transport.py Outdated
ChiragAgg5k and others added 3 commits August 1, 2026 17:04
Non-numeric or non-positive values used to raise ValueError before
dispatch and skip an MCP JSON-RPC response.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keeps Appwrite Function build logs to open-runtimes lines instead of
full dependency resolution spam.

Co-authored-by: Cursor <cursoragent@cursor.com>
Keep the verbose pip install build command.

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@ChiragAgg5k
ChiragAgg5k merged commit d3e497f into appwrite:main Aug 3, 2026
11 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the feat-352-mcp-server branch August 3, 2026 11:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants