Skip to main content
⏳ Estimated read time: 9 min read

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

STDIOSSE
MechanismThe 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 configOne server entry (for example stackgen-mcp) in Claude, VS Code, or Cursor.Two server entries in Cursor: stackgen-admin and stackgen-user (example).
Extra toolingInstalling 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)
PersonasAdmin, DevOpsDeveloper
PurposeProjects, policies, custom modules, secretsappStacks, topology (resources), snapshots
ExamplesList projects, list policies, scan / create / delete custom modules, list secretsList or create appStacks, add, delete, or configure resources, get or restore snapshots
PromptsDepends on client and tokenIn 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.

note

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 stackgen is on the PATH for 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/admin and https://<your-base-url>/api/mcp/user (see Cursor example).

Configure your IDE

Choosing a path

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

FlagDescription
claude mcp add stackgenStarts 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 userWrites the MCP server definition to user-level settings so it applies across Claude CLI sessions.
-- stackgen mcpSeparator 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
  1. Open the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows).
  2. Run MCP: Open User Configuration (wording may vary slightly by VS Code version).
  3. 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

ParameterTypeDescriptionExample
serversObjectRoot object for MCP server definitions in VS Code user MCP config.{ "stackgen-mcp": { ... } }
servers.stackgen-mcpObjectConfiguration for the StackGen STDIO server instance.See JSON above
servers.stackgen-mcp.typeStringTransport between IDE and MCP server. stdio uses a subprocess with stdin/stdout."stdio"
servers.stackgen-mcp.commandStringExecutable to launch."stackgen"
servers.stackgen-mcp.argsStringArguments for the command; together with command this starts MCP mode."mcp"
servers.stackgen-mcp.envObjectEnvironment variables passed to the MCP process.STACKGEN_TOKEN, STACKGEN_URL
servers.stackgen-mcp.env.STACKGEN_TOKENStringStackGen PAT. Replace <STACKGEN_TOKEN> with your real token.<STACKGEN_TOKEN>
servers.stackgen-mcp.env.STACKGEN_URLStringStackGen base URL for API calls from the CLI."https://cloud.stackgen.com"

See Use MCP servers in VS Code.

Cursor

Click to view

STDIO (single server)

  1. Open Settings, then Tools & MCP (or search for it).
  2. Use Add Custom MCP (or equivalent) so Cursor opens your MCP config (often mcp.json).
  3. Add:
{
"mcpServers": {
"stackgen-mcp": {
"type": "stdio",
"command": "stackgen",
"args": ["mcp"],
"env": {
"STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
"STACKGEN_URL": "https://cloud.stackgen.com"
}
}
}
}
  1. Replace <STACKGEN_TOKEN> with your PAT, adjust STACKGEN_URL, save, and restart Cursor if it does not pick up changes.

Flags (STDIO: stackgen-mcp)

ParameterTypeDescriptionExample
mcpServersObjectCursor root object for MCP server entries.{ "stackgen-mcp": { ... } }
stackgen-mcp (key)StringServer id shown in Cursor; you can rename it, but keep command/args correct.stackgen-mcp
typeStringstdio runs command as a subprocess for MCP.stdio
commandStringCLI binary on your PATH.stackgen
argsArrayArguments; mcp starts StackGen in MCP mode.["mcp"]
env.STACKGEN_TOKENStringPAT for StackGen.<STACKGEN_TOKEN>
env.STACKGEN_URLStringStackGen 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.

IDE-specific JSON

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 url to your base URL plus /api/mcp/admin or /api/mcp/user. If ${STACKGEN_URL} is not expanded by your environment, paste the full URL (no trailing slash on the host).
  • Auth: Set authorization to the literal word Bearer, 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.

ParameterTypeDescriptionExample
stackgen-admin / stackgen-user (keys)StringTwo server entries under mcpServers: Admin (Producer) and User (Consumer).stackgen-admin, stackgen-user
typeStringUse sse for remote MCP over HTTPS to StackGen.sse
urlString${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
headersObjectHTTP headers sent on MCP requests.authorization
headers.authorizationStringBearer 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 stackgen works 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.