mcp-TesouroDireto
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-TesouroDireto
An MCP server for Brazilian government bonds (Tesouro Direto) — historical prices and yields, current rates, per-maturity statistics and the ANBIMA yield curve — built for LLM agents.
It is the Python/MCP counterpart of the R package
GetTDData: same asset codes, same
parsing rules, same fields. It talks directly to the official Tesouro
Transparente CKAN open data portal, so no R installation is required.
Why this server
Official data, no R dependency. Downloads
precotaxatesourodireto.csvfrom Tesouro Transparente and reproducesGetTDData::td_get2()semantics.Robust downloads. Retries, validates the CSV header before replacing the cache, and falls back to a previously valid cache when the portal is down.
Local cache. One download per day, stored in
~/.cache/mcp-tesouro-direto(configurable), with an in-memory parsed cache for fast repeated calls.Token-efficient output. CSV with a short comment header — not thousands of repetitive JSON records. Long series can be aggregated monthly/yearly.
The whole curve.
get_yield_curvescrapes ANBIMA's ETTJ and computes maturity dates with the Brazil/ANBIMA business-day calendar.Agent guidance. Server instructions, a static bond catalog resource and an
analyze_bondprompt.
Related MCP server: Copiloto Financeiro MCP Server
Tools
Tool | What it does |
| Bond catalog: code, official name, indexer, coupon, description and aliases. |
| Historical daily prices/yields, filterable by bond family, maturity, dates; optional monthly/yearly means. |
| Latest snapshot of every bond (one row per maturity). |
| Per-maturity summary: last/mean/min/max yield, dates, observation counts. |
| ANBIMA real, nominal and implicit-inflation yield curves. |
Resources: tesouro://catalog/bond-types. Prompt: analyze_bond.
Output conventions
yield_bidis a decimal annual rate:0.1183means 11.83% p.a.yield_bid_pctand the*_pctstatistics are already in percent.price_bidis the unit purchase price in BRL (R$).asset_codeis the bond family plus maturity asDDMMYY, e.g.LTN 010123,NTN-B Principal 150835.Data starts in 2005. Daily series are truncated to the most recent
max_rowsrows; usefrequency="monthly"or a narrower range for long histories.
Install
Requires Python 3.10+ and uv.
git clone https://github.com/msperlin/mcp-TesouroDireto.git
cd mcp-TesouroDireto
uv syncRun over stdio:
uv run mcp-tesouro-diretoOr install it as a standalone tool:
uv tool install .
mcp-tesouro-diretoRegister with OpenCode
Add to ~/.config/opencode/opencode.json (or a project opencode.json):
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"servers": {
"tesouro-direto": {
"type": "local",
"command": [
"/home/msperlin/GitRepo/mcp-servers/mcp-TesouroDireto/.venv/bin/python",
"-m",
"mcp_tesouro_direto"
]
}
}
}
}Or with uv, without hard-coding a virtualenv path:
"command": ["uv", "run", "--directory", "/path/to/mcp-TesouroDireto", "mcp-tesouro-direto"]Register with Claude Desktop
{
"mcpServers": {
"tesouro-direto": {
"command": "uvx",
"args": ["--from", "git+https://github.com/msperlin/mcp-TesouroDireto", "mcp-tesouro-direto"]
}
}
}Examples
Ask the agent:
What are the current NTN-B Principal yields and maturities?
How did the LTN 010127 yield evolve in 2024?
Compare the last 10 years of NTN-B Principal yields with the ANBIMA real return curve.
Summarize the inflation implied by today's Brazilian yield curve.
Typical tool calls:
list_bond_types(asset_codes=["NTN-B Principal"])
get_bond_data(asset_codes=["LTN"], first_year=2024, last_year=2024, asset_code="010127")
get_bond_data(asset_codes=["NTN-B Principal"], first_year=2015, frequency="monthly")
get_current_rates(asset_codes=["LFT", "LTN"])
get_bond_stats(asset_codes=["NTN-B Principal"], first_year=2015, max_assets=10)
get_yield_curve()A live call returns:
# Tesouro Direto — source: Tesouro Transparente (CKAN)
# Retrieved: 2026-11-01T12:00:00+00:00 | data file date: 2026-11-01 | latest ref date: 2026-10-30 | stale cache: no
# yield_bid is a decimal annual rate (0.1183 = 11.83% p.a.); ...
ref_date,yield_bid,yield_bid_pct,price_bid,asset_code,matur_date
2026-10-30,0.118300,11.8300,912.34,LTN 010127,2027-01-01Configuration
Variable | Default | Purpose |
|
| Where the raw CSV is cached. |
| Official CKAN resource URL | Override with a direct CSV URL or a local file path (useful offline/tests). |
|
|
|
|
| Bind address for HTTP transports. |
Development
uv sync
uv run pytest # offline unit + end-to-end MCP stdio tests
uv run python scripts/smoke_test.py # live test against Tesouro/ANBIMAThe test suite uses a small CSV fixture, so it does not need network access. The smoke test downloads the real dataset and the current ANBIMA curve.
The ANBIMA business-day calendar (src/mcp_tesouro_direto/anbima_holidays.txt)
was exported from the bizdays Brazil/ANBIMA calendar used by GetTDData, so
curve maturity dates match the R package.
Data sources and disclaimer
Bond data: Tesouro Transparente, the official open data portal of the Brazilian National Treasury.
Yield curve: ANBIMA.
This project is not affiliated with Tesouro Nacional, ANBIMA or the R package authors. Data is provided as-is; verify before making financial decisions.
License
MIT © Marcelo S. Perlin
Related MCP Connectors
Banco Central do Brasil (Brazil's central bank) MCP. Keyless public APIs: SGS time series + Olinda…
Banco Central do Brasil (BCB): SGS series, Focus expectations, PTAX, stats + provenance. 17 tools.
Real SEC, 13F, insider, congress & macro data your AI agent can cite. Hosted MCP, 24 tools.
AI-powered commodity price forecasts and Brazil trade intelligence via MCP. Access Brazilian exports and imports from MDIC/ComexStat since 2000, by HS4, HS6 and NCM code, partner country, USD FOB and kilograms — plus crop production, supply & demand, climate data and production forecasts for major commodities including soybeans, coffee, corn, beef and cocoa. Compare trade flows, markets, countries and time periods with like-for-like windows. Every answer identifies the measurement period and data source. 15 read-only tools. Metered in credits. Connect directly via Streamable HTTP — no installation required: https://mcp.kyrodata.com/mcp Authentication: Bearer key or OAuth 2.1 (PKCE). Official MCP registry: com.kyrodata/kyrodata
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables natural language access to Brazilian treasury bond data through the Tesouro Direto API. Query market data, bond details, and search bonds by type, maturity, and other criteria.29 npm4AGPL 3.0
- FlicenseNot gradedqualityBmaintenanceEnables AI agents to manage personal finances for Brazilian users through MCP tools, including categorizing transactions, reconciling debts, checking cash-flow projections, and adjusting budgets, with integration to Open Finance Brasil via Pluggy.2-
- AlicenseNot gradedqualityBmaintenanceEnables fetching Brazilian stock, crypto, and ETF quotes, as well as inflation and prime rate data via MCP tools.426 npmMIT
- AlicenseAqualityCmaintenanceProvides live financial data for any LLM agent, including stock quotes, crypto prices, SEC filings, XBRL financials, FX rates, and macro indicators, through ten MCP tools.11109 npm1MIT