mcp-server-template
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@mcp-server-templatecheck the server health and list the tools you expose"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
mcp-server-template
A starting point for MCP servers that are going in front of real users, not just a demo. Clone it, replace the three example tools with your product's operations, and you already have:
Bearer-token auth on the HTTP transport (
MCP_TOKENS="alice:token1,bob:token2"), constant-time compare,401+WWW-Authenticateon failurePer-client rate limits (sliding window per token,
429+Retry-After) and a process-wide tool budget as defense in depthHost allow-list (the SDK's DNS-rebinding protection, configured instead of disabled)
Structured call logging: one JSON line per request with method, tool, duration, outcome
stdio and Streamable HTTP from the same code (
mcp-template stdio/mcp-template http)Tests that run without a network (Starlette TestClient against the real transport), CI on Linux and macOS, a Dockerfile that runs as non-root
Tool docstrings written for the model, and a swappable
Backendclass so tests never touch your real API
Built on the official Python SDK (mcp 2.x, MCPServer).
Quickstart
git clone https://github.com/JustFady/mcp-server-template my-server && cd my-server
uv venv && uv pip install -e ".[dev]"
.venv/bin/python -m pytest -q
# local, for Claude Desktop / Claude Code / Cursor
.venv/bin/mcp-template stdio
# network
MCP_TOKENS="alice:$(openssl rand -hex 24)" .venv/bin/mcp-template http --host 0.0.0.0 --port 8000 --rate 60
curl -s localhost:8000/healthzClaude Code: claude mcp add my-server -- /path/to/.venv/bin/mcp-template stdio
Claude Desktop (claude_desktop_config.json):
{ "mcpServers": { "my-server": { "command": "/path/to/.venv/bin/mcp-template", "args": ["stdio"] } } }Remote clients connect to https://your-host/mcp with Authorization: Bearer <token>. Set the public hostname so the SDK's DNS-rebinding protection accepts it: --allowed-host mcp.example.com (repeatable) or MCP_ALLOWED_HOSTS=mcp.example.com,mcp.example.com:443. Unknown Host headers are rejected (421 from the SDK middleware; some servers surface it as 400).
Related MCP server: Python MCP Server Kit
Adapting it to your product
src/mcp_template/server.py: replaceBackendwith your API client and the example tools with 5–10 operations your users actually ask for. Keep return values small and structured; the model reads them every call.Write each docstring as instructions to the model: what it does, when to use it, what it returns, what it must not be used for.
tests/: fake the backend; assert tool names, descriptions and error behavior.Decide limits:
--rateper client per minute;GlobalToolBudgetper process.Put it behind TLS (a reverse proxy or your platform's ingress). Rotate tokens by editing
MCP_TOKENSand restarting.
Layout
src/mcp_template/
server.py tools + build_server()
http.py BearerAuth ASGI middleware, make_app()
middleware.py call_logger, GlobalToolBudget (MCP-level middleware)
ratelimit.py SlidingWindow
__main__.py CLI
tests/ ratelimit, server, http (real transport via TestClient)
Dockerfile, .github/workflows/ci.ymlDocker
docker build -t my-mcp .
docker run --rm -p 8000:8000 -e MCP_TOKENS="alice:changeme" my-mcpWhy not OAuth?
For a server you operate for a known set of clients, static bearer tokens over TLS are simpler to run and to audit. The SDK supports full OAuth (AuthSettings + a TokenVerifier) when you need third-party clients to self-register; this template leaves that door open rather than making you walk through it on day one.
License
MIT © Fady Youssef
This server cannot be deployed
Maintenance
Related MCP Connectors
Operate Linux, macOS and Windows from your LLM. Every action runs through an auditable allowlist.
Verified, pay-per-use API tools for AI agents through one authenticated connection.
Machine-native tools for autonomous agents with free routing and x402 USDC pay-per-call.
The OpenRouter for tools. One MCP connection gives any AI agent 254 hosted tools, pay per call.
Related MCP Servers
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to securely discover, execute, and observe tools with role-based access control and audit logging. Serves tools over MCP stdio and HTTP for integration with Claude Desktop, Cursor, and other clients.1-
- AlicenseNot gradedqualityCmaintenanceEnables developers to build and deploy secure, typed Model Context Protocol servers with tools, resources, prompts, bearer-token authentication, per-tool scopes, rate limiting, and health probes over Streamable HTTP.MIT

OpenToolofficial
AlicenseNot gradedqualityCmaintenanceEnables AI agents to execute provider tools through a self-hostable gateway with scoped keys, permissions, and accounting reservations.Apache 2.0- AlicenseNot gradedqualityBmaintenanceEnables secure exposure of internal tools to LLM clients with API-key authentication, tenant isolation, per-tool guardrails, PII scrubbing, rate limiting, audit logging, and telemetry over stdio and HTTP/SSE.MIT