StackGen MCP Integration
The Model Context Protocol (MCP) lets assistants in Claude, Cursor, VS Code, and similar tools call StackGen APIs through a standard tool list. You authenticate with a StackGen personal access token (PAT) and either run the CLI locally (STDIO) or connect to StackGen over HTTPS (SSE).
This guide covers how those modes differ, how Admin (Producer) and User (Consumer) MCP differ, and exact configuration for common IDEs. Replace every sample URL and token placeholder with values from your StackGen tenant.
StackGen MCP Capabilities
- Live context: Models can read current infrastructure and project state from StackGen instead of guessing.
- Actions in-product: Approved operations (see Admin vs User MCP) run against the same APIs as the UI, within the PAT's permissions.
- One integration pattern: The same MCP idea works across clients; only the config file shape changes.
- Authenticated access: Every call is tied to the PAT you configure (see Tools match your token).
STDIO vs SSE
| STDIO | SSE | |
|---|---|---|
| Mechanism | The IDE (or Claude CLI) starts stackgen mcp on your machine. The StackGen CLI hosts the MCP session. | The IDE opens HTTPS connections to StackGen MCP routes. No local stackgen mcp process is required for that path. |
| Typical config | One server entry (for example stackgen-mcp) in Claude, VS Code, or Cursor. | Two server entries in Cursor: stackgen-admin and stackgen-user (example). |
| Extra tooling | Installing cloud2code can expose additional tools on this path. | Available tools still depend on your PAT's role and permissions. |
Admin MCP and User MCP (SSE)
For SSE, StackGen exposes separate endpoints so platform and module work stays distinct from appStack and topology work. The STDIO path is a single local server unless you add more entries yourself.
| Admin MCP (Producer) | User MCP (Consumer) | |
|---|---|---|
| Personas | Admin, DevOps | Developer |
| Purpose | Projects, policies, custom modules, secrets | appStacks, topology (resources), snapshots |
| Examples | List projects, list policies, scan / create / delete custom modules, list secrets | List or create appStacks, add, delete, or configure resources, get or restore snapshots |
| Prompts | Depends on client and token | In supported clients, prompts such as Create Infrastructure |
Rule of thumb: use the Admin URL for governance and module lifecycle. Use the User URL for work inside an appStack or on the canvas.
StackGen registers only tools your PAT may invoke. If you point the Admin MCP URL at a Developer PAT, the tool list will be smaller than with an Admin or DevOps PAT on the same URL. Use a PAT whose role matches the work you need.
If the client cannot connect, fix URL and Bearer token before comparing tool lists.
Prerequisites
- StackGen CLI (for STDIO only): Follow the install and uninstall guide and ensure
stackgenis on thePATHfor the environment where the IDE launches MCP. - PAT: Create or reuse a token for the tenant you are targeting.
- Base URL: Use your real StackGen base URL (examples in this doc use
https://cloud.stackgen.com; substitute yours, no trailing slash before path segments like/api/mcp/...). - SSE paths (for remote MCP):
https://<your-base-url>/api/mcp/adminandhttps://<your-base-url>/api/mcp/user(see Cursor example).
Configure your IDE
STDIO is a practical default when you already run the StackGen CLI on the same machine. SSE fits when your IDE supports remote MCP over HTTPS and you want separate Admin and User servers without a local MCP subprocess. If you use cloud2code, you can unlock more tools on the STDIO path.
Pick your tool below. JSON samples may include // comments; if your editor rejects them, remove the comment lines or use JSONC where supported.
Claude
Click to view
Register a local STDIO server that runs stackgen mcp:
claude mcp add stackgen \
--env STACKGEN_URL=https://cloud.stackgen.com \
--env STACKGEN_TOKEN="<STACKGEN_PAT>" \
-s user -- stackgen mcp
Replace https://cloud.stackgen.com with your base URL and <STACKGEN_PAT> with your PAT.
Flags
| Flag | Description |
|---|---|
claude mcp add stackgen | Starts registration of an MCP server named stackgen in Claude CLI. |
--env STACKGEN_URL=... | Sets STACKGEN_URL for the stackgen mcp process. Use your StackGen tenant base URL. |
--env STACKGEN_TOKEN="..." | Sets STACKGEN_TOKEN to your PAT so the CLI can authenticate to StackGen. |
-s user | Writes the MCP server definition to user-level settings so it applies across Claude CLI sessions. |
-- stackgen mcp | Separator plus command: Claude runs stackgen mcp to start the local STDIO MCP server. |
See the Anthropic MCP CLI guide.
Visual Studio Code
Click to view
- Open the Command Palette (
Cmd+Shift+Pon macOS,Ctrl+Shift+Pon Windows). - Run MCP: Open User Configuration (wording may vary slightly by VS Code version).
- Add a STDIO server inside
servers:
{
"servers": {
"stackgen-mcp": {
"type": "stdio",
"command": "stackgen",
"args": "mcp",
"env": {
"STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
"STACKGEN_URL": "https://cloud.stackgen.com"
}
}
}
}
Replace placeholders with your PAT and base URL. Save; Copilot Chat and other MCP-aware features can use this server.
Flags
| Parameter | Type | Description | Example |
|---|---|---|---|
servers | Object | Root object for MCP server definitions in VS Code user MCP config. | { "stackgen-mcp": { ... } } |
servers.stackgen-mcp | Object | Configuration for the StackGen STDIO server instance. | See JSON above |
servers.stackgen-mcp.type | String | Transport between IDE and MCP server. stdio uses a subprocess with stdin/stdout. | "stdio" |
servers.stackgen-mcp.command | String | Executable to launch. | "stackgen" |
servers.stackgen-mcp.args | String | Arguments for the command; together with command this starts MCP mode. | "mcp" |
servers.stackgen-mcp.env | Object | Environment variables passed to the MCP process. | STACKGEN_TOKEN, STACKGEN_URL |
servers.stackgen-mcp.env.STACKGEN_TOKEN | String | StackGen PAT. Replace <STACKGEN_TOKEN> with your real token. | <STACKGEN_TOKEN> |
servers.stackgen-mcp.env.STACKGEN_URL | String | StackGen base URL for API calls from the CLI. | "https://cloud.stackgen.com" |
Cursor
Click to view
STDIO (single server)
- Open Settings, then Tools & MCP (or search for it).
- Use Add Custom MCP (or equivalent) so Cursor opens your MCP config (often
mcp.json). - Add:
{
"mcpServers": {
"stackgen-mcp": {
"type": "stdio",
"command": "stackgen",
"args": ["mcp"],
"env": {
"STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
"STACKGEN_URL": "https://cloud.stackgen.com"
}
}
}
}
- Replace
<STACKGEN_TOKEN>with your PAT, adjustSTACKGEN_URL, save, and restart Cursor if it does not pick up changes.
Flags (STDIO: stackgen-mcp)
| Parameter | Type | Description | Example |
|---|---|---|---|
mcpServers | Object | Cursor root object for MCP server entries. | { "stackgen-mcp": { ... } } |
stackgen-mcp (key) | String | Server id shown in Cursor; you can rename it, but keep command/args correct. | stackgen-mcp |
type | String | stdio runs command as a subprocess for MCP. | stdio |
command | String | CLI binary on your PATH. | stackgen |
args | Array | Arguments; mcp starts StackGen in MCP mode. | ["mcp"] |
env.STACKGEN_TOKEN | String | PAT for StackGen. | <STACKGEN_TOKEN> |
env.STACKGEN_URL | String | StackGen base URL. | https://cloud.stackgen.com |
SSE configuration in Cursor
Use SSE when you want two servers: stackgen-admin (Producer) and stackgen-user (Consumer). Merge these entries into mcpServers alongside or instead of stackgen-mcp.
The block below matches Cursor. VS Code, AntiGravity, Kiro, and other editors may require different top-level keys or nesting. Keep the same URLs and Bearer PAT idea, then follow that product's MCP documentation.
- URL: Set each
urlto your base URL plus/api/mcp/adminor/api/mcp/user. If${STACKGEN_URL}is not expanded by your environment, paste the full URL (no trailing slash on the host). - Auth: Set
authorizationto the literal wordBearer, one space, then your PAT (placeholder<STACKGEN_PAT>below).
{
"mcpServers": {
"stackgen-admin": {
"type": "sse",
"url": "${STACKGEN_URL}/api/mcp/admin",
"headers": {
"authorization": "Bearer <STACKGEN_PAT>"
}
},
"stackgen-user": {
"type": "sse",
"url": "${STACKGEN_URL}/api/mcp/user",
"headers": {
"authorization": "Bearer <STACKGEN_PAT>"
}
}
}
}
Use stackgen-admin for producer-style operations (projects, policies, modules, secrets). Use stackgen-user for appStack and topology work and for prompts such as Create Infrastructure when Cursor exposes them.
Flags (SSE: stackgen-admin and stackgen-user)
The same fields apply to both entries; only the url path segment (admin vs user) differs.
| Parameter | Type | Description | Example |
|---|---|---|---|
stackgen-admin / stackgen-user (keys) | String | Two server entries under mcpServers: Admin (Producer) and User (Consumer). | stackgen-admin, stackgen-user |
type | String | Use sse for remote MCP over HTTPS to StackGen. | sse |
url | String | ${STACKGEN_URL}/api/mcp/admin or ${STACKGEN_URL}/api/mcp/user. Replace ${STACKGEN_URL} with your tenant base URL if it is not expanded automatically. No trailing slash on the base. | See JSON above |
headers | Object | HTTP headers sent on MCP requests. | authorization |
headers.authorization | String | Bearer followed by your PAT. The tools Cursor lists still follow token permissions. | Bearer <STACKGEN_PAT> |
See Cursor MCP install links.
Troubleshooting
Click to view
- Authentication: Verify the PAT is valid, not expired, and issued for the same base URL you configured. For SSE, confirm the full
Bearer <token>header. - Network: Ensure firewalls and proxies allow HTTPS to your StackGen host (and local subprocess launch for STDIO).
- Server not listed in IDE: Restart the IDE or shell after editing config; for STDIO, confirm
which stackgenworks in the same environment the IDE uses. - SSE errors: Use a base URL without a trailing slash before
/api/mcp/.... Confirm you selected the Admin vs User URL that matches the task. If tools look incomplete, compare against a PAT whose role matches that surface.