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

StackBuilder MCP Integration

The Model Context Protocol (MCP) server allows AI tools like Claude and VS Code to communicate with and invoke functionalities from the StackGen CLI. Configuring the MCP server involves running the stackgen mcp command and connecting it to your AI tool.

This guide provides step-by-step instructions for Developers and DevOps to set up the StackGen MCP server on their local machines.

StackGen leverages MCP to:

  • Connect to Infrastructure State: Access real-time information about your existing infrastructure.
  • Integrate with External Tools: Connect to monitoring, logging, and management tools.
  • Provide Context-Aware Suggestions: Generate infrastructure recommendations based on current system state.
  • Enable Real-Time Collaboration: Share context between different AI agents and tools.

Key Benefits

The key benefits of integrating StackGen MCP Server are:

  • Real-Time Context: AI models can access current infrastructure state.
  • Tool Integration: Connect to external monitoring, logging, and management systems.
  • Standardized Interface: Consistent way to connect various data sources.
  • Security: Secure, authenticated access to sensitive infrastructure data.

Set Up the StackGen MCP Server

1. Configure the StackGen CLI

Click to view
  • Before setting up the MCP server, ensure you have the StackGen CLI installed and configured. This is the command-line tool that will run the MCP server.

  • The MCP server connects to the StackGen cloud service, so you will need:

    • A URL of your StackGen cloud account, for example, https://cloud.stackgen.com/,
    • A StackGen token for this cloud account. This token authenticates your requests and grants access to your StackGen account.

2. Connect to an AI Tool

Click to view

The MCP server acts as a bridge, allowing your AI tool to call StackGen's capabilities. Let's learn how to configure StackGen MCP Server across your IDEs in detail.

note
  • We recommend using stdio protocol to use the full fledged capabilities of stackgen.
  • If you have installed cloud2code, you will be able to access more tools.

Based on the users IDE, choose a path as shown below.

Claude

Click to view

To add the StackGen MCP server to Claude, use the claude mcp add stackgen command. From your Terminal or Command Prompt, run the following command to register StackGen as an MCP server accessible to Claude CLI:

claude mcp add stackgen \
--env STACKGEN_URL=https://cloud.stackgen.com \
--env STACKGEN_TOKEN="<STACKGEN_PAT>" \
-s user -- stackgen mcp

This command registers the StackGen server with Claude, providing the necessary environment variables for authentication.

Flags

FlagDescription
claude mcp add stackgenInitiates the process of adding a new MCP server named stackgen.
--env STACKGEN_URL=...Sets the STACKGEN_URL environment variable, specifying the endpoint for the StackGen cloud service.
--env STACKGEN_TOKEN="..."Sets the STACKGEN_TOKEN environment variable, which is crucial for authenticating your requests. For example, https://cloud.stackgen.com.

Replace <STACKGEN_PAT> with your actual token.
-s userThis flag saves the configuration to your user settings, making it available for all your Claude sessions.
-- stackgen mcpSpecifies the executable to run when the server is invoked. In this case, it's the stackgen mcp command.

Check out the Anthropic MCP CLI Guide to learn more.

VSCode

Click to view

Visual Studio Code provides a dedicated setting for configuring MCP servers. You can add the StackGen MCP server directly to your VS Code settings file. Follow these steps:

  1. Open your VS Code settings by pressing Ctrl + on windows or Cmd + on macOS.

  2. Search for MCP to find the relevant settings.

  3. Click Edit in settings.json to open the settings file directly.

  4. Add the following JSON configuration to your settings.json file:

    {
    "servers": {
    "stackgen-mcp": {
    "type": "stdio",
    "command": "stackgen",
    "args": "mcp",
    "env": {
    "STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
    "STACKGEN_URL": "https://cloud.stackgen.com"
    }
    }
    }
    }
  5. After saving the settings.json file, VS Code will automatically detect the new server and make StackGen's functionalities available in its AI-powered features, such as Copilot Chat.

Flags

ParameterTypeDescriptionExample / Default
serversObjectContainer object holding configuration for one or more MCP servers.{ "stackgen-mcp": { ... } }
servers.stackgen-mcpObjectConfiguration for the StackGen MCP server instance.{ "type": "stdio", ... }
servers.stackgen-mcp.typeStringSpecifies the communication protocol between the client and MCP server. "stdio" indicates communication over standard input/output."stdio"
servers.stackgen-mcp.commandStringThe command or executable name to run for the MCP server."stackgen"
servers.stackgen-mcp.argsStringThe argument(s) passed to the command to initiate the MCP server mode."mcp"
servers.stackgen-mcp.envObjectEnvironment variables required for the MCP server to run and authenticate.{ "STACKGEN_TOKEN": "...", "STACKGEN_URL": "..." }
servers.stackgen-mcp.env.STACKGEN_TOKENStringAuthentication token for StackGen access. Replace <STACKGEN_TOKEN> with your actual API or CLI token.<STACKGEN_TOKEN>
servers.stackgen-mcp.env.STACKGEN_URLStringBase URL for the StackGen Cloud or MCP endpoint."https://cloud.stackgen.com"

Check out Use MCP servers in VS Code documentation to learn more.

Cursor

Click to view

You can connect StackGen to Cursor as an MCP (Model Context Protocol) server to enable intelligent code context, project scaffolding, and AI-assisted workflows.

Follow these steps:

  1. Navigate to Cursor Settings > Tools & MCP.

  2. Under Installed MCP Servers, click ➕ Add Custom MCP.

  3. Paste the following snippet into your MCP configuration file:

    {
    "mcpServers": {
    "stackgen-mcp": {
    "type": "stdio",
    "command": "stackgen",
    "args": "mcp",
    "env": {
    "STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
    "STACKGEN_URL": "https://cloud.stackgen.com"
    }
    }
    }
  4. Replace <STACKGEN_TOKEN> with your actual StackGen token.

  5. Save and restart Cursor to apply the changes. The MCP server should now be active and ready for use with StackGen.

Flags

ParameterTypeDescriptionExample / Default
Server NameStringIdentifier for the MCP server in Cursor.stackgen-mcp
TypeStringCommunication protocol stdio means standard input/output.stdio
CommandStringCommand used to launch StackGen MCP.stackgen
ArgsStringArgument that triggers MCP mode in StackGen.mcp
STACKGEN_TOKENStringAuthentication token for StackGen access. Obtain this from your StackGen account.<STACKGEN_TOKEN>
STACKGEN_URLStringBase URL for StackGen Cloud or your self-hosted instance.https://cloud.stackgen.com

Check out the Cursor MCP Install Links documentation to learn more.

Troubleshooting

Click to view

Here are the most commonly encountered errors and steps to troubleshoot them:

  • Authentication Issues: Double-check that your STACKGEN_TOKEN is correct and hasn't expired against the right STACKGEN_URL domain.
  • Connection Problems: Ensure your firewall isn't blocking the connection and that the StackGen server URL is accessible from your network.
  • Tool Not Found: If your AI tool can't find the StackGen server, restart the application or the StackGen CLI to ensure the new configuration is loaded.