For the complete documentation index, see llms.txt. This page is also available as Markdown.

MCP

Portainer-Run exposes a Model Context Protocol (MCP) endpoint at POST /mcp, so AI coding tools can deploy applications directly, with no browser and no human clicking through the UI at all. This is the same governed pipeline as Deploy, just driven by an MCP-capable client instead of the web interface.

Connect your agent

Every user has a Connect your agent page, under AI agents in the navigation. It creates the Portainer API key your AI assistant uses and walks you through adding Portainer-Run to Claude Desktop, so you don't need to create a token in Portainer yourself.

  1. Select New key, name it (for example after the computer it's on), and enter your Portainer password if asked. Portainer only asks for it when you sign in with Portainer's own user database, not with LDAP or OAuth.

  2. Copy the key. It's shown once.

  3. Choose how to connect Claude Desktop:

    • Extension (recommended): download the portainer-run.mcpb extension, open it to install it in Claude Desktop, and paste the key when asked. The address is filled in for you, and Claude Desktop keeps the key in your system's keychain.

    • Config file: for macOS, Linux, or Windows, paste the generated configuration into claude_desktop_config.json, then quit and reopen Claude Desktop. This route needs Node.js installed, as described below.

The assistant acts as you, with all of your Portainer rights. Keys never expire, so treat a key like a password. The page lists your keys, and you can revoke any of them; an assistant using a revoked key stops working straight away. If Portainer uses a self-signed or internal certificate, give the extension that certificate (or its CA) in its optional certificate setting.

Connecting Claude Desktop manually

The following procedure connects Claude Desktop to your Portainer-Run instance so you can work with it from a Claude chat.

Before you begin

You will need:

Add Portainer-Run configuration to Claude desktop

These details differ by operating system, select Windows, MacOS or Linux below.

  1. Open Claude Desktop.

  2. Select your name at the bottom left, then select Settings.

  3. In the left menu, select Developer.

  4. Select Edit Config. A file window opens and highlights claude_desktop_config.json.

  5. Right-click the file, select Open with, then select Notepad.

  6. Add the configuration for your system to the file.

    1. If the file is empty or contains only {}, select all the text in the file, delete it, and paste the full configuration for your system.

    2. If the file already contains other settings, don’t delete them.

      1. If the file already has an "mcpServers": { section, add a comma after the last entry in that section, then paste the "portainer-run": { ... } block on a new line below it.

      2. If the file doesn’t have an "mcpServers": { section, add a comma after the last setting in the file, then paste the whole "mcpServers": { ... } section on a new line below it.

      In both cases, don’t copy the outer { and } from the configuration.

If you are using a self-signed certificate, you will need the following environment variable set:

For example:

  1. Replace <your-portainer-host> with your Portainer address (for example portainer.example.com) and keep /addons/portainer-run/mcp at the end. Replace YOUR_PORTAINER_TOKEN with your API token. Keep the quotation marks.

  2. Save the file and close the editor.

  3. Restart Claude Desktop. Claude Desktop only reads the configuration when it starts, and closing the window doesn’t quit the app. Select the arrow at the right of the taskbar to show hidden icons, right-click the Claude icon, and select Quit.

  1. Open Claude Desktop.

  2. Select your name at the bottom left, then select Settings.

  3. In the left menu, select Developer.

  4. Select Edit Config. A file window opens and highlights claude_desktop_config.json.

  5. Right-click the file, select Open With, then select TextEdit. If the file appears with formatting options, select Format > Make Plain Text.

  6. Add the configuration for your system to the file.

    1. If the file is empty or contains only {}, select all the text in the file, delete it, and paste the full configuration for your system.

    2. If the file already contains other settings, don’t delete them.

      1. If the file already has an "mcpServers": { section, add a comma after the last entry in that section, then paste the "portainer-run": { ... } block on a new line below it.

      2. If the file doesn’t have an "mcpServers": { section, add a comma after the last setting in the file, then paste the whole "mcpServers": { ... } section on a new line below it.

      In both cases, don’t copy the outer { and } from the configuration.

If you are using a self-signed certificate, you will need the following environment variable set:

For example:

  1. Replace <your-portainer-host> with your Portainer address (for example portainer.example.com) and keep /addons/portainer-run/mcp at the end. Replace YOUR_PORTAINER_TOKEN with your API token. Keep the quotation marks.

  2. Save the file and close the editor.

  3. Restart Claude Desktop. Claude Desktop only reads the configuration when it starts, and closing the window doesn’t quit the app. Select Claude in the menu bar, then select Quit Claude, or press Command+Q.

Claude Linux support is in beta.

  1. Open Claude Desktop.

  2. Select Claude in the menu bar, then select Settings.

  3. In the left menu, select Developer.

  4. Select Edit Config. A file window opens and highlights claude_desktop_config.json.

  5. Open claude_desktop_config.json in your text editor, such as Text Editor (GNOME) or Kate (KDE).

  6. Add the configuration for your system to the file.

    1. If the file is empty or contains only {}, select all the text in the file, delete it, and paste the full configuration for your system.

    2. If the file already contains other settings, don’t delete them.

      1. If the file already has an "mcpServers": { section, add a comma after the last entry in that section, then paste the "portainer-run": { ... } block on a new line below it.

      2. If the file doesn’t have an "mcpServers": { section, add a comma after the last setting in the file, then paste the whole "mcpServers": { ... } section on a new line below it.

      In both cases, don’t copy the outer { and } from the configuration.

If you are using a self-signed certificate, you will need the following environment variable set:

For example:

  1. Replace <your-portainer-host> with your Portainer address (for example portainer.example.com) and keep /addons/portainer-run/mcp at the end. Replace YOUR_PORTAINER_TOKEN with your API token. Keep the quotation marks.

  2. Save the file and close the editor.

  3. Restart Claude Desktop. Close the window, then quit from the app’s menu or tray icon. If Claude Desktop still seems to be running, enter pkill -f claude-desktop in Terminal. Then reopen it from your applications menu.

Verify your connection

  1. In Claude desktop, go to Settings > Developer.

  2. Confirm that portainer-run is listed with a Running status. The first start can take a few seconds while the connector downloads.

  3. Start a new chat and try out some of the available tools.

Available tools

Whatever you see and do in Portainer is exactly what it can see and do through MCP; the same RBAC boundary applies. See Roles and RBAC.

Tool
What it does

get_deploy_options

Call this before deploying. Returns what Portainer-Run would use for this user, the way the Deploy page would: where the app would run (environment and project space), its web address, and where it's stored. It also returns questions, listing only the choices Portainer-Run can't make itself (often none). Accepts optional appName, envId, namespace, gitTargetId and ingress. If the user can't deploy yet, it returns blocked with a message.

list_environments

For technical users. Returns Kubernetes environments accessible with the provided token, excluding any an admin has disabled from deploy flows via Cluster Readiness.

list_namespaces

For technical users. Returns namespaces in a given environment, filtered to exclude system namespaces.

list_git_targets

For technical users. Returns Git targets accessible to the caller (their own targets plus shared targets). If none exist, also returns a message explaining that a Git target is required and must be created in the Portainer-Run UI. Git targets can't be created via MCP.

list_ingress_classes

For technical users. Returns the IngressClasses defined in an environment (including which one is the cluster default), plus baseDomain and ingressHostRequired. Use it to pick an ingress class when deploying with exposeType: "Ingress". When ingressHostRequired is true, no base domain is configured, so a full ingress.host must be supplied.

request_upload_session

Starts a file upload for a deployment. Takes no parameters and returns a sessionId, an uploadUrl and an expiresAt time. Upload the complete set of files to uploadUrl, then pass the sessionId to deploy_app as stagedSessionId. A session can be used once and expires after 5 minutes.

deploy_app

Deploys previously uploaded source files via the full Deploy pipeline.

Accepts appName, envId, namespace, gitTargetId and stagedSessionId (from request_upload_session), and optional envVars (an array of { key, value }), ingress ({ host, path, ingressClass }), runtime, branch (defaults to main), size (S, M or L; defaults to S) and sizeReason, which is required with M or L. See Size. Runtime is auto-detected by default; pass runtime (node, python, php, ruby, or nginx) to override, for example nginx to serve a static site.

Parses .env.example for environment variables if envVars isn't supplied.

Applications deployed over MCP are always exposed through an Ingress. The host defaults to <appName>.<base domain> if a base domain is set in Settings, and ingressClass defaults to the cluster's default IngressClass if not supplied.

Returns a url for accessing the app, or null if the address is still being assigned, in which case get_app_status returns it once ready.

get_app_status

Returns the running status of a deployed application, with a plain summary (Running, Starting up, Stopped, or Having trouble) and a live access url resolved from the Service or Ingress. Takes appName, and envId and namespace when needed. If the app could be in more than one place, it returns a question to ask instead.

redeploy_app

Redeploys an app so its pods pull the latest image of its runtime, for example after a Node.js security release. It commits the change to the app's manifest in Git; Portainer applies it straight away if the caller deployed the app, and otherwise the next time it applies the stack from Git. Needs edit access to the app. Takes appName, and envId and namespace when needed. Call get_app_status afterwards to see it running again.

The file relay gateway

MCP deployments never send files inline in the deploy_app call. The files are uploaded to uploadUrl (from request_upload_session) through Portainer's hosted relay, https://run-gateway.portainer.ai, which avoids the payload-size limits some MCP clients or transports impose. This means the Gateway URL must be set in Settings; without it deploy_app fails with "GATEWAY_URL is not configured". There's nothing for the calling MCP client to configure differently.

Last updated

Was this helpful?