brasilapi-mcp
brasilapi-mcp
一个自行编写的 Model Context Protocol (MCP) 服务器,它将公共 BrasilAPI 作为工具暴露给 LLM 客户端(Claude Desktop、Claude Code 或任何 MCP 主机)调用:可查询 CEP、CNPJ、银行、FIPE 车辆价格、全国节假日,以及 DDD 区号。
为什么会有这个项目
使用别人开发的 MCP 服务器很容易;我想证明我可以构建一个 — 包括工具 schema、类型化 HTTP 客户端,以及一个让整个项目可测试的边界。BrasilAPI 非常合适:它不需要 API 密钥,提供的是公共数据,因此任何人都可以克隆并立即运行;而且每个工具都会在测试中得到验证,全程不访问网络。
Related MCP server: MCP Brasil API
工具
工具 | 返回内容 |
| 巴西邮政编码对应的地址(接受 |
| CNPJ 的公司注册信息(法定名称、地址、经营活动、状态) |
| 在巴西中央银行注册的所有银行 |
| 按数字代码查询单个银行(例如 |
| 指定年份的全国节假日 |
| 某个两位电话区号所覆盖的州和城市 |
| 针对 |
| 某个车型代码的 FIPE 参考价格表 |
安装
pip install -e .依赖只有 mcp(官方 Python SDK,v2)和 httpx。
运行
brasilapi-mcp # runs the MCP server over stdio (what an MCP client launches)
brasilapi-mcp --help # prints usage and exits, without opening a socket服务器通过 stdio 使用 MCP 通信 — 你通常不需要手动运行它;MCP 客户端会启动它并与它通信。直接运行 python -m brasilapi_mcp.server 也可以。
接入客户端
Claude Desktop — 添加到 claude_desktop_config.json:
{
"mcpServers": {
"brasilapi": {
"command": "brasilapi-mcp"
}
}
}如果 brasilapi-mcp 不在你的 PATH 中,请把 command 指向你 venv 中的脚本(例如在 Windows 上为 .../.venv/Scripts/brasilapi-mcp),或者使用 "command": "python", "args": ["-m", "brasilapi_mcp.server"]。
Claude Code — 一条命令:
claude mcp add brasilapi -- brasilapi-mcp然后用自然语言提问:“CEP 01001-000 的地址是什么?” 或 “列出 2026 年的全国节假日”,模型就会调用对应的工具。
设计 — 为何测试在离线状态下进行
网络被放在一个可注入的边界之后。BrasilAPIClient 接受一个可选的 httpx.Client/传输层,因此测试套件会传入一个带有预设 JSON 的 httpx.MockTransport,并在完全没有真实网络 I/O 的情况下运行。工具主体是对普通同步函数的薄封装,这些函数显式接收客户端,因此逻辑可以独立进行单元测试;BrasilAPIError 会变成模型可读的简洁消息,而不是 traceback。
测试
pip install -e ".[dev]"
pytest -q测试套件覆盖了客户端(每个端点、输入规范化、404/500 处理)针对模拟传输层的测试、工具逻辑函数,以及服务器的工具注册。整个过程不会访问网络。
关于数据的一点说明
BrasilAPI 是一项公共服务,不需要密钥;本服务器不存储任何机密,也不读取任何环境变量。实时响应归 BrasilAPI 及其上游数据源所有。
许可证
MIT — 参见 LICENSE。
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Tools
Related MCP Servers
- FlicenseBqualityDmaintenanceQuery a variety of data from Brasil resources seamlessly. Access information on postal codes, area codes, banks, holidays, taxes, and more through a unified interface. Enhance your AI agents and applications with rich and updated data from BrasilAPI effortlessly.67
- AlicenseNot gradedqualityDmaintenanceEnables LLMs to query Brazilian public data such as CEP, CNPJ, DDD, exchange rates, banks, and holidays via the Model Context Protocol.12MIT
- AlicenseAqualityCmaintenanceExposes the BrasilAPI as MCP tools, enabling AI agents to query Brazilian public data such as CEP, CNPJ, DDD, IBGE, banks, PIX, FIPE, NCM, exchange rates, taxes, weather, CVM information, holidays, ISBN, domains, stock tickers, and TUSS.41Apache 2.0
- AlicenseNot gradedqualityCmaintenanceBrazilian company-registry lookup via Receita Federal, allowing AI agents to query CNPJ data.6MIT
Related MCP Connectors
Validate LatAm IDs: Mexican CLABE, Brazilian CNPJ/CPF checksums + BrasilAPI company/CEP/bank lookups
IBGE: geography, census, economy and health from the official APIs, with provenance. 21 tools.
Free Brazilian CNPJ lookup (legal name, status, partners) + lawsuit discovery. Public data, no login
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/monkaS013/brasilapi-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server