> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cufea.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MCP server

> Let AI agents issue sandbox invoices through Cufea with the remote MCP server.

An [MCP](https://modelcontextprotocol.io) server lets AI agents (Claude Code, Cursor, Codex,
OpenCode...) issue Colombian DIAN electronic invoices through Cufea. It is a thin client of the
public API, with the same API keys, stages and tenant isolation as any other client.

It drives the **sandbox** only: Cufea's simulated DIAN, with no legal effect.

## Remote server

`https://mcp.cufea.com/co` serves the tools over MCP Streamable HTTP. Nothing to install: each
request is authenticated by its own `Authorization: Bearer <key>` header and must carry a
`cufea_sandbox_` key from the [developer console](https://app.cufea.com/signup); there is no
OAuth flow. Replace `cufea_sandbox_...` with your key (or export it as `CUFEA_API_KEY` where
the snippet reads it).

> [tab] Claude Code
>
> ```sh theme={null}
> claude mcp add --transport http cufea https://mcp.cufea.com/co \
>   --header "Authorization: Bearer cufea_sandbox_..."
> ```

> [tab] Codex
>
> In `~/.codex/config.toml`, with the key exported as `CUFEA_API_KEY`:
>
> ```toml theme={null}
> [mcp_servers.cufea]
> url = "https://mcp.cufea.com/co"
> bearer_token_env_var = "CUFEA_API_KEY"
> ```

> [tab] OpenCode
>
> In `opencode.json`:
>
> ```json theme={null}
> {
>   "mcp": {
>     "cufea": {
>       "type": "remote",
>       "url": "https://mcp.cufea.com/co",
>       "headers": { "Authorization": "Bearer {env:CUFEA_API_KEY}" }
>     }
>   }
> }
> ```

> [tab] Cursor
>
> In `.cursor/mcp.json` or `~/.cursor/mcp.json`:
>
> ```json theme={null}
> {
>   "mcpServers": {
>     "cufea": {
>       "url": "https://mcp.cufea.com/co",
>       "headers": { "Authorization": "Bearer cufea_sandbox_..." }
>     }
>   }
> }
> ```

The remote server answers `401` (with `WWW-Authenticate: Bearer`) when the header is missing
and `403` with `sandbox_only` for a key that is not a `cufea_sandbox_` key; it has no
production switch. It keeps no session: every request builds a fresh server for its key.

## Tools

| Tool | Does | Hints |
| - | - | - |
| `cufea_health` | `GET /v1/health` | read-only |
| `cufea_get_tenant` | the key's tenant and stage | read-only |
| `cufea_get_configuration` | what the tenant lacks before invoicing | read-only |
| `cufea_create_invoice` | create (and with `send: true` queue) a sales invoice | write |
| `cufea_send_invoice` | queue a stored invoice for the DIAN | write, idempotent with a key |
| `cufea_get_invoice` | one invoice: state, DIAN status, CUFE | read-only |
| `cufea_wait_for_invoice` | poll until `accepted` or `rejected` | read-only |
| `cufea_find_document` | find an invoice or note by your `reference` | read-only |
| `cufea_download_xml` | signed XML, AttachedDocument, or a note's XML | read-only |
| `cufea_list_events`, `cufea_get_event` | the RADIAN event chain of an invoice | read-only |
| `cufea_create_event` | register a RADIAN event (030-034) on an accepted invoice | write |
| `cufea_resend_event` | queue a saved event that was not queued | write, idempotent |
| `cufea_refresh_events` | re-read from the DIAN which events are registered | write, idempotent |
| `cufea_refresh_invoice` | re-read an invoice's status from the DIAN | write, idempotent |
| `cufea_create_note`, `cufea_send_note`, `cufea_get_note` | credit (91) and debit (92) notes | write / read-only |
| `cufea_list_webhook_endpoints` | the tenant's webhook endpoints | read-only |
| `cufea_create_webhook_endpoint` | register one; its `secret` is shown once | write, deduplicated with a key |
| `cufea_delete_webhook_endpoint` | delete one | destructive |

Each tool has an input schema whose descriptions explain the DIAN fields (NIT and check digit,
DANE city and department codes, tax schemes, payment forms...), and returns structured
content. Creates drop the answer's `xml_base64`; `cufea_download_xml` serves the XML.

`cufea_create_invoice`, `cufea_send_invoice`, `cufea_create_note`, `cufea_send_note`,
`cufea_create_event` and `cufea_create_webhook_endpoint` take an optional `idempotency_key`:
the same key and body replays the first answer instead of acting twice. Give creates a
`reference` too, so `cufea_find_document` can tell whether a document whose answer was lost
exists.

## Errors

A failed call is an MCP tool error (`isError: true`) whose text is JSON:

```json theme={null}
{ "error": { "status": 422, "code": "validation_error", "title": "...", "detail": "...", "request_id": "...", "errors": [] } }
```

`code` is the API's stable problem code (see [Errors](https://docs.cufea.com/en/errors.md)), or one of the server's
own: `sandbox_only`, `connection_error`, `timeout`, `wait_timeout`, `invalid_arguments`,
`internal_error`. Stack traces and the API key never appear.

## Documentation MCP

This documentation site also serves a search MCP server at `https://docs.cufea.com/mcp`, so an
agent can search these pages. Use it next to the Cufea MCP server: one reads the docs, the
other calls the API.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.