Python MCP Server Kit
Python MCP Server Kit
这是一个后端专用的入门套件,用于构建安全、类型化且可测试的 Model Context Protocol
服务器。它通过官方 Python SDK v2 面向 MCP 2026-07-28 协议,并使用无状态的 Streamable HTTP 进行部署。
Features
类型化工具,带结构化 Pydantic 输出
通用计算器和确定性目录示例
MCP 工具、资源和提示词
Bearer-token 边界与工具级作用域
请求大小、主机和进程内速率限制
关联 ID 和结构化请求日志
公开的健康与就绪探针
单元测试和 HTTP 集成测试
生产风格的非 root Docker 镜像
用于 lint、格式化、类型检查、测试、镜像构建、密钥和工作流的 CI
Related MCP server: MCP TypeScript SDK
Architecture
HTTP request
-> SecurityMiddleware (host, size, auth, rate limit, request ID)
-> MCP Streamable HTTP transport
-> typed tool/resource/prompt
-> scope check
-> deterministic domain function协议注册位于 src/mcp_server_kit/server.py;可复用的领域逻辑保留在独立模块中。TokenStore 有意设计为可替换的部署边界,而不是完整的授权服务器。
快速开始
需要 Python 3.11 或更高版本。
python -m venv .venv
.\.venv\Scripts\Activate.ps1
python -m pip install -e ".[dev]"
Copy-Item .env.example .env
.\scripts\dev.ps1MCP 端点为 http://127.0.0.1:8000/mcp。健康探针位于 /health 和 /ready。仅限本地的演示令牌如下:
demo-reader—catalog:readdemo-operator—catalog:read,calculator:use
使用 npx -y @modelcontextprotocol/inspector 运行 MCP Inspector,并设置 Authorization: Bearer demo-operator 请求头。在 examples/client.json 中提供了免凭据的客户端配置模板;可在本地注入 MCP_CLIENT_TOKEN。
命令
.\scripts\dev.ps1 # development server with reload
.\scripts\check.ps1 # lint, format check, mypy, and tests
docker compose up --build配置
变量 | 默认值 | 用途 |
|
| 在生产环境拒绝不安全的 demo 认证 |
|
| 绑定地址 |
|
|
|
| 空 |
|
| 本地主机 | 精确接受的 HTTP 主机名 |
|
| 最大声明请求体 |
|
| 每个主体/窗口允许的请求数 |
|
| 速率限制窗口 |
|
| Uvicorn 日志级别 |
切勿提交 .env。在进行面向互联网的部署之前,请参阅安全和部署;在扩展注册表时,请参阅添加工具。
部署说明
请设置 MCP_ENVIRONMENT=production、MCP_AUTH_MODE=bearer、由密钥管理的 MCP_BEARER_TOKENS 值,以及精确的公共主机白名单。在受信任的反向代理处终止 TLS。当需要用户委托或令牌生命周期管理时,请将入门套件中的令牌存储替换为你自己的 OAuth 2.1 资源服务器验证器。
许可证
MIT
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceA TypeScript implementation of a Model Context Protocol server that provides a frictionless framework for developers to build and deploy AI tools and prompts, focusing on developer experience with zero boilerplate and automatic tool registration.1,28414MIT
- AlicenseNot gradedqualityDmaintenanceA toolkit for building Model Context Protocol servers and clients that provide standardized context for LLMs, allowing applications to expose resources, tools, and prompts through stdio or Streamable HTTP transports.35,101,265MIT
- AlicenseNot gradedqualityDmaintenanceA reusable runtime infrastructure for hosting Model Context Protocol servers and tool registries over HTTP. It provides built-in validation, authentication, and logging to simplify the deployment of AI-powered workflows.MIT
- AlicenseNot gradedqualityDmaintenanceModel Context Protocol server that standardizes tool discovery, execution, and context management for AI applications.MIT
Related MCP Connectors
A Model Context Protocol server for Wix AI tools
A comprehensive Model Context Protocol (MCP) server that enables AI assistants to interact with yo…
MCP server for secureFlows: token-free URL builders and integration-linting tools for AI agents.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Boyeep/python-mcp-server-kit'
If you have feedback or need assistance with the MCP directory API, please join our Discord server