使用说明
MCP 服务器
模型上下文协议(MCP)服务器实现,用于与Tesouro Direto API集成,实现对巴西国债数据的自然语言访问。
特性
通过兼容MCP的客户端,使用日常语言查询市场数据、债券详细信息并搜索/过滤债券。
- MCP工具:
market_data:检索一般国债市场数据(开盘/收盘时间、状态)bond_data:获取特定债券的详细信息search_bonds:按类型、到期日和其他条件搜索/筛选债券
- 智能缓存:基于API的10分钟内存缓存更新时间戳,以减少调用,同时确保数据新鲜度。
示例用法
在MCP兼容的客户端中,您可以使用以下提示:
- “显示所有可用的Tesouro Direto债券”
- “获取债券IPCA+2029的详细信息”
- “搜索2045年后到期的IPCA债券”
- “目前的国债市场状况如何?”
- “提供IPCA和固定利率债券收益率最高的前三种债券的详细分析。”
安装
通过Smithery安装
通过以下方式自动安装Tesouro Direto MCP Server for Claude Desktop 史密瑟里:
npx -y @smithery/cli install @AtilioA/tesouro-direto-mcp --client claude
通过npm安装
MCP客户端配置的JSON示例(Cursor/Claude)
随着 新巴拿马型船舶,将此添加到您的 ~/.cursor/mcp.json,或 claude_desktop_config.json 如果您正在使用其桌面应用程序:
{
"mcpServers": {
"tesouro-direto": {
"command": "npx",
"args": [
"-y",
"tesouro-direto-mcp"
],
"env": {
"USE_MCP_CACHE": "true"
}
}
}
}
从源头构建
# Clone the repository
git clone https://github.com/AtilioA/tesouro-direto-mcp.git
cd tesouro-direto-mcp
# Install dependencies
pnpm install
# Build the project
pnpm run build
您可以在构建后直接运行MCP服务器:
node dist/index.js
或将其与任何兼容MCP的客户端(如MCP Inspector)一起使用:
npx @modelcontextprotocol/inspector dist/index.js
工具
market_data
检索一般市场数据,包括开盘/收盘时间和当前状态。
bond_data
通过代码获取特定债券的详细信息。
search_bonds
按类型(SELIC、IPCA、PREFIXADO)、到期日等搜索和过滤债券。
环境变量
| 变量 | 描述 | 默认值 |
|---|---|---|
USE_MCP_CACHE |
为API响应启用内存中缓存 | true |
在您的环境或MCP客户端配置中设置这些。
项目结构
src/
├── api/ # API client for Tesouro Direto
│ └── tesouroDireto.ts
├── cache/ # Caching implementation
│ └── apiCache.ts
├── resources/ # MCP resources implementation
│ └── index.ts
├── tools/ # MCP tools implementation
│ ├── bondData.ts
│ ├── marketData.ts
│ └── searchBonds.ts
├── types/ # Type definitions
│ └── index.ts
├── utils/ # Utility functions
│ ├── errorHandler.ts
│ └── logger.ts
├── client.ts # Example MCP client
├── index.ts # Entry point
└── server.ts # MCP server implementation
可用脚本
pnpm run build/npm run build:构建项目pnpm start/npm start:启动服务器pnpm run dev/npm run dev:以自动重新加载的开发模式启动服务器
贡献
欢迎投稿!请在上打开问题或提交拉取请求 GitHub.
许可证
此项目根据GNU Affero通用公共许可证v3.0获得许可。请参阅 许可证 文件以获取详细信息。
