How it works
MCP clients such as Claude or ChatGPT sign a user in through Omni’s OAuth flow. Embed users don’t sign in to Omni, so your backend vouches for them instead:- Your backend calls
createEmbedMcpTokenfrom the@omni-co/embedSDK with the user’s identity and role values, the same as for a signed embed URL. - The SDK signs a short-lived JWT with your embed secret and sends it to your Omni instance’s
/oauth/tokenendpoint. This uses OAuth’s JWT-bearer grant (RFC 7523). - Omni creates or updates the embed user, starts an embed session for them, and returns a standard OAuth access token.
- Your agent sends the token as
Authorization: Beareron every MCP request, the same as a token from the OAuth sign-in flow. Omni runs each query as that embed user.
401, your backend mints a new one.
Requirements
To follow the steps on this page, you’ll need:- Organization Admin permissions
- The MCP server setting enabled in AI Hub > MCP
- For Omni embed:
- The Embed feature enabled in your Omni instance
- Embed MCP tokens enabled for your organization. Reach out to Omni support to enable them.
- An embed secret. If you already sign embed URLs, reuse that secret.
-
@omni-co/embedversion 1.2.0 or later installed in your backend:
Setup
Mint a token for the user
On your server, mint a token with the user’s identity and roles. If you also embed Omni, you can use the same Call A successful call returns
externalId and name as your embed URLs, so both belong to the same Omni user, but read the warning below first.The token’s access comes only from its roles, so at least one of connectionRoles or modelRoles is required.- Use a standard role of Restricted Querier or Viewer, or a custom role that resolves to one of them, the same as for an embed URL. For a chat agent, use Restricted Querier or higher. A Viewer token can’t use
getDataoraskOmni. - Omni refuses a
groupsorentityvalue that names a group with a higher role.
- SDK (Recommended)
- Direct request
The Omni TypeScript SDK uses Node’s
crypto module, which is only available in Node environments. If your backend isn’t running Node, use the Direct request tab instead.createEmbedMcpToken from the TypeScript SDK. If you use a custom domain, use the Custom domain tab to view an example call.- Non-custom domain
- Custom domain
Mint a token with the SDK
accessToken and expiresAt.Call the MCP Server as the user
Send the token from the previous step as a Replace
Bearer token to your Omni instance’s MCP endpoint. Omni serves the same endpoint at /mcp and /mcp/https, so use either path.If you also embed Omni, request the token on the same host your embed URLs use.Omni identifies embed users by
externalId and host, so a token from blobsrus.embed-omniapp.co and an embed URL on analytics.blobsrus.com are two different users.<MODEL_ID> with a model the user can query. Use the pickModel tool to list them.The token can call the tools that are enabled in AI Hub > MCP and that the user’s roles allow.The MCP endpoints don’t support the
X-MCP-User-ID or X-MCP-User-Required headers. Omni returns a 403 if a token request sends X-MCP-User-ID or sets X-MCP-User-Required: true.Cache the token and implement 401 handling
Cache one token per Common causes of a
externalId until shortly before its expiresAt, in a store all your servers share. Each call to createEmbedMcpToken ends the user’s previous token, so servers that each mint their own token will keep logging each other out.When Omni answers 401 - which means the token stopped working - call createEmbedMcpToken again and retry once:Refresh on 401
401 include:- A newer token was issued for the user
- The token’s session was deleted or expired
- The feature was turned off for your organization
rate_limited and a retryAfterSeconds value. Reuse the cached token instead of requesting another token.Limiting what the agent can do
Omni gives each token only the tools that are enabled in AI Hub > MCP and that the user’s roles allow. For example, a Viewer token doesn’t getgetData. To narrow what your agent can do for a user, combine the following:
Data access
- Use the
connectionRoles,modelRoles, anduserAttributesparameters in your mint calls to control which connections, models, and rows the user can query. - Define access filters in your model to set up row-level filters using
userAttributes. An attribute doesn’t filter anything until a topic’s access filter uses it. Take attribute values such astenant_idfrom the user’s authenticated session on your server, never from a request the client controls.
Topics
- Use the
ai_chat_topicsmodel parameter to limit which topics the AI can pick. - You can also use the
X-MCP-Model-IDandX-MCP-Topic-Nameheaders to pin a session to one model or topic.
MCP tools
Your agent is the MCP client, so it decides which tools the LLM sees. After calling
tools/list, pass only the tools you want, such as pickModel, pickTopic, and getData, to your LLM. Hosted agent APIs that take an MCP endpoint URL usually accept an allowed-tools list that does the same thing.Managing tokens
Tokens show up as embed sessions in Settings > Embed > Sessions. See Managing user sessions for more information. Rotating or deleting an embed secret doesn’t end tokens already issued. A token lives as long as its session, so to immediately end a token, delete the user’s session. Every active secret can sign new assertions, so you can add a new secret before you delete the old one. See Managing embed secrets for more information.Troubleshooting
MCP requests return 401 right after minting a token
MCP requests return 401 right after minting a token
Another server minted a newer token for the same
externalId, which ended this one. Share the token cache across your servers.MCP requests return 403
MCP requests return 403
Check that the request doesn’t include
X-MCP-User-ID or X-MCP-User-Required, and that the MCP server setting is enabled in AI Hub > MCP.createEmbedMcpToken can throw, see Error codes in the MCP token reference.
Next steps
- Look up parameters and error codes in the MCP token reference
- Review the MCP Server tools your agent can call and enable the ones you need in AI Hub > MCP
- Optimize your models for AI so the agent gets better answers
- Set AI credit limits for embed entities to manage usage per customer

