Skip to main content

Why meta-tools

CodeSpar provides 15 meta-tools that abstract every connected MCP server into a unified commerce interface, reducing context window cost and simplifying agent development.

4 min read
View MarkdownEdit on GitHub

Tools & Meta-Tools

CodeSpar integrates MCP servers covering every major LatAm commerce API — payments, fiscal compliance, logistics, messaging, banking, ERP, and crypto. Instead of requiring your agent to understand each server's API individually, CodeSpar provides 15 meta-tools that intelligently route calls to the right provider.

This design is intentional. A typical commerce workflow in Brazil might touch Stripe (cards), Mercado Pago (Pix), SEFAZ (NF-e), Melhor Envio (shipping), and Z-API (WhatsApp). That is 5 providers, each with 10-20 tools, totaling 50-100 tool definitions in the LLM's context window. Meta-tools compress this to 15 stable interfaces regardless of how many providers are connected.

Why a few meta-tools, not 99 raw tools

Context window economics

Every tool definition consumes tokens in the LLM's context window. A typical MCP server exposes 10-15 tools, each with a JSON Schema input_schema averaging 200-400 tokens. Connect 5 servers and you consume 5,000-15,000 tokens just on tool definitions -- before the conversation even starts.

Meta-tools solve this by providing 15 fixed interfaces that never change regardless of how many servers are connected:

ApproachTools in contextTokens consumedAgent complexity
Raw server tools (5 servers)50-7510,000-30,000Agent must know each provider
Meta-tools15~3,000Agent uses unified interface

Routing abstraction

When your agent calls codespar_pay, CodeSpar inspects the arguments (payment method, currency, amount) and routes to the optimal provider:

  1. Inspects the arguments to determine payment method and region
  2. Selects the best available provider for that rail (e.g. Asaas for Pix in Brazil, Conekta for card in Mexico)
  3. Translates the request to the provider's native API format
  4. Normalizes the response into a consistent schema
  5. Returns the result to your agent

Your agent never needs to know which provider handles Pix vs. boleto vs. SPEI. It calls codespar_pay with the intent, and CodeSpar handles the routing.

The 15 meta-tools

Meta-toolPurposeTypical latency
codespar_get_startedRead-only setup planner: the ordered happy path for this workspace. Moves no money50-150ms
codespar_discoverSemantic + lexical search across the catalog for tools and servers50-150ms
codespar_manage_connectionsInspect connected providers and start connection flows50-200ms
codespar_payOutbound transfers — payouts via Pix, card, wire, or bank transfer. method: "boleto" settles an existing boleto rather than issuing one400-1200ms
codespar_chargeInbound charges — buyer pays merchant via Pix, boleto, card, PSE, or wallet across BR, MX, PE, CO, CL, AR, EC and USD400-1200ms
codespar_checkoutSell-side merchant checkout — assemble a cart and dispatch it as an inbound charge. Pix x BRL x BR is the only rail with catalog lines; boleto and card refuse with no_eligible_providers600-2000ms
codespar_shopBuy-side shopping — act as the shopper: search a store and buy, minting the store's real Pix (VTEX guest checkout, Mercado Livre)600-2000ms
codespar_invoiceIssue fiscal documents (NFS-e default, NF-e, CFDI, Factura AR)500-2000ms
codespar_shipDomestic shipping via Melhor Envio (domestic-quote, domestic-label, domestic-track)200-600ms
codespar_notifySend notifications via WhatsApp, SMS, or email100-300ms
codespar_crypto_payCrypto rails — Coinbase Commerce (hosted checkout), Bitso and Foxbit (BR), plus fiat on/offramp300-1000ms
codespar_kycKYC / identity verification via Persona, Sift, Konduto, or Truora300-1500ms
codespar_walletThe agent's governed wallet: balance and Pix key, ledger statement, top-up via minted Pix copia-e-cola100-400ms
codespar_ledgerDouble-entry ledger (Lerian Midaz) — entry, balance, account100-400ms
codespar_issueIssue + control payment cards via our card-issuing partner — virtual/physical/freeze/cancel300-1000ms

As quinze, uma a uma

Cada meta-tool tem página própria, com o formato dos argumentos, o formato do resultado, o roteamento entre trilhos e a configuração que o operador precisa fazer. Esta página não repete isso: repetir uma referência é criar duas que divergem, e a que tem menos detalhe ganha por estar mais perto.

meta-toolo que faz
codespar_chargeCobra, gerando o instrumento do trilho
codespar_checkoutFecha um carrinho de e-commerce
codespar_crypto_payPaga em stablecoin, com liquidação on-chain
codespar_discoverEncontra o servidor e a ferramenta para uma intenção
codespar_get_startedO caminho de primeira integração
codespar_invoiceEmite documento fiscal
codespar_issueEmite cartão
codespar_kycVerifica identidade e onboarda
codespar_ledgerLê e escreve o razão
codespar_manage_connectionsConecta e revoga credenciais de provedor
codespar_notifyEnvia mensagem por WhatsApp, SMS ou e-mail
codespar_payPaga, roteando entre Pix, cartão e cripto
codespar_shipContrata e rastreia entrega
codespar_shopBusca produto em lojas conectadas
codespar_walletLê saldo e movimenta a carteira

Server-specific tools

In addition to the 15 meta-tools, each connected MCP server exposes its own native tools. These are useful when you need provider-specific features that meta-tools do not cover, such as Stripe subscription management or Mercado Pago installment configuration.

const tools = await session.tools();

// Meta-tools are always available (15 tools)
// Server-specific tools depend on connected servers
// Examples:
//   "stripe_create_subscription"
//   "stripe_create_refund"
//   "mercadopago_create_preference"
//   "melhor_envio_calculate_deadline"

The tool schema field is input_schema (snake_case), following the MCP specification. Not inputSchema (camelCase).

Next steps

Why meta-tools | CodeSpar