Portainer MCP

Manage Portainer resources and execute Docker or Kubernetes commands through an AI assistant.

Portainer MCP

MCP server for Portainer, generated from the Portainer OpenAPI spec via FastMCP.

Overview

Exposes Portainer's REST API as MCP tools — list environments, manage Docker containers and stacks, query Kubernetes resources, run Helm releases. Two escape-hatch tools (docker_proxy, kubernetes_proxy) forward arbitrary paths to the underlying Docker/K8s APIs for endpoints the spec doesn't enumerate.

Status: in development. Tool names, env vars, and defaults can change between releases. Pin loosely (see Version compatibility) to pick up MCP-only fixes without surprise.

Architecture overview: docs/architecture.md.

Getting started

The server is distributed on PyPI as mcp-portainer. MCP clients launch it as a subprocess via uvx, so uv must be on PATH — see the uv install docs.

Generate an API key in Portainer under My Account → Access tokens, then register the server with Claude Code:

claude mcp add portainer \
  -e PORTAINER_URL=https://portainer.example.com \
  -e PORTAINER_API_KEY=ptr_xxxxxxxxxxxxxxxx \
  -- uvx --from "mcp-portainer~=2.42.0" mcp-portainer

~=2.42.0 picks up MCP-only patch fixes against the same Portainer minor — see Version compatibility for the policy.

Recommended: install the hygiene skill. This repo ships a Claude Code skill (portainer-mcp-hygiene) that helps the model query the MCP efficiently and keep responses within context. Install user-wide, pinned to the same tag as the server:

mkdir -p ~/.claude/skills/portainer-mcp-hygiene && \
  curl -fsSL https://raw.githubusercontent.com/portainer/portainer-mcp/2.42.0/skills/portainer-mcp-hygiene/SKILL.md \
  -o ~/.claude/skills/portainer-mcp-hygiene/SKILL.md

Re-run on each server upgrade so the skill stays in sync.

For other clients, see docs/distribution/. See Configuration for optional knobs.

Contribution are welcome for other client instructions !

Version compatibility

Match your server's minor to your Portainer minor. The major+minor tracks the Portainer API version the embedded spec targets.

Server versionPortainer (CE / EE)
2.42.x2.42.x
2.41.x2.41.x

Configuration

All knobs are environment variables. Only PORTAINER_URL and PORTAINER_API_KEY are required.

Env varDefaultEffect
PORTAINER_URLRequired. Portainer base URL.
PORTAINER_API_KEYRequired. Portainer API key.
PORTAINER_PROFILESBASE,DOCKER,KUBERNETESTag bundles to enable. ALL disables the filter.
PORTAINER_TAGS_EXTRAemptyExtra tags appended to the profile union (escape hatch).
PORTAINER_READ_ONLY01 restricts to GET/HEAD operations.
PORTAINER_NO_PROXY01 skips docker_proxy / kubernetes_proxy.
PORTAINER_TLS_VERIFY10 skips TLS verification (Portainer instance using self-signed certs).
PORTAINER_MAX_RESPONSE_CHARS50000Response truncation cap. Size to ~80% of your MCP client's output ceiling.
PORTAINER_MCP_LOG_LEVELINFOOne of DEBUG, INFO, WARNING, ERROR, CRITICAL. Logs go to stderr.
PORTAINER_MCP_TRANSPORTstdiostdio (default) or http. http binds a local server for dev / remote deployment.
PORTAINER_MCP_HTTP_HOST127.0.0.1Bind host when PORTAINER_MCP_TRANSPORT=http.
PORTAINER_MCP_HTTP_PORT8000Bind port when PORTAINER_MCP_TRANSPORT=http.

Advanced profile setup — per-profile tag lists, orphan tags, read-only semantics — see docs/profiles.md.

Related Servers