MCP ExplorerExplorer

Tesouro Direto Mcp

@AtilioAon a year ago
3ย AGPL-3.0
FreeCommunity
AI Systems
#mcp#mcp-server#tesouro-direto#treasury-bonds
๐Ÿ—ฃ๏ธ Query Brazilian treasury bond data with natural language

Overview

What is Tesouro Direto Mcp

tesouro-direto-mcp is an MCP server implementation that allows users to query Brazilian treasury bond data using natural language. It integrates with the Tesouro Direto API to provide accessible financial information.

Use cases

Use cases include retrieving current market status, getting details about specific bonds, and analyzing bond yields based on user-defined criteria.

How to use

To use tesouro-direto-mcp, install it via npm or build it from source. Configure your MCP client to connect to the server and use natural language prompts to query bond data.

Key features

Key features include querying market data, retrieving detailed bond information, and searching/filtering bonds by various criteria. It also features smart caching to enhance performance.

Where to use

tesouro-direto-mcp can be used in financial applications, investment platforms, and any software that requires access to Brazilian treasury bond data.

Content

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.

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 claude

Installing 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 build

You can run the MCP server directly after building:

node dist/index.js

Or use it with any MCP-compatible client (e.g., MCP Inspector):

npx @modelcontextprotocol/inspector dist/index.js

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

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

Tools

No tools

Comments

Recommend MCP Servers

View All MCP Servers