This guide helps you set up the Go MCP Example server with VS Code and the MCP extension.
- VS Code installed on your system
- VS Code MCP extension installed
- Go 1.24+ installed on your system
- US Data Analytics Program API key
- Visit the US Data Analytics Program API documentation
- Sign up for an API key if you don't have one
- Make note of your API key for configuration
- Open VS Code
- Go to Extensions (Ctrl+Shift+X / Cmd+Shift+X)
- Search for "MCP" and install the official MCP extension
- Restart VS Code if required
-
Clone and build the project:
git clone https://github.com/rameshsunkara/go-mcp-example.git cd go-mcp-example make build -
Copy the VS Code configuration:
# Copy the MCP configuration to your .vscode folder cp docs/vscode/mcp.json .vscode/ cp docs/vscode/settings.json .vscode/ -
Update the configuration:
Edit
.vscode/mcp.jsonand update thecommandpath to point to your compiled binary.
When you open the project in VS Code, the MCP extension will prompt you for:
- US Data Gov API Key: Your API key for accessing analytics data
- US Data Gov Base URL: API base URL (defaults to official endpoint)
- Log Level: Logging verbosity (info, debug, warn, error)
- Log Format: Output format (json, text)
This file defines the MCP server configuration with input prompts:
VS Code workspace settings for optimal development experience:
{
"go.toolsManagement.checkForUpdates": "local",
"go.useLanguageServer": true,
"go.formatTool": "goimports",
"go.lintTool": "golangci-lint",
"go.testFlags": ["-v", "-race"],
"files.exclude": {
"**/.git": true,
"**/coverage.out": true,
"**/go-mcp-example": true
}
}Once configured, you'll have access to:
- get_report: Fetch analytics data from the Digital Analytics Program
- Interactive Prompts: Guided analytics workflows
- Resources: Documentation and examples
In VS Code with the MCP extension:
-
Fetch device statistics:
Use the get_report tool to get device usage data for the last 30 days -
Get traffic analysis:
Show me traffic trends using the analyze-traffic prompt -
Generate monthly report:
Create a monthly analytics report for January 2024
For development, you can also run the server directly:
Update your .vscode/mcp.json to point to the compiled binary:
{
"servers": {
"go-mcp-example-stdio": {
"command": "/full/path/to/go-mcp-example/go-mcp-example",
// ... rest of config
}
}
}For development iterations, you can use go run:
{
"servers": {
"go-mcp-example-dev": {
"type": "stdio",
"command": "go",
"args": ["run", "main.go"],
"cwd": "/path/to/go-mcp-example",
"env": {
// ... environment variables
}
}
}
}-
MCP extension not loading:
- Ensure the MCP extension is properly installed
- Restart VS Code
- Check the VS Code output panel for MCP logs
-
Server not starting:
- Verify the binary path in
mcp.json - Check that the binary is executable:
chmod +x go-mcp-example - Review environment variables
- Verify the binary path in
-
API key errors:
- Verify your API key is valid
- Check network connectivity
- Test the API key with a direct HTTP request
-
Build errors:
- Ensure Go 1.24+ is installed:
go version - Run
go mod tidyto resolve dependencies - Check for any compilation errors:
make build
- Ensure Go 1.24+ is installed:
To enable debug logging:
- Set the log level to "debug" when prompted by VS Code
- Or manually edit your environment in
mcp.json:
{
"env": {
"LOG_LEVEL": "debug",
// ... other vars
}
}- Check the VS Code Output panel
- Select "MCP" from the dropdown to see MCP-specific logs
- Look for server startup messages and any error details
You can extend the mcp.json file to add more configuration options:
{
"inputs": [
// ... existing inputs
{
"type": "promptString",
"id": "custom-setting",
"description": "Your custom setting",
"default": "default-value"
}
]
}You can run multiple instances with different configurations:
{
"servers": {
"go-mcp-example-prod": {
"type": "stdio",
"command": "/path/to/binary",
// ... production config
},
"go-mcp-example-dev": {
"type": "stdio",
"command": "go",
"args": ["run", "main.go"],
// ... development config
}
}
}- Check the main README.md for detailed documentation
- Review the OpenAPI specification for API details
- Consult the Claude Desktop setup guide for comparison
- Create an issue on the project repository for bugs or feature requests
{ "inputs": [ { "type": "promptString", "id": "us-data-gov-api-key", "description": "US Data Gov API Key", "password": true }, // ... more inputs ], "servers": { "go-mcp-example-stdio": { "type": "stdio", "command": "/path/to/go-mcp-example/go-mcp-example", "env": { "API_KEY": "${input:us-data-gov-api-key}", "API_BASE_URL": "${input:us-data-gov-base-url}", "LOG_LEVEL": "${input:log_level}", "LOG_FORMAT": "${input:log_format}" } } } }