custodyops-mcp-python
custodyops-mcp-python
一个极简的 Python MCP 服务器,基于 Streamable HTTP,使用 FastAPI + fastmcp 构建,可直接部署到 Render 并启用 HTTPS。它暴露了一个 ping 工具以及两个演示工具(get_positions、list_upcoming_corporate_actions),你可以将其替换为托管数据的只读适配器。
为什么选择 Streamable HTTP? 它是 远程/托管 MCP 服务器 的推荐传输方式,将双向流简化为单个
POST /mcp端点,使云部署变得简单直接。请参考 MCP HTTP 快速入门和 SDK 文档了解标准模式。
功能特性
在
POST /mcp提供 Streamable HTTP 端点通过
AUTH_TOKEN实现 Bearer 认证/health端点用于正常运行时间检查极少的代码量,易于扩展更多 MCP 工具
通过
render.yaml一键部署到 Render
Related MCP server: MCP Ping-Pong Server
快速开始(本地)
python -m venv .venv && source .venv/bin/activate # Windows: .venv\Scriptsctivate
pip install -r requirements.txt
export AUTH_TOKEN=devtoken123
export PORT=3000
uvicorn app:app --host 0.0.0.0 --port $PORT使用 cURL 测试:
# tools/list
curl -s -X POST http://localhost:3000/mcp -H "Content-Type: application/json" -H "Authorization: Bearer devtoken123" -d '{"jsonrpc":"2.0","id":"1","method":"tools/list","params":{}}' | jq
# tools/call ping
curl -s -X POST http://localhost:3000/mcp -H "Content-Type: application/json" -H "Authorization: Bearer devtoken123" -d '{"jsonrpc":"2.0","id":"2","method":"tools/call","params":{"name":"ping","arguments":{}}}' | jq或运行辅助脚本:
chmod +x scripts/test_locally.sh
AUTH_TOKEN=devtoken123 PORT=3000 ./scripts/test_locally.sh部署到 Render(HTTPS)
Fork 或推送 此仓库到你的 GitHub。
在 Render 中:New → Web Service → Connect repo。
根据
render.yaml查看设置(Python 环境,免费方案)。Render 会自动配置 HTTPS。在 Render Environment 中设置
AUTH_TOKEN(如果使用 blueprint 则会自动生成)。部署 → 你的公共 MCP 端点为:
https://<your-app>.onrender.com/mcp。
测试远程:
APP_URL=https://<your-app>.onrender.com AUTH_TOKEN=<token> ./scripts/test_remote.sh从 Claude Desktop 使用(远程 MCP)
在 claude_desktop_config.json 中添加中继条目:
{
"mcpServers": {
"custodyops-mcp": {
"command": "npx",
"args": ["-y", "mcp-remote", "https://<your-app>.onrender.com/mcp"],
"env": { "AUTH_TOKEN": "<same-token>" }
}
}
}重启应用,然后让 Claude 列出可用工具。
扩展为真实托管数据
将演示工具替换为指向你的数据仓库或 API 的只读适配器。保持响应 小巧且类型化,并在可能时添加字段来源说明。
示例框架:
@mcp_tool
def get_positions(account_id: str) -> str:
rows = query_positions(account_id) # your adapter
return json.dumps(rows)安全说明
保持
AUTH_TOKEN机密,并定期轮换。企业使用时,建议迁移到 OAuth/JWT 并添加按账户授权。对于 HTTP 传输,普通日志记录即可,但应屏蔽敏感数据并添加请求 ID。
许可证
Related MCP Connectors
MCP server for Modern Treasury — payment orders, transactions, counterparties and ledgers.
Multi-tenant FastMCP server for Charles Schwab brokerage data, monetized via DPYC Tollbooth
MCP server for Codat — companies, connections, invoices, bills and financial statements.
Model Context Protocol server for the Apideck Unified API. Connect any MCP-compatible agent framework to 100+ accounting systems, HRIS platforms, file storage providers, and more through one integration. More information https://www.apideck.com/mcp-server
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceA minimal Model Context Protocol server built with FastAPI that provides a basic "Hello World" resource and tool. Serves as a starting point for building and validating MCP client integrations with richer resources and tools.-
- AlicenseNot gradedqualityDmaintenanceAn experimental MCP server demonstrating remote calls via FastAPI, supporting ping-pong commands through API endpoints and SSE transport.2MIT
- FlicenseNot gradedqualityDmaintenanceEnables building and running MCP servers over streamable HTTP, exposing tools to AI assistants like Cursor, with examples of mounting multiple servers in FastAPI.-
- FlicenseNot gradedqualityDmaintenanceA Python-based MCP server that exposes tools over streamable HTTP using FastAPI, enabling connection to AI assistants like Cursor. Supports multiple servers mounted in a single FastAPI app.-