Skip to content

feat: add Python MCP server template - #353

Open
ChiragAgg5k wants to merge 4 commits into
appwrite:mainfrom
ChiragAgg5k:feat-352-mcp-server
Open

feat: add Python MCP server template#353
ChiragAgg5k wants to merge 4 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 stateless Python MCP server template for Appwrite Functions and updates generated template-name capitalization.

  • Implements buffered legacy and modern MCP request dispatch.
  • Adds optional bearer authentication, configurable request timeouts, CORS handling, and example tools.
  • Documents deployment, client configuration, and environment variables.
  • Adds the exact MCP SDK dependency and template support files.

Confidence Score: 5/5

The PR appears safe to merge.

No blocking failure remains.

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 timeout parsing failure now safely handled by a default fallback.
python/mcp-server/src/appwrite_mcp/dispatch.py Implements buffered routing between legacy and modern MCP protocol paths with JSON-RPC error handling.
python/mcp-server/src/appwrite_mcp/auth.py Adds optional bearer-token authentication with constant-time token comparison.
python/mcp-server/src/main.py Adds the Appwrite Function entrypoint and package import setup.
python/mcp-server/src/app.py Defines the example MCP server and its echo and addition tools.
python/mcp-server/requirements.txt Pins the MCP SDK version required by the adapter’s private API usage.
python/mcp-server/README.md Documents the template’s protocol behavior, deployment configuration, authentication, timeout, and client setup.
.github/workflows/markdown-table-workflow/index.js Adds MCP capitalization to the README table generator.

Reviews (3): Last reviewed commit: "Revert "docs: quiet pip in MCP server bu..." | 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>
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.

1 participant