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 CLIinstalled 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.
- A URL of your StackGen cloud account, for example,
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.
- We recommend using
stdioprotocol 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
| Flag | Description |
|---|---|
claude mcp add stackgen | Initiates 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 user | This flag saves the configuration to your user settings, making it available for all your Claude sessions. |
-- stackgen mcp | Specifies 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:
-
Open your VS Code settings by pressing
Ctrl +on windows orCmd +on macOS. -
Search for MCP to find the relevant settings.
-
Click Edit in settings.json to open the settings file directly.
-
Add the following JSON configuration to your
settings.jsonfile:{
"servers": {
"stackgen-mcp": {
"type": "stdio",
"command": "stackgen",
"args": "mcp",
"env": {
"STACKGEN_TOKEN": "<STACKGEN_TOKEN>",
"STACKGEN_URL": "https://cloud.stackgen.com"
}
}
}
} -
After saving the
settings.jsonfile, VS Code will automatically detect the new server and make StackGen's functionalities available in its AI-powered features, such as Copilot Chat.
Flags
| Parameter | Type | Description | Example / Default |
|---|---|---|---|
servers | Object | Container object holding configuration for one or more MCP servers. | { "stackgen-mcp": { ... } } |
servers.stackgen-mcp | Object | Configuration for the StackGen MCP server instance. | { "type": "stdio", ... } |
servers.stackgen-mcp.type | String | Specifies the communication protocol between the client and MCP server. "stdio" indicates communication over standard input/output. | "stdio" |
servers.stackgen-mcp.command | String | The command or executable name to run for the MCP server. | "stackgen" |
servers.stackgen-mcp.args | String | The argument(s) passed to the command to initiate the MCP server mode. | "mcp" |
servers.stackgen-mcp.env | Object | Environment variables required for the MCP server to run and authenticate. | { "STACKGEN_TOKEN": "...", "STACKGEN_URL": "..." } |
servers.stackgen-mcp.env.STACKGEN_TOKEN | String | Authentication token for StackGen access. Replace <STACKGEN_TOKEN> with your actual API or CLI token. | <STACKGEN_TOKEN> |
servers.stackgen-mcp.env.STACKGEN_URL | String | Base 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:
-
Navigate to Cursor Settings > Tools & MCP.
-
Under Installed MCP Servers, click ➕ Add Custom MCP.
-
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"
}
}
} -
Replace
<STACKGEN_TOKEN>with your actual StackGen token. -
Save and restart Cursor to apply the changes. The MCP server should now be active and ready for use with StackGen.
Flags
| Parameter | Type | Description | Example / Default |
|---|---|---|---|
| Server Name | String | Identifier for the MCP server in Cursor. | stackgen-mcp |
| Type | String | Communication protocol stdio means standard input/output. | stdio |
| Command | String | Command used to launch StackGen MCP. | stackgen |
| Args | String | Argument that triggers MCP mode in StackGen. | mcp |
| STACKGEN_TOKEN | String | Authentication token for StackGen access. Obtain this from your StackGen account. | <STACKGEN_TOKEN> |
| STACKGEN_URL | String | Base 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_TOKENis correct and hasn't expired against the rightSTACKGEN_URLdomain. - 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.