mcp-server-python-mt9e4j8z
MCP Server Template (Python)
一个用于 Render 的极简 Model Context Protocol 服务器模板。Fork 它,添加你自己的工具,然后部署。
包含内容
一个使用 MCP Python SDK 且支持 Streamable HTTP 传输的可用 MCP 服务器
通过
MCP_API_TOKEN进行 Bearer token 认证(部署时自动生成)一个示例工具(
hello)用于展示模式一个用于 Render 健康检查的
/health端点一个用于一键部署的
render.yamlBlueprint一个
AGENTS.md文件,让 AI 编码助手可以为你搭建新工具
注意: 此模板默认在免费计划上部署。免费服务在闲置 15 分钟后会关闭,导致下一次请求时出现 30-60 秒的冷启动。MCP 客户端可能会在此延迟期间超时。为了可靠使用,请在 Render Dashboard 中升级到付费方案——Starter 计划可让你的服务持续运行。
Related MCP server: mcp-server-python
本地入门
git clone https://github.com/render-examples/mcp-server-python.git
cd mcp-server-python
pip install -r requirements.txt
python server.py服务器启动于 http://localhost:10000。MCP 端点为 /mcp。
运行测试
pip install -r requirements.txt
pytest认证
服务器使用 bearer token 对请求进行认证。Render 的 Blueprint 在首次部署时会自动生成一个随机的 MCP_API_TOKEN。
部署后查找你的 token:前往 Render Dashboard > 你的服务 > Environment,复制 MCP_API_TOKEN 的值。
客户端必须在 Authorization 头中包含该 token:
Authorization: Bearer YOUR_TOKEN当未设置 MCP_API_TOKEN 时(例如在本地开发期间),认证被禁用,所有请求都会被放行。
管理你的 token
首次部署后,token 由你自行管理:
轮换它:在 Render Dashboard 的 Environment 下更新
MCP_API_TOKEN。服务会自动使用新值重启。生成新 token,可使用以下任一方式:
openssl rand -base64 32python3 -c "import secrets; print(secrets.token_urlsafe(32))"密码管理器的生成器(1Password、Bitwarden 等)
不要将 token 提交到源代码控制中。请使用环境变量或
.env文件(这些已在.gitignore中)。对于多用户或生产环境,请考虑升级到 OAuth 2.1。
连接到你的 MCP 服务器
部署到 Render 后,你的 MCP 端点位于:
https://your-service-name.onrender.com/mcpCursor
添加到你的项目的 .cursor/mcp.json:
{
"mcpServers": {
"my-mcp-server": {
"url": "https://your-service-name.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}Claude Desktop
添加到你的 Claude Desktop 配置:
{
"mcpServers": {
"my-mcp-server": {
"type": "streamable-http",
"url": "https://your-service-name.onrender.com/mcp",
"headers": {
"Authorization": "Bearer YOUR_TOKEN"
}
}
}
}Codex
codex mcp add --transport streamable-http \
--url https://your-service-name.onrender.com/mcp \
--header "Authorization: Bearer YOUR_TOKEN" \
my-mcp-server或者添加到 .codex/config.toml:
[mcp_servers.my-mcp-server]
url = "https://your-service-name.onrender.com/mcp"
http_headers = { Authorization = "Bearer YOUR_TOKEN" }添加工具
在 server.py 中,通过用 @mcp.tool() 装饰函数来添加工具:
@mcp.tool()
def fetch_weather(city: str, units: str = "celsius") -> str:
"""Get the current weather for a city."""
# your implementation here
return f"Weather for {city}"docstring 会成为工具的描述,MCP 客户端会将其展示给 LLM。请始终编写清晰的描述。
此仓库包含一个
AGENTS.md文件。如果你使用 AI 编码助手(Cursor、Copilot、Codex、Windsurf 等),你可以要求它"添加一个新工具",它会自动遵循AGENTS.md中的约定。
项目结构
server.py MCP server with example tool and health check
requirements.txt Python dependencies
render.yaml Render Blueprint for deployment
.env.example Environment variable reference
tests/test_server.py Test suite (auth, health, tool calls)
pyproject.toml pytest configuration
AGENTS.md Instructions for AI coding assistants
CLAUDE.md Pointer to AGENTS.md for Claude Code了解更多
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
- FlicenseNot gradedqualityCmaintenanceA minimal template for deploying Model Context Protocol servers on Render with Streamable HTTP transport, bearer token authentication, and an example hello tool.
- FlicenseNot gradedqualityCmaintenanceA minimal MCP server template for Python with Streamable HTTP transport, bearer token authentication, and a hello tool, designed for deployment on Render.
- FlicenseNot gradedqualityCmaintenanceA minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool. Enables developers to quickly scaffold and deploy their own MCP servers.
- FlicenseNot gradedqualityCmaintenanceA minimal MCP server template for Render with Streamable HTTP transport, bearer token authentication, and an example 'hello' tool.
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…
Remote ChromaDB vector database MCP server with streamable HTTP transport
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/Suryakanta26/mcp-server-python-mt9e4j8z'
If you have feedback or need assistance with the MCP directory API, please join our Discord server