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

# MCP API key authentication

> Connect MCP clients to Omni with an API key, run tools as another user, and restrict an agent to a model or topic.

API key authentication gives you direct control over key creation and management. This approach is useful when:

* You need to manage API keys centrally for your organization
* You're setting up automated workflows or CI/CD pipelines
* You want to use a service account rather than individual user credentials
* Your MCP client doesn't support OAuth

## How it works

1. Create an [API key in Omni](https://docs.omni.co/api/authentication.md)
2. Configure the key in your MCP client's settings
3. The client includes the key in all requests to Omni

## Connection URL

When using API key authentication, connect directly to your Omni instance:

```text theme={null}
https://<YOUR_OMNI_INSTANCE>/mcp/https
```

Replace `<YOUR_OMNI_INSTANCE>` with your Omni URL (e.g., `acme.omniapp.co`).

## Running tools as another user

With an Organization API key, you can run tools as another user. Send that user's ID in the `X-MCP-User-ID` header. Results include only what that user can access.

Tools that can run as another user have the  icon next to their name on the [tool pages](https://docs.omni.co/ai/mcp/tools).

The header works with Organization API keys only. A request that uses a PAT or OAuth and includes the header fails with a `403` error.

## Restricting an agent to a model or topic

If you connect your own agent or app, you can send these headers to restrict new queries to a single model or topic:

* `X-MCP-Model-ID` - [`getData`](https://docs.omni.co/ai/mcp/tools/querying#get-data), [`askOmni`](https://docs.omni.co/ai/mcp/tools/omni-agent#ask-omni), and [`pickTopic`](https://docs.omni.co/ai/mcp/tools/querying#pick-topic) use this model. [`runQuery`](https://docs.omni.co/ai/mcp/tools/querying#run-query) refuses a query on a different model.
* `X-MCP-Topic-Name` - `getData` and `askOmni` use this topic. `runQuery` refuses a query on a different topic.

This is useful for:

* An [embedded agent](https://docs.omni.co/embed/customization/ai-chat/your-agent-access.md), where your backend restricts each user to the model or topic your product shows
* A shared or automated agent that should stay on one model
* Better answers. With fewer fields to search, the AI picks the right ones more often.

These headers don't restrict saved queries. A user can still run the saved queries in any document they can open.

## Troubleshooting

> [accordion] Authentication fails
>
> * Verify the API key is correct and hasn't been revoked
> * Check that the key has appropriate permissions
> * Ensure you're using the correct instance URL

## Next steps

Follow the setup guide for your MCP client:

> [card] [ChatGPT](https://docs.omni.co/ai/mcp/chatgpt.md)
>
> OpenAI's AI assistant with developer mode

> [card] [Claude Code](https://docs.omni.co/ai/mcp/claude-code.md)
>
> Command-line based version of Anthropic Claude

> [card] [Claude Desktop](https://docs.omni.co/ai/mcp/claude-desktop.md)
>
> App version of Anthropic Claude

> [card] [Codex](https://docs.omni.co/ai/mcp/codex.md)
>
> OpenAI's agentic coding tool

> [card] [Cursor](https://docs.omni.co/ai/mcp/cursor.md)
>
> AI-powered IDE designed for fast, agentic programming

> [card] [Microsoft Copilot](https://docs.omni.co/ai/mcp/microsoft-copilot.md)
>
> Microsoft's AI assistant, configured through Copilot Studio

> [card] [Visual Studio Code](https://docs.omni.co/ai/mcp/vscode.md)
>
> Popular open-source IDE with powerful AI features

## Related

* [MCP authentication](https://docs.omni.co/ai/mcp/authentication) - Compare the ways to authenticate MCP clients
* [MCP OAuth authentication](https://docs.omni.co/ai/mcp/authentication/oauth.md) - Authenticate through your browser
* [MCP Enterprise Managed Auth](https://docs.omni.co/ai/mcp/authentication/enterprise-managed-auth.md) - Let users sign in through your Okta organization
