Portainer MCP

Portainer MCP

Connect AI assistants securely to Portainer environments using the Model Context Protocol.

81
Stars
16
Forks
81
Watchers
8
Issues
Portainer MCP is an implementation of the Model Context Protocol (MCP) designed for seamless integration between AI assistants and Portainer-managed container environments. It enables management of Portainer resources and allows execution of Docker and Kubernetes commands through AI interfaces in a secure, standardized manner. The tool provides direct protocol-based access to environment data, facilitating automation and operational insights for container infrastructures.

Key Features

Implements the Model Context Protocol for environment interoperability
Connects AI assistants directly to Portainer environments
Enables management of Portainer resources such as users and environments
Supports execution of Docker commands via AI interfaces
Supports Kubernetes command execution through MCP
Secure access using Portainer administrator API tokens
Version compatibility checks with Portainer deployments
Pre-built binaries for Linux and macOS platforms
Checksum verification for binary integrity
Designed for further extensibility and active development

Use Cases

Automated container management via conversational or AI-driven interfaces
Integrating Portainer operational data with custom AI workflows
Granting AI tools secure programmatic access to Docker or Kubernetes resources
Centralizing administration of Portainer environments through standardized protocols
Building infrastructure monitoring assistants for Portainer and containers
Automating deployment and scaling decisions based on AI recommendations
Providing self-service LLM agents with infrastructure management capabilities
Facilitating DevOps processes by exposing environment state to LLM-based tools
Enhancing operational insight for administrators via natural language queries
Developing custom automation bots for troubleshooting or resource provisioning

README

Portainer MCP

Go Report Card coverage

Ever wished you could just ask Portainer what's going on?

Now you can! Portainer MCP connects your AI assistant directly to your Portainer environments. Manage Portainer resources such as users and environments, or dive deeper by executing any Docker or Kubernetes command directly through the AI.

portainer-mcp-demo

Overview

Portainer MCP is a work in progress implementation of the Model Context Protocol (MCP) for Portainer environments. This project aims to provide a standardized way to connect Portainer's container management capabilities with AI models and other services.

MCP (Model Context Protocol) is an open protocol that standardizes how applications provide context to LLMs (Large Language Models). Similar to how USB-C provides a standardized way to connect devices to peripherals, MCP provides a standardized way to connect AI models to different data sources and tools.

This implementation focuses on exposing Portainer environment data through the MCP protocol, allowing AI assistants and other tools to interact with your containerized infrastructure in a secure and standardized way.

[!NOTE] This tool is designed to work with specific Portainer versions. If your Portainer version doesn't match the supported version, you can use the --disable-version-check flag to attempt connection anyway. See Portainer Version Support for compatible versions and Disable Version Check for bypass instructions.

See the Supported Capabilities sections for more details on compatibility and available features.

Note: This project is currently under development.

It is currently designed to work with a Portainer administrator API token.

Installation

You can download pre-built binaries for Linux (amd64, arm64) and macOS (arm64) from the Latest Release Page. Find the appropriate archive for your operating system and architecture under the "Assets" section.

Download the archive: You can usually download this directly from the release page. Alternatively, you can use curl. Here's an example for macOS (ARM64) version v0.2.0:

bash
# Example for macOS (ARM64) - adjust version and architecture as needed
curl -Lo portainer-mcp-v0.2.0-darwin-arm64.tar.gz https://github.com/portainer/portainer-mcp/releases/download/v0.2.0/portainer-mcp-v0.2.0-darwin-arm64.tar.gz

(Linux AMD64 binaries are also available on the release page.)

(Optional but recommended) Verify the checksum: First, download the corresponding .md5 checksum file from the release page. Example for macOS (ARM64) v0.2.0:

bash
# Download the checksum file (adjust version/arch)
curl -Lo portainer-mcp-v0.2.0-darwin-arm64.tar.gz.md5 https://github.com/portainer/portainer-mcp/releases/download/v0.2.0/portainer-mcp-v0.2.0-darwin-arm64.tar.gz.md5
# Now verify (output should match the content of the .md5 file)
if [ "$(md5 -q portainer-mcp-v0.2.0-darwin-arm64.tar.gz)" = "$(cat portainer-mcp-v0.2.0-darwin-arm64.tar.gz.md5)" ]; then echo "OK"; else echo "FAILED"; fi

