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

# MCP

> Connect Claude, ChatGPT, Cursor or any MCP client to Croma's government data sources: the server URL, authentication and every tool exposed over MCP.

Croma exposes every data source as a tool over the [Model Context
Protocol](https://modelcontextprotocol.io) (MCP), served over Streamable HTTP
at:

```
https://api.croma.run/mcp
```

Any MCP client can connect. Interactive clients (Claude, ChatGPT, Cursor) use
the OAuth flow: [add Croma to Claude in one click](https://claude.ai/new?modal=add-custom-connector\&connectorName=Croma%20%7C%20The%20API%20for%20government%20data\&connectorUrl=https%3A%2F%2Fapi.croma.run%2Fmcp#settings/customize-connectors)
and sign in with your Croma account. For your own code you authenticate with
the **same API key as the REST API**: send it as a bearer token and the tools
run scoped to your organization, sharing the same [rate limits](/rate-limits)
and usage.

## Use it from the AI SDK

The [AI SDK](https://ai-sdk.dev) can load the Croma tools directly and hand them
to a model for tool calling. Pass your key in the `Authorization` header of the
transport:

```ts theme={"dark"}
import { experimental_createMCPClient as createMCPClient, generateText } from "ai";
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
import { anthropic } from "@ai-sdk/anthropic";

const mcp = await createMCPClient({
  transport: new StreamableHTTPClientTransport(
    new URL("https://api.croma.run/mcp"),
    {
      requestInit: {
        headers: { Authorization: `Bearer ${process.env.CROMA_API_KEY}` },
      },
    },
  ),
});

// Every data source, exposed as a tool the model can call.
const tools = await mcp.tools();

const { text } = await generateText({
  model: anthropic("claude-opus-4-8"),
  tools,
  // Let the model call tools and then answer. Consult the AI SDK docs for the
  // multi-step setting in your version (`stopWhen` / `maxSteps`).
  prompt: "Consulta los antecedentes de la Policía Nacional para la cédula 1234567890.",
});

await mcp.close();
console.log(text);
```

<Warning>
  Treat the key as a secret: load it from an environment variable or secrets
  manager, never commit it, and close the client (`mcp.close()`) when you are
  done so the connection is released.
</Warning>

## Start from the chat template

[Croma Chat Template](https://github.com/croma-ai/croma-chat-template) is an
open-source Next.js chat built on this endpoint with the AI SDK and
[AI Elements](https://ai-sdk.dev/elements): streaming responses, tool calls
across every Croma source, a per-message source picker, and optional rate
limiting. Try the live deployment at
[chat.usecroma.com](https://chat.usecroma.com), or use the repository's
one-click Vercel deploy: it asks for your `CROMA_API_KEY` and a model key and
comes up ready to use.

## Tool names

Tools are named after their source, with underscores instead of hyphens, for
example `policia_criminal_records`, `rues_entity_by_nit`, and
`rama_judicial_cases_by_radicado`. Call `mcp.tools()` to list the full set with
their input schemas, or browse the [API reference](/api-reference) for the
fields each one accepts.

[Async lookups](/async-jobs) always wait inline over MCP: the tool call returns
the finished result, with no `202`, polling, or callbacks.

## Any MCP client

The AI SDK is one option. Because the endpoint speaks standard MCP over
Streamable HTTP, the official
[MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk),
LangChain, and other MCP-aware frameworks connect the same way: point them at
`https://api.croma.run/mcp` and set the `Authorization: Bearer` header.
