1. AI and MCP
  2. Treeunfe MCP

MCP (Model Context Protocol) is an open standard that lets AI agents — such as Claude, Cursor, VS Code Copilot, Codex and Gemini — use external tools. With the Treeunfe MCP server, an agent can issue, look up and cancel invoices from a natural-language request.

Issue a sales NF-e in homologation for customer 12345678909,
with 1 unit of product 6654, and give me the access key.

​
Server URL

https://mcp.treeunfe.com.br/mcp

The server uses the HTTP (Streamable HTTP) transport. Clients that connect to remote servers don’t need anything installed locally.

​
Authentication

The MCP uses the same organization API Key as the REST routes (the rawKey). See API Keys to create one.

Send the key in one of these ways:

OptionHeader
Treeunfe header (recommended)x-api-key: <rawKey>
BearerAuthorization: Bearer <rawKey>

Use Bearer when your AI client can only send a token in that format (for example, Codex and the Claude API).

Don’t put the key in the URL. URLs end up in logs and history.

Without a key, the server returns 401 with the message x-api-key não fornecida.

​
Homologation or production

The environment follows the API Key, as in the REST API:

  • A HOMOLOGACAO key issues invoices with no fiscal value.
  • A PRODUCAO key issues real invoices.

Always start with a homologation key. Switch to production only after you have validated how the agent behaves.

​
Working safely with agents

An agent that can issue invoices can create real ones. Before going to production:

  • Grant only the scopes it needs. An agent that only looks things up needs nfe:read. Keep nfe:emit for agents that issue.
  • One key per agent. You can revoke one integration without affecting the others.
  • Require confirmation before issuing or cancelling. Set your AI client to ask for approval before calling tools that create or cancel invoices.
  • Keep the key out of code. Use environment variables or the client’s secret store.

​
Next steps