Labsco
AtilioA logo

Tesouro Direto MCP Server

โ˜… 5

from AtilioA

Provides natural language access to Brazilian treasury bond data from the Tesouro Direto API, allowing users to query market data and bond details.

๐Ÿ”ฅ๐Ÿ”ฅ๐Ÿ”ฅโœ“ VerifiedFreeAdvanced setup

Tesouro Direto MCP Server

smithery badge npm version License: AGPL v3

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.

Tools

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

VariableDescriptionDefault
USE_MCP_CACHEEnable the in-memory cache for API responsestrue

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 implementation

Available 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.