Skip to main content

authentik Agent MCP server

authentik: 2026.8.0+Enterprise

The authentik Agent includes a Model Context Protocol (MCP) server, ak mcp. With it, AI clients such as Claude Code, Codex, or Cursor can send requests to applications that are protected by authentik, and to the authentik API, without receiving your credentials or tokens.

The AI client works through an agent account that it creates for you. Requests to applications carry a token for you, with the agent account recorded as the actor, so that events show both.

Agent accounts and the authentik Agent

Agent accounts are a type of user account in authentik. The authentik Agent is the software that runs on your device. The MCP server is part of the authentik Agent and creates agent accounts.

How it works​

  1. The AI client creates an agent account. You're its owner. The agent account expires after the default token duration of your authentik deployment, 1 day by default, and starts without access to any application.
  2. The AI client requests access to one or more applications for the agent account, and shows you a link to the request.
  3. You approve or deny the request in authentik.
  4. The MCP server exchanges your authentik token for a token for the application, with the agent account as the actor.
  5. The AI client asks the MCP server to send HTTP requests to the application. The MCP server adds the token to the requests, so the AI client never sees it.

Prerequisites​

Prepare an application​

The AI client can reach an application through the MCP server if the following applies:

  • The application uses an OAuth2/OpenID Connect provider with the authentik-cli provider in Federated OAuth2/OpenID Providers, under Machine-to-Machine authentication settings. This is the same configuration as for Kubernetes.
  • The application has a Launch URL, or its provider has a redirect URI. Without a launch URL, the MCP server uses the first redirect URI.
  • You can access the application.

The MCP server only sends requests to URLs with the same scheme and the same registrable domain as the launch URL, on any port. For example, a launch URL of https://wiki.internal.example.com allows requests to https://example.com, https://wiki.internal.example.com, and https://api.example.com:8443, but not to http://wiki.internal.example.com. For localhost and IP addresses, the host must match exactly.

Add the MCP server to an AI client​

The MCP Server page of the authentik Agent app shows the same instructions, with buttons that install the server in Cursor and VS Code.

claude mcp add authentik -- ak mcp

Check the connection with /mcp in Claude Code.

The MCP server uses the active profile. To use a different profile, add -p <profile>, for example ak -p work mcp.

Approve access requests​

When the AI client requests access to an application, it shows you a link to the request. AI clients that support MCP Apps show a card with a Review in authentik button instead.

  1. Open the link. The request opens in the authentik user interface.
  2. Approve or deny the request.

Only you, as the owner of the agent account, can approve its requests, and the agent account can only request applications that you can access. A request expires if you don't approve it within 1 hour. Approved access lasts 1 hour, and never longer than the agent account. For more information, refer to Requests from agent accounts.

Tools​

ToolDescriptionAuthenticates as
list_applicationsLists the applications that you can access, with their pbm_uuid and launch URL.You
create_agentCreates an agent account that you own.You
request_accessRequests access to applications for an agent account.The agent account
grant_statusChecks whether an access request was approved or denied, and can wait for about 50 seconds.You
token_exchangeGets a token for an application.You, with the agent account as actor
http_fetchSends a GET or HEAD request to an application.You, with the agent account as actor
http_sendSends a POST, PUT, PATCH, or DELETE request to an application.You, with the agent account as actor
api_searchSearches the authentik API commands of ak api.No request is sent
api_describeShows the arguments of an authentik API command.No request is sent
api_callRuns an authentik API command.The agent account
api_call_dangerousRuns an authentik API command. Only available if ak mcp runs with --allow-dangerous-api.You

token_exchange takes the pbm_uuid of the application, which list_applications returns.

http_fetch and http_send only work after a token_exchange for the application, and only for URLs that the application's launch URL allows. They don't follow redirects, they set the Authorization, Cookie, Host, and Proxy-Authorization headers themselves, they time out after 30 seconds, and they return at most 256 KiB of a response body. Applications see your user as the subject of the token. Applications that read the act claim of the token also see the agent account.

Agent accounts that create_agent creates have no permissions in authentik, so api_call can only run commands that you grant the agent account access to.

The MCP server also provides two skills, authentik-app-access and authentik-api, that describe how to use these tools. AI clients that support MCP skills load them automatically.

Security considerations​

  • The AI client doesn't receive your authentik token or the tokens for applications. The MCP server adds them to requests.
  • Each token exchange goes through the authentik Agent's authorization prompt for token_exchange. To limit the applications that the MCP server can get tokens for, set authorization.allowed_exchange_audiences to the UUIDs of these applications.
  • http_fetch and http_send send an application's token to every host in the registrable domain of its launch URL. If other services in that domain shouldn't receive the token, give the application its own domain.
  • http_fetch and http_send have an insecure option, off by default, that skips TLS certificate verification.
  • --allow-dangerous-api adds the api_call_dangerous tool, which can do anything that your authentik account can do. Only use it in sessions that you trust.
  • The MCP server only knows the agent accounts that it created while it runs. When the AI client restarts, it creates new agent accounts. The previous agent accounts remain until they expire. You can delete them on the Agents page of the user interface.

Troubleshooting​

ErrorSolution
Self-service agent creation is not enabled.Give the user the Add an agent user (self-service) permission.
Only internal user accounts can create agents.Only internal users can create agent accounts.
You can only create agents for yourself.Update the authentik Agent to 0.73 or later.
Cannot request access to '<application>'You don't have access to the application.
Unknown agent or Agent identity not foundThe MCP server restarted. Ask the AI client to create a new agent account.
No launch URL could be resolvedSet a Launch URL for the application, and pass the application's pbm_uuid to token_exchange.
<url> is not adjacent to any applicationThe URL isn't in the registrable domain of the application's launch URL. Refer to Prepare an application.
failed to exchange tokenCheck that the authentik-cli provider is federated with the application's provider, and that you can access the application.