(For Linux, you can use md5sum -c <checksum_file_name>.md5) If the verification command outputs "OK", the file is intact.

Extract the archive:

bash
# Adjust the filename based on the downloaded version/OS/architecture
tar -xzf portainer-mcp-v0.2.0-darwin-arm64.tar.gz

This will extract the portainer-mcp executable.

Move the executable: Move the executable to a location in your $PATH (e.g., /usr/local/bin) or note its location for the configuration step below.

Usage

With Claude Desktop, configure it like so:

{
    "mcpServers": {
        "portainer": {
            "command": "/path/to/portainer-mcp",
            "args": [
                "-server",
                "[IP]:[PORT]",
                "-token",
                "[TOKEN]",
                "-tools",
                "/tmp/tools.yaml"
            ]
        }
    }
}

Replace [IP], [PORT] and [TOKEN] with the IP, port and API access token associated with your Portainer instance.

[!NOTE] By default, the tool looks for "tools.yaml" in the same directory as the binary. If the file does not exist, it will be created there with the default tool definitions. You may need to modify this path as described above, particularly when using AI assistants like Claude that have restricted write permissions to the working directory.

Disable Version Check

By default, the application validates that your Portainer server version matches the supported version and will fail to start if there's a mismatch. If you have a Portainer server version that doesn't have a corresponding Portainer MCP version available, you can disable this version check to attempt connection anyway.

To disable the version check, add the -disable-version-check flag to your command arguments:

{
    "mcpServers": {
        "portainer": {
            "command": "/path/to/portainer-mcp",
            "args": [
                "-server",
                "[IP]:[PORT]",
                "-token",
                "[TOKEN]",
                "-disable-version-check"
            ]
        }
    }
}

[!WARNING] Disabling the version check may result in unexpected behavior or API incompatibilities if your Portainer server version differs significantly from the supported version. The tool may work partially or not at all with unsupported versions.

When using this flag:

  • The application will skip Portainer server version validation at startup
  • Some features may not work correctly due to API differences between versions
  • Newer Portainer versions may have API changes that cause errors
  • Older Portainer versions may be missing APIs that the tool expects

This flag is useful when:

  • You're running a newer Portainer version that doesn't have MCP support yet
  • You're running an older Portainer version and want to try the tool anyway

Tool Customization

By default, the tool definitions are embedded in the binary. The application will create a tools file at the default location if one doesn't already exist.

You can customize the tool definitions by specifying a custom tools file path using the -tools flag:

{
    "mcpServers": {
        "portainer": {
            "command": "/path/to/portainer-mcp",
            "args": [
                "-server",
                "[IP]:[PORT]",
                "-token",
                "[TOKEN]",
                "-tools",
                "/path/to/custom/tools.yaml"
            ]
        }
    }
}

The default tools file is available for reference at internal/tooldef/tools.yaml in the source code. You can modify the descriptions of the tools and their parameters to alter how AI models interpret and decide to use them. You can even decide to remove some tools if you don't wish to use them.

[!WARNING] Do not change the tool names or parameter definitions (other than descriptions), as this will prevent the tools from being properly registered and functioning correctly.

Read-Only Mode

For security-conscious users, the application can be run in read-only mode. This mode ensures that only read operations are available, completely preventing any modifications to your Portainer resources.

To enable read-only mode, add the -read-only flag to your command arguments:

{
    "mcpServers": {
        "portainer": {
            "command": "/path/to/portainer-mcp",
            "args": [
                "-server",
                "[IP]:[PORT]",
                "-token",
                "[TOKEN]",
                "-read-only"
            ]
        }
    }
}

When using read-only mode:

  • Only read tools (list, get) will be available to the AI model
  • All write tools (create, update, delete) are not loaded
  • The Docker proxy requests tool is not loaded
  • The Kubernetes proxy requests tool is not loaded

Portainer Version Support

This tool is pinned to support a specific version of Portainer. The application will validate the Portainer server version at startup and fail if it doesn't match the required version.

Portainer MCP Version Supported Portainer Version
0.1.0 2.28.1
0.2.0 2.28.1
0.3.0 2.28.1
0.4.0 2.29.2
0.4.1 2.29.2
0.5.0 2.30.0
0.6.0 2.31.2

