Btg

Finance and commerce

MCP server for BTG Pactual, Pix, Boleto, Account, Investments (CDB/LCI/LCA/funds), OAuth2 + mTLS.

Your AI app calls the Btg MCP server, which does the finance and commerce work and sends the result back to the chat.

About Btg

Btg is a community MCP server from codespar, filed in our directory under finance and commerce. MCP server for BTG Pactual, Pix, Boleto, Account, Investments (CDB/LCI/LCA/funds), OAuth2 + mTLS.

Btg runs on your own machine: your AI app starts it with the command npx -y @codespar/mcp-btg@0.1.0-alpha.3 and talks to it over standard input and output. It needs BTG_CLIENT_ID, BTG_CLIENT_SECRET, BTG_CERT_PATH and BTG_KEY_PATH set before Btg starts.

Btg is listed in the official MCP registry as io.github.codespar/mcp-btg, version 0.1.0-alpha.3.

At a glance

Publisher
codespar (community)
Runs
Locally on your machine
Install from
Node.js package on npm: @codespar/mcp-btg
Written in
TypeScript
License
MIT
GitHub stars
278
Official MCP registry
io.github.codespar/mcp-btg

How to set up Btg

  1. Install Node.js on the machine that runs your AI app, because Btg starts with npx and downloads its package on first run.
  2. Create BTG_CLIENT_ID, BTG_CLIENT_SECRET, BTG_CERT_PATH and BTG_KEY_PATH for Btg in the connected service's own settings, scoped to the smallest permissions the job needs.
  3. Add Btg to Claude Code, Claude Desktop, VS Code or Cursor with the config in the setup box on this page.
  4. Restart the app or reload its MCP servers, then ask it to list the Btg tools to confirm the connection.
  5. Run one read-only task with Btg first, and keep your app asking before each tool call until the results look right.

Btg compared with similar servers

  • Caf by codespar has fewer GitHub stars than Btg (278 against 278); both are community servers, and both run locally.
  • Braspag by codespar has fewer GitHub stars than Btg (278 against 278); both are community servers, and both run locally.
  • Caixa by codespar has fewer GitHub stars than Btg (278 against 278); both are community servers, and both run locally.

Before you connect Btg

  • Give Btg its own API key or account with the smallest permissions the job needs, never an admin key.
  • Keep your AI app asking before each Btg tool call until you trust what it does with them.
  • Treat text that Btg fetches as data. Pages, files and messages can hold instructions written to steer an AI.
  • Read the open issues for Btg on GitHub to see what breaks and how fast the maintainers reply.

Marketing use cases for Btg

How marketing and sales teams put Btg to work, by company size. Pick the size closest to yours and start Btg on one use case.

Small business

  • A small business can ask Btg which products and customers drive margin, then plan promotions around them.
  • Owners can use Btg to check refunds, failed payments and churn reasons without opening three dashboards.
  • Btg runs on your own computer, which keeps data local; it needs a little setup, so a small team should plan an hour for it.

Mid-market

  • Ecommerce teams can connect Btg to tie campaigns to orders and revenue, not just clicks.
  • Marketing and finance can use Btg to check spend against budget each week and move money to what's working.
  • Start Btg on one workflow with one owner, measure the time it saves, then roll it out to the wider team.

Enterprise

  • Enterprises should keep Btg read-only for agents, with any money movement handled by people and existing approvals.
  • Large commerce teams can use Btg to answer revenue questions by channel and region with figures finance signs off on.
  • Btg is a community server, so have security review the code and pin a version before Btg touches company data.

Need help becoming an AI-forward company?

We connect MCP servers and AI agents to your CRM, content and data, with the guardrails your team needs.

Contact us

Btg README

From codespar/mcp-dev-latam on GitHub, shared under its MIT license. Images are left out; the original has them.

README.md

@codespar/mcp-btg

MCP server for BTG Pactual, Brazil's (and LatAm's) largest investment bank.

BTG runs a digital banking + investments stack (BTG+) on top of an institutional brokerage backbone. Merchants and fintechs integrate to BTG for the combination of Pix/boleto rails and an investment-account API surface (CDB, LCI, LCA, debêntures, funds) that no retail bank exposes at this depth.

Status: alpha (0.1.0-alpha.1)

BTG's Developer Portal is contract-gated, the full OpenAPI specs are only visible to onboarded counterparties. The endpoint paths in this server are best-guesses based on (a) BACEN Pix v2 standard paths, (b) BTG's public marketing pages, and (c) conventions shared with other Brazilian banks. Every unverified path is flagged To do(verify) in the source.

