tesouro-direto-mcp
๐ฃ๏ธ Query Brazilian treasury bond data with natural language
Documentation
Tesouro Direto MCP Server
A Model Context Protocol (MCP) server implementation for integrating with the Tesouro Direto API, enabling natural language access to Brazilian treasury bond data.
Features
Query market data, bond details, and search/filter bonds using everyday language through MCP-compatible clients.
- MCP tools:
- `market_data`: Retrieve general treasury bond market data (opening/closing times, status)
- `bond_data`: Get detailed information about a specific bond
- `search_bonds`: Search/filter bonds by type, maturity, and other criteria
- Smart caching: 10-minute in-memory cache based on API update timestamps to reduce calls while ensuring data freshness.
Example usage
In a MCP-compatible client, you can use the following prompts:
- *"Show all available Tesouro Direto bonds"*
- *"Get details for the bond IPCA+ 2029"*
- *"Search for IPCA bonds maturing after 2045"*
- *"What is the current treasury bond market status?"*
- *"Provide a detailed analysis of the top three bonds with the highest yields for both IPCA and fixed-rate bonds."*
Installation
Installing via Smithery
To install Tesouro Direto MCP Server for Claude Desktop automatically via Smithery:
npx -y @smithery/cli install @AtilioA/tesouro-direto-mcp --client claudeInstalling via npm
Example JSON for MCP client configuration (Cursor/Claude)
With npx, add this to your `~/.cursor/mcp.json`, or `claude_desktop_config.json` if you are using its desktop app:
{
"mcpServers": {
"tesouro-direto": {
"command": "npx",
"args": [
"-y",
"tesouro-direto-mcp"
],
"env": {
"USE_MCP_CACHE": "true"
}
}
}
}Building from source
# 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 buildYou can run the MCP server directly after building:
node dist/index.jsOr use it with any MCP-compatible client (e.g., MCP Inspector):
npx @modelcontextprotocol/inspector dist/index.jsTools
`market_data`
Retrieve general market data, including opening/closing times and current status.
`bond_data`
Get detailed information for a specific bond by its code.
`search_bonds`
Search and filter bonds by type (SELIC, IPCA, PREFIXADO), maturity date, and more.
Environment variables
| Variable | Description | Default |
|---|---|---|
| `USE_MCP_CACHE` | Enable the in-memory cache for API responses | `true` |
Set these in your environment or in your MCP client configuration.
Project structure
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 implementationAvailable scripts
- `pnpm run build` / `npm run build`: Build the project
- `pnpm start` / `npm start`: Start the server
- `pnpm run dev` / `npm run dev`: Start the server in development mode with auto-reload
Contributing
Contributions are welcome! Please open an issue or submit a pull request on GitHub.
License
This project is licensed under the GNU Affero General Public License v3.0. See the LICENSE file for details.
Frequently asked questions
What is tesouro-direto-mcp?
tesouro-direto-mcp is ๐ฃ๏ธ Query Brazilian treasury bond data with natural language
How do I install tesouro-direto-mcp?
Open the GitHub repository and follow its README. Most MCP servers are added to your client's MCP config, then called by your agent.
Is tesouro-direto-mcp open source?
Yes โ it is hosted on GitHub at https://github.com/AtilioA/tesouro-direto-mcp and has 5 stars.
Related MCP tools
The Open-Source Multimodal AI Agent Stack: Connecting Cutting-Edge AI Models and Agent Infra
A MCP for Claude Desktop / Claude Code / Windsurf / Cursor to build n8n workflows for you
Browser MCP is a Model Context Provider (MCP) server that allows AI applications to control your browser
A Model Context Protocol (MCP) server and CLI that provides tools for agent use when working on iOS and macOS projects.
The go-to web for your AI coding agent โ local-first search, fetch, crawl & research over MCP. No API keys, no cloud, $0/query. Public beta.
MCP Aggregator, Orchestrator, Middleware, Gateway in one docker
Run your own MCP server? See who uses it and what to fix.
Measure it with TrackMCP