[!NOTE] If you need to connect to an unsupported Portainer version, you can use the -disable-version-check flag to bypass version validation. See the Disable Version Check section for more details and important warnings about using this feature.

Supported Capabilities

The following table lists the currently (latest version) supported operations through MCP tools:

Resource Operation Description Supported In Version
Environments
ListEnvironments List all available environments 0.1.0
UpdateEnvironmentTags Update tags associated with an environment 0.1.0
UpdateEnvironmentUserAccesses Update user access policies for an environment 0.1.0
UpdateEnvironmentTeamAccesses Update team access policies for an environment 0.1.0
Environment Groups (Edge Groups)
ListEnvironmentGroups List all available environment groups 0.1.0
CreateEnvironmentGroup Create a new environment group 0.1.0
UpdateEnvironmentGroupName Update the name of an environment group 0.1.0
UpdateEnvironmentGroupEnvironments Update environments associated with a group 0.1.0
UpdateEnvironmentGroupTags Update tags associated with a group 0.1.0
Access Groups (Endpoint Groups)
ListAccessGroups List all available access groups 0.1.0
CreateAccessGroup Create a new access group 0.1.0
UpdateAccessGroupName Update the name of an access group 0.1.0
UpdateAccessGroupUserAccesses Update user accesses for an access group 0.1.0
UpdateAccessGroupTeamAccesses Update team accesses for an access group 0.1.0
AddEnvironmentToAccessGroup Add an environment to an access group 0.1.0
RemoveEnvironmentFromAccessGroup Remove an environment from an access group 0.1.0
Stacks (Edge Stacks)
ListStacks List all available stacks 0.1.0
GetStackFile Get the compose file for a specific stack 0.1.0
CreateStack Create a new Docker stack 0.1.0
UpdateStack Update an existing Docker stack 0.1.0
Tags
ListEnvironmentTags List all available environment tags 0.1.0
CreateEnvironmentTag Create a new environment tag 0.1.0
Teams
ListTeams List all available teams 0.1.0
CreateTeam Create a new team 0.1.0
UpdateTeamName Update the name of a team 0.1.0
UpdateTeamMembers Update the members of a team 0.1.0
Users
ListUsers List all available users 0.1.0
UpdateUser Update an existing user 0.1.0
GetSettings Get the settings of the Portainer instance 0.1.0
Docker
DockerProxy Proxy ANY Docker API requests 0.2.0
Kubernetes
KubernetesProxy Proxy ANY Kubernetes API requests 0.3.0
getKubernetesResourceStripped Proxy GET Kubernetes API requests and automatically strip verbose metadata fields 0.6.0

Development

Code Statistics

The repository includes a helper script cloc.sh to calculate lines of code and other metrics for the Go source files using the cloc tool. You might need to install cloc first (e.g., sudo apt install cloc or brew install cloc).

Run the script from the repository root to see the default summary output:

bash
./cloc.sh

Refer to the comment header within the cloc.sh script for details on available flags to retrieve specific metrics.

Token Counting

To get an estimate of how many tokens your current tool definitions consume in prompts, you can use the provided Go program and shell script to query the Anthropic API's token counting endpoint.

1. Generate the Tools JSON:

First, use the token-count Go program to convert your YAML tool definitions into the JSON format required by the Anthropic API. Run this from the repository root:

bash
# Replace internal/tooldef/tools.yaml with your YAML file if different
# Replace .tmp/tools.json with your desired output path
go run ./cmd/token-count -input internal/tooldef/tools.yaml -output .tmp/tools.json

This command reads the tool definitions from the specified input YAML file and writes a JSON array of tools (containing name, description, and input_schema) to the specified output file.

2. Query the Anthropic API:

Next, use the token.sh script to send these tool definitions along with a sample message to the Anthropic API. You will need an Anthropic API key for this step.

bash
# Ensure you have jq installed
# Replace sk-ant-xxxxxxxx with your actual Anthropic API key
# Replace .tmp/tools.json with the path to the file generated in step 1
./token.sh -k sk-ant-xxxxxxxx -i .tmp/tools.json

The script will output the JSON response from the Anthropic API, which includes the estimated token count for the provided tools and sample message under the usage.input_tokens field.

This process helps in understanding the token cost associated with the toolset provided to the language model.

