-
Notifications
You must be signed in to change notification settings - Fork 220
feat: Add MCP server #3577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kichristensen
wants to merge
3
commits into
getporter:main
Choose a base branch
from
kichristensen:mcpServer
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
feat: Add MCP server #3577
Changes from 2 commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "get.porter.sh/porter/pkg/mcp" | ||
| "get.porter.sh/porter/pkg/porter" | ||
| "github.com/spf13/cobra" | ||
| ) | ||
|
|
||
| func buildMCPCommand(p *porter.Porter) *cobra.Command { | ||
| opts := mcp.ServerOptions{} | ||
| cmd := &cobra.Command{ | ||
| Use: "mcp", | ||
| Short: "Start an MCP server over stdio", | ||
| Long: `Start a Model Context Protocol (MCP) server that exposes Porter | ||
| operations as tools for LLM agents. | ||
|
|
||
| The server communicates over stdin/stdout using the MCP protocol. | ||
| Read-only tools are always available. Mutating tools (install, upgrade, | ||
| uninstall, invoke) require the --allow-write flag. | ||
|
|
||
| Configure your MCP client (e.g. Claude Desktop) with: | ||
| {"command": "porter", "args": ["mcp"]} | ||
| `, | ||
| RunE: func(cmd *cobra.Command, args []string) error { | ||
| srv := mcp.NewMCPServer(p, opts) | ||
| srv.RegisterTools() | ||
| return srv.ServeStdio(cmd.Context()) | ||
| }, | ||
| } | ||
| f := cmd.Flags() | ||
| f.BoolVar(&opts.AllowWrite, "allow-write", false, | ||
| "Enable mutating tools: install, upgrade, uninstall, invoke") | ||
| return cmd | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,147 @@ | ||
| --- | ||
| title: Working with AI Agents | ||
| description: Connect AI coding assistants and LLM agents to Porter using the Model Context Protocol. | ||
| weight: 3 | ||
| aliases: | ||
| - /how-to-guides/work-with-ai-agents/ | ||
| --- | ||
|
|
||
| Porter includes a built-in [Model Context Protocol (MCP)][mcp] server that | ||
| exposes bundle operations as tools for LLM agents and AI coding assistants such | ||
| as Claude Code, Cursor, and VS Code Copilot. This lets an agent install, | ||
| inspect, and troubleshoot bundles on your behalf using natural language. | ||
|
|
||
| - [Prerequisites](#prerequisites) | ||
| - [Configure your MCP client](#configure-your-mcp-client) | ||
| - [Claude Code](#claude-code) | ||
| - [VS Code (GitHub Copilot)](#vs-code-github-copilot) | ||
| - [Cursor](#cursor) | ||
| - [Available tools](#available-tools) | ||
| - [Enabling write operations](#enabling-write-operations) | ||
| - [Security considerations](#security-considerations) | ||
|
|
||
| ## Prerequisites | ||
|
|
||
| - Porter [installed and configured](/install/) | ||
| - An MCP-compatible AI client (Claude Code, Cursor, VS Code Copilot, etc.) | ||
|
|
||
| ## Configure your MCP client | ||
|
|
||
| Porter's MCP server communicates over stdin/stdout. All clients need the same | ||
| two values: | ||
|
|
||
| | Setting | Value | | ||
| |---------|-------| | ||
| | **command** | `porter` | | ||
| | **args** | `["mcp"]` | | ||
|
|
||
| ### Claude Code | ||
|
|
||
| Add the server to your project: | ||
|
|
||
| ```console | ||
| claude mcp add porter -- porter mcp | ||
| ``` | ||
|
|
||
| Or add it to your user-level configuration so it is available in every project: | ||
|
|
||
| ```console | ||
| claude mcp add --scope user porter -- porter mcp | ||
| ``` | ||
|
|
||
| Verify the server is registered: | ||
|
|
||
| ```console | ||
| claude mcp list | ||
| ``` | ||
|
|
||
| ### VS Code (GitHub Copilot) | ||
|
|
||
| Add to `.vscode/mcp.json` in your workspace: | ||
|
|
||
| ```json | ||
| { | ||
| "servers": { | ||
| "porter": { | ||
| "type": "stdio", | ||
| "command": "porter", | ||
| "args": ["mcp"] | ||
| } | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ### Cursor | ||
|
|
||
| Open **Cursor Settings → MCP** and add: | ||
|
|
||
| ```json | ||
| { | ||
| "porter": { | ||
| "command": "porter", | ||
| "args": ["mcp"] | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| ## Available tools | ||
|
|
||
| ### Read-only tools (always available) | ||
|
|
||
| | Tool | What the agent can do | | ||
| |------|-----------------------| | ||
| | `explain_bundle` | Show parameters, credentials, outputs, and actions of a published bundle by OCI reference | | ||
| | `list_installations` | List Porter installations, optionally filtered by namespace or name | | ||
| | `show_installation` | Show the current status and details of a specific installation | | ||
| | `list_runs` | List execution history for an installation | | ||
| | `get_logs` | Retrieve logs from a run (latest run or a specific run ID) | | ||
| | `list_outputs` | List output values from an installation run (sensitive values are masked) | | ||
| | `get_output` | Read a specific output value (blocked for sensitive outputs) | | ||
| | `list_credentials` | List available credential sets | | ||
| | `show_credential` | Show the definition of a credential set | | ||
| | `list_parameters` | List available parameter sets | | ||
| | `show_parameter` | Show the definition of a parameter set | | ||
| | `analyze_failure` | Aggregate failure context: finds the last failed run (or a specific run by ID) and returns its logs and outputs in one call | | ||
|
|
||
| ### Write tools (require `--allow-write`) | ||
|
|
||
| | Tool | What the agent can do | | ||
| |------|-----------------------| | ||
| | `install_bundle` | Install a bundle from an OCI reference | | ||
| | `upgrade_bundle` | Upgrade an existing installation | | ||
| | `uninstall_bundle` | Uninstall an installation | | ||
| | `invoke_bundle` | Run a custom action on an installation | | ||
|
|
||
| ## Enabling write operations | ||
|
|
||
| Write tools are disabled by default so that an agent browsing installations | ||
| cannot accidentally modify them. Pass `--allow-write` to expose the install, | ||
| upgrade, uninstall, and invoke tools: | ||
|
|
||
| ```console | ||
| # Claude Code | ||
| claude mcp add porter -- porter mcp --allow-write | ||
|
|
||
| # VS Code / Cursor — add "--allow-write" to the args array | ||
| "args": ["mcp", "--allow-write"] | ||
| ``` | ||
|
|
||
| When `--allow-write` is not set, the write tools are not registered at all and | ||
| will not appear in the agent's tool list. | ||
|
|
||
| ## Security considerations | ||
|
|
||
| - **Read-only by default.** Without `--allow-write`, no bundle lifecycle | ||
| operations are exposed. | ||
| - **Sensitive outputs are masked.** Values marked sensitive in the bundle are | ||
| returned as `***` in `list_outputs` and are blocked entirely in `get_output`. | ||
| - **Credentials are not exposed.** The server can show the structure of a | ||
| credential set (which sources are configured) but never returns the resolved | ||
| secret values. | ||
| - **Local access only.** The MCP server uses stdio transport; there is no | ||
| network listener and no authentication is required or possible. | ||
| - **Porter's own access controls apply.** The server runs as the current OS | ||
| user with the existing Porter configuration. It can only access namespaces | ||
| and plugins that the user can access directly. | ||
|
|
||
| [mcp]: https://modelcontextprotocol.io |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| --- | ||
| title: "porter mcp" | ||
| slug: porter_mcp | ||
| url: /cli/porter_mcp/ | ||
| --- | ||
| ## porter mcp | ||
|
|
||
| Start an MCP server over stdio | ||
|
|
||
| ### Synopsis | ||
|
|
||
| Start a Model Context Protocol (MCP) server that exposes Porter | ||
| operations as tools for LLM agents. | ||
|
|
||
| The server communicates over stdin/stdout using the MCP protocol. | ||
| Read-only tools are always available. Mutating tools (install, upgrade, | ||
| uninstall, invoke) require the --allow-write flag. | ||
|
|
||
| Configure your MCP client (e.g. Claude Desktop) with: | ||
| {"command": "porter", "args": ["mcp"]} | ||
|
|
||
|
|
||
kichristensen marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
| porter mcp [flags] | ||
| ``` | ||
|
|
||
| ### Options | ||
|
|
||
| ``` | ||
| --allow-write Enable mutating tools: install, upgrade, uninstall, invoke | ||
| -h, --help help for mcp | ||
| ``` | ||
|
|
||
| ### Options inherited from parent commands | ||
|
|
||
| ``` | ||
| --context string Name of the configuration context to use. When unset, Porter uses the current-context from the config file, falling back to the context named "default". | ||
| --experimental strings Comma separated list of experimental features to enable. See https://porter.sh/configuration/#experimental-feature-flags for available feature flags. | ||
| --verbosity string Threshold for printing messages to the console. Available values are: debug, info, warning, error. (default "info") | ||
| ``` | ||
|
|
||
| ### SEE ALSO | ||
|
|
||
| * [porter](/cli/porter/) - With Porter you can package your application artifact, client tools, configuration and deployment logic together as a versioned bundle that you can distribute, and then install with a single command. | ||
|
|
||
| Most commands require a Docker daemon, either local or remote. | ||
|
|
||
| Try our QuickStart https://porter.sh/quickstart to learn how to use Porter. | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.