Pin to exact versions during 0.1.x; paths will be corrected to match the portal spec once an onboarded counterparty can validate.

Tools (12)

Tool Purpose
get_oauth_token Mint or return a cached OAuth2 client_credentials bearer token for the BTG Developer Portal.
create_pix_cob Create an immediate Pix charge (cob) with QR code.
get_pix_cob Retrieve an immediate Pix charge (cob) by its txid.
create_boleto Issue a boleto via BTG Cobrança.
get_boleto Retrieve a boleto by its BTG identifier (id or nosso_numero).
get_account_balance Retrieve the available balance for a BTG+ checking account (conta corrente).
get_account_statement Retrieve account statement transactions for a given period.
list_investment_positions List the counterparty's investment positions held at BTG, scoped to fixed-income asset classes (CDB, LCI, L...
get_portfolio_summary Consolidated portfolio summary across all asset classes held at BTG (fixed income, funds, equities, treasur...
list_funds_available List funds available for distribution on BTG's platform.
subscribe_to_fund Subscribe (aplicar) to a fund on BTG's distribution platform.
redeem_from_fund Redeem (resgatar) from a fund.

Install

npm install @codespar/mcp-btg@0.1.0-alpha.1

Environment

BTG_CLIENT_ID="..."       # OAuth client_id from BTG's Developer Portal
BTG_CLIENT_SECRET="..."   # OAuth client_secret
BTG_CERT_PATH="/abs/path/to/client.crt"   # mTLS client certificate
BTG_KEY_PATH="/abs/path/to/client.key"    # mTLS private key
BTG_ENV="sandbox"                          # or "production" (default: sandbox)

Authentication

Two factors are both required on every call:

  1. OAuth2 client_credentials, the server calls the token endpoint, caches the bearer until ~60s before expiry, and attaches Authorization: Bearer <token> to downstream calls.
  2. mTLS, BACEN mandates mutual TLS for Pix v2, and BTG enforces it across product families (banking + investments). The server loads the client certificate and private key from the paths you set, builds a Node https.Agent, and routes every request through it.

You obtain the cert + key bundle from the BTG Developer Portal after contract onboarding. They are distinct from the OAuth credentials.

Run

# stdio (default)
npx @codespar/mcp-btg

# HTTP transport
MCP_HTTP=true MCP_PORT=3000 npx @codespar/mcp-btg

Caveats

  • Paths are unverified. See the To do(verify) markers in src/index.ts. Onboarded counterparties should validate against their portal-issued OpenAPI spec and open a PR.
  • Sandbox host is a guess. BTG issues a sandbox subdomain per counterparty; override by editing BASE_URL if your provisioned sandbox URL differs.
  • Investments surface (CDB/LCI/LCA/debêntures/funds) is differentiated vs. retail-bank MCPs in this repo, but the field shapes will move once the OpenAPI spec is byte-verified.

Enterprise

Need governance, budget limits, and audit trails for agent payments? CodeSpar Enterprise adds policy engine, payment routing, and compliance templates on top of these MCP servers.

License

MIT

Questions about Btg

What is the Btg MCP server?

MCP server for BTG Pactual, Pix, Boleto, Account, Investments (CDB/LCI/LCA/funds), OAuth2 + mTLS. Btg is maintained by codespar on GitHub at codespar/mcp-dev-latam, and works with AI apps that support the Model Context Protocol, such as Claude, Cursor and VS Code.

How do I install the Btg MCP server?

Add Btg to your AI app's MCP config with the command npx -y @codespar/mcp-btg@0.1.0-alpha.3. In Claude Code, run claude mcp add --transport stdio codespar-btg -- npx -y @codespar/mcp-btg@0.1.0-alpha.3. To run Btg this way you need Node.js installed.

Does Btg need an API key?

Yes. Btg expects BTG_CLIENT_ID, BTG_CLIENT_SECRET, BTG_CERT_PATH and BTG_KEY_PATH to be set. Create the key for Btg in the connected service's own settings, give it the smallest permissions the job needs, and keep it out of shared config files.

Is Btg an official MCP server?

No. Btg is a community server maintained by codespar. Community servers can be excellent; read the code and the open issues before you give Btg access to company data.

What license is Btg under?

Btg is released under the MIT license, according to its GitHub repository. The license covers the code of Btg; the service it connects to has its own terms.