Star History

Star History Chart

Repository Owner

portainer
portainer

Organization

Repository Details

Language Go
Default Branch main
Size 358 KB
Contributors 3
License zlib License
MCP Verified Nov 11, 2025

Programming Languages

Go
97.98%
Shell
1.77%
Makefile
0.26%

Tags

Join Our Newsletter

Stay updated with the latest AI tools, news, and offers by subscribing to our weekly newsletter.

We respect your privacy. Unsubscribe at any time.

Related MCPs

Discover similar Model Context Protocol servers

  • QuantConnect MCP Server

    QuantConnect MCP Server

    Official bridge for secure AI access to QuantConnect's algorithmic trading cloud platform

    QuantConnect MCP Server enables artificial intelligence systems such as Claude and OpenAI to interface with QuantConnect's cloud platform through an official, secure, and dockerized implementation of the Model Context Protocol (MCP). It facilitates automated project management, strategy writing, backtesting, and live deployment by exposing a comprehensive suite of API tools for users with valid access credentials. As the maintained official version, it ensures security, easy deployment, and cross-platform compatibility for advanced algorithmic trading automation.

    • 50
    • MCP
    • QuantConnect/mcp-server
  • mcp-server-docker

    mcp-server-docker

    Natural language management of Docker containers via Model Context Protocol.

    mcp-server-docker enables users to manage Docker containers using natural language instructions through the Model Context Protocol. It allows composing, introspecting, and debugging containers, as well as managing persistent Docker volumes. The tool is suitable for server administrators, tinkerers, and AI enthusiasts looking to leverage LLM capabilities for Docker management. Integration with tools like Claude Desktop and Docker ensures flexible deployment and easy connectivity to Docker engines.

    • 648
    • MCP
    • ckreiling/mcp-server-docker
  • Docker Hub MCP Server

    Docker Hub MCP Server

    Expose Docker Hub APIs to LLMs via the Model Context Protocol.

    The Docker Hub MCP Server implements the Model Context Protocol (MCP) to make Docker Hub APIs accessible to large language models, enabling AI-powered discovery and management of container images and repositories. It provides an interface for LLMs to access real-time Docker Hub data, recommend images, and streamline developer workflows. The server supports both public and private repositories through configurable authentication, and can be integrated with AI assistants like Gordon and clients such as Claude Desktop.

    • 83
    • MCP
    • docker/hub-mcp
  • Insforge MCP Server

    Insforge MCP Server

    A Model Context Protocol server for seamless integration with Insforge and compatible AI clients.

    Insforge MCP Server implements the Model Context Protocol (MCP), enabling smooth integration with various AI tools and clients. It allows users to configure and manage connections to the Insforge platform, providing automated and manual installation methods. The server supports multiple AI clients such as Claude Code, Cursor, Windsurf, Cline, Roo Code, and Trae via standardized context management. Documentation and configuration guidelines are available for further customization and usage.

    • 3
    • MCP
    • InsForge/insforge-mcp
  • CipherTrust Manager MCP Server

    CipherTrust Manager MCP Server

    Enables AI assistants to access CipherTrust Manager securely via the Model Context Protocol.

    CipherTrust Manager MCP Server provides an implementation of the Model Context Protocol (MCP), offering AI assistants such as Claude and Cursor a unified interface to interact with CipherTrust Manager resources. Communication is facilitated through JSON-RPC over stdin/stdout, enabling key management, CTE client management, user management, and connection management functionalities. The tool is configurable via environment variables and integrates with existing CipherTrust Manager instances using the ksctl CLI for secure resource access.

    • 7
    • MCP
    • sanyambassi/ciphertrust-manager-mcp-server
  • Intruder MCP

    Intruder MCP

    Enable AI agents to control Intruder.io via the Model Context Protocol.

    Intruder MCP allows AI model clients such as Claude and Cursor to interactively control the Intruder vulnerability scanner through the Model Context Protocol. It can be deployed using smithery, locally with Python, or in a Docker container, requiring only an Intruder API key for secure access. The tool provides integration instructions tailored for MCP-compatible clients, streamlining vulnerability management automation for AI-driven workflows.

    • 21
    • MCP
    • intruder-io/intruder-mcp
  • Didn't find tool you were looking for?

    Be as detailed as possible for better results