MCP Server Starter

MCP Server Starter

A production-minded Python starter for exposing typed tools over the Model Context Protocol with FastAPI.

Category
访问服务器

README

MCP Server Starter

An opinionated, production-minded Python starter for exposing typed tools over the Model Context Protocol.

It deliberately uses the stable MCP Python SDK v1 line. SDK v2 is prerelease as of July 2026 and is not yet recommended for production.

End-to-end MCP server demo

What is included

  • Streamable HTTP MCP endpoint at /mcp
  • Typed tool inputs and structured outputs
  • FastAPI health and readiness endpoints
  • Request IDs and JSON access logs
  • Environment-based configuration
  • Stateless mode for horizontal scaling
  • Unit, protocol, and HTTP tests
  • Non-root Docker image
  • Clear extension points for gateway authentication and telemetry

Quick start

Requirements: Python 3.11+ and uv.

uv sync --all-groups
uv run uvicorn mcp_server_starter.app:app --reload

The service exposes:

  • MCP: http://localhost:8000/mcp
  • Liveness: http://localhost:8000/health/live
  • Readiness: http://localhost:8000/health/ready

Try it with the MCP Inspector:

npx @modelcontextprotocol/inspector

Use http://localhost:8000/mcp as the Streamable HTTP server URL.

Or run the included demo client in a second terminal:

uv run python scripts/demo_client.py

It discovers the available tools and calls echo over the Streamable HTTP endpoint.

Included tools

  • echo: returns a validated message and request correlation ID
  • service_status: returns service name, version, and health state

They are intentionally boring. Replace them with domain tools while keeping the surrounding operational shell.

Configuration

All settings use the MCP_STARTER_ prefix.

Variable Default Purpose
MCP_STARTER_ENVIRONMENT development Deployment environment name
MCP_STARTER_LOG_LEVEL INFO Python log level
MCP_STARTER_ALLOWED_ORIGINS [] JSON array of browser origins allowed by CORS

Example:

export MCP_STARTER_ENVIRONMENT=production
export MCP_STARTER_ALLOWED_ORIGINS='["https://your-mcp-client.example"]'

Architecture

MCP client
    |
identity-aware API gateway   <- authenticate, authorize, rate-limit
    |
FastAPI operational shell    <- health, request IDs, access logs
    |
MCP Streamable HTTP          <- protocol and typed schemas
    |
domain tools                 <- business authorization + services
    |
logs, traces, metrics, audit events

This starter does not pretend that a hard-coded API key is enterprise authentication. Terminate OAuth/OIDC at an identity-aware gateway, pass only trusted identity context to the application, and still enforce resource-level authorization inside each tool.

Development

uv run pytest
uv run ruff check .
uv run ruff format --check .

Build and run the container:

docker build -t mcp-server-starter .
docker run --rm -p 8000:8000 mcp-server-starter

Production checklist

  • Put the service behind TLS and an identity-aware gateway.
  • Restrict CORS to explicit origins; an empty list is the safe default.
  • Add tool-level authorization—not only endpoint authentication.
  • Emit audit events for every side-effecting tool.
  • Add OpenTelemetry export for your chosen backend.
  • Set timeouts, retries, and circuit breakers around downstream calls.
  • Pin dependencies through uv.lock and scan the image in CI.
  • Treat tool descriptions and schemas as part of your public API.

Author

JP Oliveira · LinkedIn

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选