# MCP Go Server
[](https://golang.org)
[](LICENSE)
[](https://github.com/inja-online/golang-mcp/releases)
[](https://github.com/inja-online/golang-mcp/actions)
[](https://github.com/inja-online/golang-mcp/graphs/contributors)
[](CHANGELOG.md)
MCP Go Server is a Model Context Protocol (MCP) server implementation designed to provide AI assistants with comprehensive tools for executing, optimizing, and managing Go projects. The project acts as a bridge between AI assistants (like Claude) and the Go runtime, enabling AI to interact with and control Go-based development workflows.
## Table of Contents
- [Quick Start](#quick-start)
- [Features](#features)
- [Quick Reference](#quick-reference)
- [Prerequisites](#prerequisites)
- [Installation Methods](#installation-methods)
- [Platform-Specific Guides](#platform-specific-guides) (36 platforms - click to expand)
- [Configuration](#configuration)
- [Troubleshooting](#troubleshooting) (click to expand)
- [FAQ](#faq)
- [Available Tools](#available-tools) (click to expand for detailed docs)
- [Code Execution Tools](#code-execution-tools)
- [Go Tools](#go-tools)
- [Optimization Tools](#optimization-tools)
- [Server Management Tools](#server-management-tools)
- [Package Documentation Tools](#package-documentation-tools)
- [LSP Tools](#lsp-tools)
- [Available Resources](#available-resources)
- [Available Prompts](#available-prompts)
- [Usage Examples](#usage-examples) (click to expand)
- [Resources Usage](#resources-usage)
- [Advanced Patterns](#advanced-patterns) (click to expand)
- [Security Considerations](#security-considerations)
- [License](#license)
- [Contributing](#contributing) (see [CONTRIBUTING.md](CONTRIBUTING.md) for development guide)
- [Changelog](#changelog)
## Quick Start
Choose your platform to get started quickly:
### Popular Platforms
- **[Claude Desktop](#1-claude-desktop)** - Most popular desktop app
- **[Cursor](#2-cursor)** - AI-powered code editor
- **[VS Code](#3-vs-code)** - Popular code editor with MCP support
- **[Docker](#27-docker)** - Container-based installation
- **[Pre-built Binaries](#using-pre-built-binaries)** - Direct binary download
### Installation Methods
1. **[Go Install](#using-go-install)** - Install via Go toolchain (recommended)
2. **[From Source](#from-source)** - Build from GitHub repository
3. **[Pre-built Binaries](#using-pre-built-binaries)** - Download ready-made binaries
4. **[Docker](#27-docker)** - Use containerized version
### What You Need First
- **Go 1.24 or higher** - Check with `go version`
- **Git** - For cloning the repository (if building from source)
### Quick Reference Tables
#### Platform Compatibility
| Platform | macOS | Windows | Linux | Difficulty |
|----------|-------|---------|-------|------------|
| Claude Desktop | ✅ | ✅ | ✅ | ⭐ Easy |
| Cursor | ✅ | ✅ | ✅ | ⭐ Easy |
| VS Code | ✅ | ✅ | ✅ | ⭐ Easy |
| Docker | ✅ | ✅ | ✅ | ⭐⭐ Medium |
| JetBrains IDEs | ✅ | ✅ | ✅ | ⭐⭐ Medium |
| Windsurf | ✅ | ✅ | ✅ | ⭐ Easy |
| Zed | ✅ | ✅ | ✅ | ⭐ Easy |
#### Installation Method Comparison
| Method | Speed | Requires Go | Requires Docker | Best For |
|--------|-------|-------------|-----------------|----------|
| Go Install | ⚡ Fast | ✅ Yes | ❌ No | Most users |
| Pre-built Binaries | ⚡ Fast | ❌ No | ❌ No | No Go installed |
| From Source | 🐌 Slower | ✅ Yes | ❌ No | Development |
| Docker | ⚡ Fast | ❌ No | ✅ Yes | Containers |
#### Config File Locations by OS
| Platform | macOS | Windows | Linux |
|----------|-------|---------|-------|
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` | `%APPDATA%\Claude\claude_desktop_config.json` | `~/.config/Claude/claude_desktop_config.json` |
| VS Code | `~/.vscode/settings.json` or workspace `.vscode/settings.json` | `%APPDATA%\Code\User\settings.json` | `~/.config/Code/User/settings.json` |
| Cursor | `~/.cursor/settings.json` | `%APPDATA%\Cursor\User\settings.json` | `~/.config/Cursor/User/settings.json` |
#### Common Issues Quick Fix
| Issue | Quick Fix |
|-------|-----------|
| Command not found | Add to PATH: `export PATH=$PATH:$HOME/go/bin` |
| Permission denied | `chmod +x /path/to/mcp-go` |
| Config not working | Validate JSON, check path, restart client |
| Tools don't appear | Restart client, verify config, check logs |
| LSP not available | Install gopls: `go install golang.org/x/tools/gopls@latest` |
## Quick Reference
### Tools (22 total)
**Code Execution (1):**
- `go_run` - Execute Go files directly
**Go Operations (7):**
- `go_build` - Build Go packages
- `go_test` - Run tests with coverage
- `go_fmt` - Format Go code
- `go_mod` - Manage Go modules
- `go_doc` - Generate documentation
- `go_lint` - Lint Go code
- `go_cross_compile` - Cross-compile for different platforms
**Optimization (6):**
- `go_profile` - Generate performance profiles
- `go_trace` - Generate execution traces
- `go_benchmark` - Run benchmarks
- `go_race_detect` - Detect race conditions
- `go_memory_profile` - Generate memory profiles
- `go_optimize_suggest` - Get optimization suggestions
**Server Management (5):**
- `go_server_start` - Start background servers
- `go_server_stop` - Stop servers
- `go_server_list` - List running servers
- `go_server_logs` - Get server logs
- `go_server_status` - Get server status
**Package Documentation (3):**
- `go_pkg_docs` - Fetch package docs from go.dev
- `go_pkg_search` - Search for packages
- `go_pkg_examples` - Extract examples
**LSP Tools (5, optional - requires `ENABLE_LSP=true`):**
- `lsp_start_session` - Start LSP session
- `lsp_shutdown_session` - Shutdown LSP session
- `lsp_request` - Send LSP request
- `lsp_notify` - Send LSP notification
- `lsp_subscribe_diagnostics` - Subscribe to diagnostics
### Resources (8 total)
- `go://modules` - Go modules and dependencies
- `go://build-tags` - Build tags and constraints
- `go://tests` - Test files and benchmarks
- `go://workspace` - Workspace structure
- `go://pkg-docs/{path}` - Package documentation
- `go://tools` - List all available tools
- `go://prompts` - List all available prompts
- `go://resources` - List all available resources
### Prompts (7 total)
- `setup-go-project` - Project setup guide
- `write-go-tests` - Test writing template
- `optimize-go-performance` - Performance optimization guide
- `debug-go-issue` - Debugging guide
- `add-go-dependency` - Dependency management guide
- `go-code-review` - Code review checklist
- `go-server-deployment` - Deployment guide
## Features
- **22 Comprehensive Tools**: Code execution, Go operations, optimization, server management, package documentation, and optional LSP support
- **8 Discovery Resources**: Access Go modules, build tags, tests, workspace structure, and package documentation
- **7 Guided Prompts**: Step-by-step guides for project setup, testing, optimization, debugging, dependencies, code review, and deployment
- **Code Execution**: Execute Go files directly with `go run`
- **Go Operations**: Build, test, format, and manage Go modules
- **Optimization Tools**: Performance profiling, benchmarking, and race detection
- **Server Management**: Start, stop, and monitor long-running Go servers
- **Package Documentation**: Fetch package documentation from go.dev (pkg.go.dev)
- **Project Discovery**: Discover Go modules, build tags, test files, and workspace structure
- **LSP Support**: Optional Language Server Protocol integration (requires `ENABLE_LSP=true`)
- **Cross-Platform**: Support for Linux, macOS, and Windows
- **Cross-Compilation**: Build for different platforms and architectures
## Prerequisites
**Required:**
- **Go 1.24 or higher** - Check with `go version`
- **Git** - For cloning the repository (if building from source)
**✅ Verify Prerequisites:**
```bash
go version # Should show go1.24 or higher
git --version # Should show git version
```
## Installation Methods
Choose the installation method that works best for you:
| Method | Best For | Speed | Difficulty |
|--------|----------|-------|------------|
| **Go Install** | Most users | ⚡ Fast | ⭐ Easy |
| **Pre-built Binaries** | No Go needed | ⚡ Fast | ⭐ Easy |
| **From Source** | Development | 🐌 Slower | ⭐⭐ Medium |
| **Docker** | Containers | ⚡ Fast | ⭐⭐ Medium |
### Using Go Install
**✅ Recommended for most users**
**Steps:**
1. Run the install command:
```bash
go install github.com/inja-online/golang-mcp/cmd/mcp-go@latest
```
2. **Verify installation:**
```bash
mcp-go --version
```
**✅ Success:** You should see the version number (e.g., `mcp-go v0.0.1`)
**💡 Tip:** The binary will be installed to `$GOPATH/bin` or `$HOME/go/bin`. Make sure this is in your PATH.
**⚠️ Troubleshooting:**
- If `mcp-go` command not found, add `$HOME/go/bin` to your PATH
- On macOS/Linux: `export PATH=$PATH:$HOME/go/bin`
- On Windows: Add `%USERPROFILE%\go\bin` to your PATH
### From Source
**🔧 Best for development or custom builds**
**Steps:**
1. Clone the repository:
```bash
git clone https://github.com/inja-online/golang-mcp.git
cd golang-mcp
```
2. Build the project:
```bash
make build
```
3. **Verify installation:**
```bash
./bin/mcp-go --version
```
**✅ Success:** The binary will be in the `bin/` directory
**💡 Tip:** You can also use `go build -o mcp-go ./cmd/mcp-go` if you don't have `make`
### Using Pre-built Binaries
**✅ Fastest method - no Go installation needed**
**Steps:**
1. Download from [releases page](https://github.com/inja-online/golang-mcp/releases)
2. **For Linux/macOS:**
```bash
curl -L https://github.com/inja-online/golang-mcp/releases/latest/download/golang-mcp_Linux_x86_64.tar.gz | tar xz
sudo mv mcp-go /usr/local/bin/
```
3. **For Windows:**
- Download the `.zip` file for Windows
- Extract and move `mcp-go.exe` to a directory in your PATH (e.g., `C:\Program Files\mcp-go\`)
4. **Verify installation:**
```bash
mcp-go --version
```
**✅ Success:** You should see the version number
**💡 Tip:** Choose the binary that matches your OS and architecture (Linux/macOS/Windows, x86_64/arm64)
### Using Docker
**🔧 Best for containerized environments**
#### Pull from GitHub Container Registry
**Steps:**
1. Pull the image:
```bash
docker pull ghcr.io/inja-online/golang-mcp:latest
```
2. **Verify:**
```bash
docker images | grep golang-mcp
```
**✅ Success:** You should see the image listed
#### Build from Source
**Steps:**
1. Clone and build:
```bash
git clone https://github.com/inja-online/golang-mcp.git
cd golang-mcp
docker build -t mcp-go:latest .
```
2. **Verify:**
```bash
docker images | grep mcp-go
```
**✅ Success:** You should see the image listed
#### Run with Docker
**Basic usage:**
```bash
docker run -it --rm \
-v $(pwd):/workspace \
-w /workspace \
mcp-go:latest
```
**Using docker-compose:**
```bash
docker-compose up
```
#### Docker Compose Configuration
The project includes a `docker-compose.yml` for local development:
**Commands:**
```bash
docker-compose up # Start the server
docker-compose up --build # Build and start
docker-compose up -d # Run in detached mode
docker-compose logs -f # View logs
docker-compose down # Stop the server
```
**✅ Success:** Server should start without errors
**The Docker image includes:**
- Alpine Linux base for minimal size
- Go runtime environment
- Pre-configured working directory
- Environment variable support
## Configuration
**🔧 Configure MCP Go Server** using environment variables or config file settings.
The server can be configured using environment variables:
```bash
export DISABLE_NOTIFICATIONS=true # Disable permission prompts
export DEBUG_MCP=true # Enable debug logging
export ENABLE_LSP=true # Enable LSP tools (optional)
export GOROOT=/path/to/go # Custom GOROOT
export GOPATH=/path/to/gopath # Custom GOPATH
export GOOS=linux # Target OS for cross-compilation
export GOARCH=amd64 # Target architecture
export GOPROXY=https://proxy.golang.org # Go proxy URL
```
### Configuration Options
| Variable | Type | Default | Description |
|----------|------|---------|-------------|
| **DISABLE_NOTIFICATIONS** | boolean | `false` | Set to `true` to disable permission prompts for command execution |
| **DEBUG_MCP** | boolean | `false` | Set to `true` to enable debug logging (useful for troubleshooting) |
| **ENABLE_LSP** | boolean | `false` | Set to `true` to enable LSP tools. Requires gopls in PATH |
| **GOROOT** | string | auto-detected | Custom Go root directory |
| **GOPATH** | string | default | Custom Go workspace path |
| **GOOS** | string | current OS | Target OS for cross-compilation |
| **GOARCH** | string | current arch | Target architecture for cross-compilation |
| **GOPROXY** | string | `https://proxy.golang.org` | Go module proxy URL |
**What this means:**
- **DISABLE_NOTIFICATIONS**: Prevents permission prompts (useful for automation)
- **DEBUG_MCP**: Shows detailed logs (helpful when troubleshooting)
- **ENABLE_LSP**: Enables Language Server Protocol tools (requires `gopls` installed)
- **GOROOT/GOPATH**: Override Go installation paths (usually auto-detected)
- **GOOS/GOARCH**: Set target platform for cross-compilation
- **GOPROXY**: Change where Go fetches modules from
### Common Configuration Examples
**💡 Development with LSP support:**
```bash
export DEBUG_MCP=true
export ENABLE_LSP=true
export DISABLE_NOTIFICATIONS=true
```
**✅ Production build configuration:**
```bash
export DISABLE_NOTIFICATIONS=true
export GOOS=linux
export GOARCH=amd64
export GOPROXY=https://proxy.golang.org
```
**🔧 Custom Go installation:**
```bash
export GOROOT=/usr/local/go
export GOPATH=$HOME/go
```
**⚠️ Note:** Environment variables set in your shell need to be passed to your MCP client's config file `env` section for them to take effect.
## Platform-Specific Guides
Configure MCP Go Server for your platform. Each guide includes step-by-step instructions, config file locations, and verification steps.
### Quick Platform Reference
| Platform | Config Location | Difficulty |
|----------|----------------|------------|
| Claude Desktop | `~/Library/Application Support/Claude/claude_desktop_config.json` (macOS)
`%APPDATA%\Claude\claude_desktop_config.json` (Windows) | ⭐ Easy |
| Cursor | Settings → MCP Servers | ⭐ Easy |
| VS Code | `.vscode/settings.json` or User Settings | ⭐ Easy |
| Docker | `docker-compose.yml` or command line | ⭐⭐ Medium |
1. Claude Desktop - ⭐ Easy - Most popular desktop app
**Prerequisites:**
- Claude Desktop installed
- `mcp-go` binary installed (see [Installation Methods](#installation-methods))
**Steps:**
1. **Find your config file location:**
- **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
- **Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
- **Linux:** `~/.config/Claude/claude_desktop_config.json`
2. **Open or create the config file**
3. **Add the MCP server configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
4. **Update the command path:**
- Replace `/usr/local/bin/mcp-go` with your actual `mcp-go` path
- Find it with: `which mcp-go` (macOS/Linux) or `where mcp-go` (Windows)
5. **Restart Claude Desktop**
**✅ Verify:**
- Open Claude Desktop
- Check that MCP tools are available
- Try asking Claude to run a Go command
**⚠️ Troubleshooting:**
- If tools don't appear, check the config file JSON is valid
- Verify the binary path is correct
- Check Claude Desktop logs for errors
2. Cursor - ⭐ Easy - AI-powered code editor
**Prerequisites:**
- Cursor installed
- `mcp-go` binary installed
**Steps:**
1. **Open Cursor Settings:**
- Press `Cmd+,` (macOS) or `Ctrl+,` (Windows/Linux)
- Or: Cursor → Settings → Settings
2. **Navigate to MCP Servers:**
- Search for "MCP" in settings
- Or go to: Settings → Features → MCP Servers
3. **Add server configuration:**
- Click "Add Server" or edit settings JSON
- Add configuration:
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
4. **Update the command path** to match your installation
5. **Reload Cursor** (restart or reload window)
**✅ Verify:**
- Open a Go file
- Check that MCP tools are available in the command palette
- Try using Go-related AI features
3. VS Code - ⭐ Easy - Popular code editor with MCP support
**Prerequisites:**
- VS Code with MCP extension installed
- `mcp-go` binary installed
**Steps:**
1. **Choose configuration location:**
- **Workspace:** `.vscode/settings.json` (project-specific)
- **User:** User Settings JSON (global)
2. **Open settings JSON:**
- Press `Cmd+Shift+P` (macOS) or `Ctrl+Shift+P` (Windows/Linux)
- Type "Preferences: Open Settings (JSON)"
- Or edit `.vscode/settings.json` in your workspace
3. **Add MCP server configuration:**
```json
{
"mcp.servers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
4. **Update the command path**
5. **Reload VS Code window**
**✅ Verify:**
- Check Output panel for MCP server messages
- Verify Go environment: `go version` in integrated terminal
- Test tools: Try calling `go_fmt` or `go_test`
**💡 Tip:** For workspace settings, create `.vscode/settings.json` in your project root
4. Cline (VS Code Extension) - ⭐ Easy - VS Code extension for AI coding
**Prerequisites:**
- VS Code with Cline extension installed
- `mcp-go` binary installed
**Steps:**
1. **Install Cline extension** from VS Code marketplace
2. **Open Cline settings:**
- Go to: Settings → Extensions → Cline
- Or edit settings JSON
3. **Add MCP server:**
```json
{
"cline.mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
4. **Update command path and reload**
**✅ Verify:** Cline should recognize MCP Go tools
5. Windsurf - ⭐ Easy - AI-powered IDE
**Prerequisites:**
- Windsurf installed
- `mcp-go` binary installed
**Steps:**
1. **Open Windsurf Settings:**
- Go to Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
3. **Update path and restart Windsurf**
**✅ Verify:** MCP tools available in Windsurf
6. Zed - ⭐ Easy - Modern code editor
**Prerequisites:**
- Zed installed
- `mcp-go` binary installed
**Steps:**
1. **Open Zed Settings:**
- `Cmd+,` (macOS) or `Ctrl+,` (Windows/Linux)
2. **Navigate to MCP configuration:**
- Settings → Features → MCP
3. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
4. **Update path and restart Zed**
**✅ Verify:** MCP integration working
7. JetBrains AI Assistant - ⭐⭐ Medium - Works with all JetBrains IDEs
**Prerequisites:**
- JetBrains IDE with AI Assistant enabled
- `mcp-go` binary installed
**Steps:**
1. **Open IDE Settings:**
- Go to: Settings/Preferences → Tools → AI Assistant → MCP Servers
2. **Add MCP server:**
- Click "Add" or edit configuration
- Add:
```json
{
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
```
3. **Update path and restart IDE**
**✅ Verify:** AI Assistant can use Go tools
**💡 Tip:** Works with IntelliJ IDEA, GoLand, WebStorm, PyCharm, etc.
8. Perplexity Desktop - ⭐ Easy - Desktop AI assistant
**Prerequisites:**
- Perplexity Desktop installed
- `mcp-go` binary installed
**Steps:**
1. **Open Perplexity Settings:**
- Settings → Integrations → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Perplexity can access Go tools
9. Amazon Q Developer CLI - ⭐ Easy - AWS AI coding assistant CLI
**Prerequisites:**
- Amazon Q Developer CLI installed
- `mcp-go` binary installed
**Steps:**
1. **Create or edit config file:**
- Location: `~/.aws-q/config.json` or `%USERPROFILE%\.aws-q\config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Run `aws-q` commands with Go support
10. Smithery - ⭐ Easy - MCP server management tool
**Prerequisites:**
- Smithery installed
- `mcp-go` binary installed
**Steps:**
1. **Open Smithery configuration:**
- Edit `~/.smithery/config.json` or use Smithery UI
2. **Add server:**
```json
{
"servers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart Smithery**
**✅ Verify:** Server appears in Smithery
11. Claude Code CLI - ⭐ Easy - Command-line Claude interface
**Prerequisites:**
- Claude Code CLI installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config file:**
- Location: `~/.claude-code/config.json`
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** CLI can use Go tools
12. Amp - ⭐ Easy - AI coding assistant
**Prerequisites:**
- Amp installed
- `mcp-go` binary installed
**Steps:**
1. **Open Amp Settings:**
- Settings → MCP Servers
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Amp integration working
13. Warp Terminal - ⭐ Easy - Modern terminal with AI
**Prerequisites:**
- Warp Terminal installed
- `mcp-go` binary installed
**Steps:**
1. **Open Warp Settings:**
- `Cmd+,` (macOS) or `Ctrl+,` (Windows/Linux)
2. **Navigate to AI → MCP Servers**
3. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
4. **Update path and restart Warp**
**✅ Verify:** AI features in Warp can use Go tools
14. Copilot Coding Agent - ⭐ Easy - GitHub Copilot agent
**Prerequisites:**
- Copilot Coding Agent installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.copilot/config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Copilot agent can use Go tools
15. Copilot CLI - ⭐ Easy - GitHub Copilot command line
**Prerequisites:**
- GitHub Copilot CLI installed
- `mcp-go` binary installed
**Steps:**
1. **Configure Copilot CLI:**
- Edit `~/.github/copilot/config.json`
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** CLI commands work with Go
16. LM Studio - ⭐ Easy - Local LLM interface
**Prerequisites:**
- LM Studio installed
- `mcp-go` binary installed
**Steps:**
1. **Open LM Studio Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** LM Studio can use Go tools
17. Visual Studio 2022 - ⭐⭐ Medium - Microsoft IDE
**Prerequisites:**
- Visual Studio 2022 with MCP extension
- `mcp-go` binary installed
**Steps:**
1. **Install MCP extension** for Visual Studio 2022
2. **Open Tools → Options → MCP Servers**
3. **Add server:**
- Name: `mcp-go`
- Command: Path to `mcp-go.exe`
- Args: (empty)
4. **Save and restart Visual Studio**
**✅ Verify:** MCP tools available in Visual Studio
18. Roo Code - ⭐ Easy - AI coding assistant
**Prerequisites:**
- Roo Code installed
- `mcp-go` binary installed
**Steps:**
1. **Open Roo Code Settings:**
- Settings → MCP Configuration
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Roo Code integration working
19. Gemini CLI - ⭐ Easy - Google Gemini command line
**Prerequisites:**
- Gemini CLI installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.gemini/config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Gemini CLI can use Go tools
20. Qwen Coder - ⭐ Easy - AI coding assistant
**Prerequisites:**
- Qwen Coder installed
- `mcp-go` binary installed
**Steps:**
1. **Open Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Qwen Coder integration working
21. Opencode - ⭐ Easy - Open-source AI coding tool
**Prerequisites:**
- Opencode installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.opencode/config.json`
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Opencode can use Go tools
22. OpenAI Codex - ⭐ Easy - OpenAI coding assistant
**Prerequisites:**
- OpenAI Codex access
- `mcp-go` binary installed
**Steps:**
1. **Configure Codex:**
- Edit `~/.openai/codex/config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Codex integration working
23. Kiro - ⭐ Easy - AI coding assistant
**Prerequisites:**
- Kiro installed
- `mcp-go` binary installed
**Steps:**
1. **Open Kiro Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Kiro can use Go tools
24. Trae - ⭐ Easy - AI development tool
**Prerequisites:**
- Trae installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.trae/config.json`
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Trae integration working
25. Bun Runtime - ⭐ Easy - JavaScript runtime with MCP support
**Prerequisites:**
- Bun installed
- `mcp-go` binary installed
**Steps:**
1. **Create MCP config:**
- Location: `~/.bun/mcp/config.json`
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Bun can use MCP Go server
26. Deno Runtime - ⭐ Easy - JavaScript/TypeScript runtime
**Prerequisites:**
- Deno installed
- `mcp-go` binary installed
**Steps:**
1. **Configure Deno MCP:**
- Edit `~/.deno/mcp/config.json`
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Deno MCP integration working
27. Docker - ⭐⭐ Medium - Container-based installation
**Prerequisites:**
- Docker installed
- Docker Compose (optional, for easier management)
**Steps:**
1. **Pull the image:**
```bash
docker pull ghcr.io/inja-online/golang-mcp:latest
```
2. **Run the container:**
```bash
docker run -it --rm \
-v $(pwd):/workspace \
-w /workspace \
ghcr.io/inja-online/golang-mcp:latest
```
3. **Or use docker-compose:**
- Create `docker-compose.yml`:
```yaml
version: '3.8'
services:
mcp-go:
image: ghcr.io/inja-online/golang-mcp:latest
volumes:
- .:/workspace
working_dir: /workspace
stdin_open: true
tty: true
```
4. **Start with docker-compose:**
```bash
docker-compose up
```
**✅ Verify:**
```bash
docker run --rm ghcr.io/inja-online/golang-mcp:latest mcp-go --version
```
**💡 Tip:** Use volumes to mount your Go projects into the container
28. Desktop Extension (.mcpb) - ⭐ Easy - MCP bundle format for easy installation
**Prerequisites:**
- MCP-compatible client that supports `.mcpb` files
**Steps:**
1. **Download the .mcpb file** from releases
2. **Install the bundle:**
- Double-click the `.mcpb` file, or
- Use your MCP client's "Install Bundle" feature
3. **Follow client-specific installation prompts**
**✅ Verify:** Bundle appears in your MCP client's server list
**💡 Tip:** `.mcpb` files are self-contained bundles with all dependencies
29. Windows (Detailed) - ⭐ Easy - Complete Windows installation guide
**Prerequisites:**
- Windows 10/11
- Go 1.24+ installed (optional, for building from source)
**Steps:**
1. **Download Windows binary:**
- Go to [releases page](https://github.com/inja-online/golang-mcp/releases)
- Download `golang-mcp_Windows_x86_64.zip`
2. **Extract the archive:**
- Right-click → Extract All
- Or use: `Expand-Archive golang-mcp_Windows_x86_64.zip`
3. **Move to a permanent location:**
- Create folder: `C:\Program Files\mcp-go\`
- Move `mcp-go.exe` there
4. **Add to PATH:**
- Open System Properties → Environment Variables
- Edit "Path" variable
- Add: `C:\Program Files\mcp-go`
- Click OK on all dialogs
5. **Verify installation:**
- Open PowerShell or Command Prompt
- Run: `mcp-go --version`
**✅ Success:** You should see the version number
**⚠️ Troubleshooting:**
- If command not found, restart your terminal after adding to PATH
- Check PATH with: `$env:PATH` (PowerShell) or `echo %PATH%` (CMD)
- Verify file exists: `Test-Path "C:\Program Files\mcp-go\mcp-go.exe"`
30. BoltAI - ⭐ Easy - AI coding assistant
**Prerequisites:**
- BoltAI installed
- `mcp-go` binary installed
**Steps:**
1. **Open BoltAI Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** BoltAI integration working
31. Rovo Dev CLI - ⭐ Easy - Development CLI tool
**Prerequisites:**
- Rovo Dev CLI installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.rovo/config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Rovo CLI can use Go tools
32. Zencoder - ⭐ Easy - AI code generation tool
**Prerequisites:**
- Zencoder installed
- `mcp-go` binary installed
**Steps:**
1. **Open Zencoder Settings:**
- Settings → MCP Configuration
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Zencoder can use Go tools
33. Qodo Gen - ⭐ Easy - AI code generator
**Prerequisites:**
- Qodo Gen installed
- `mcp-go` binary installed
**Steps:**
1. **Edit configuration:**
- Location: `~/.qodo/config.json`
2. **Add MCP server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Qodo Gen integration working
34. Factory - ⭐ Easy - AI development platform
**Prerequisites:**
- Factory installed
- `mcp-go` binary installed
**Steps:**
1. **Open Factory Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Factory can use Go tools
35. Crush - ⭐ Easy - AI coding assistant
**Prerequisites:**
- Crush installed
- `mcp-go` binary installed
**Steps:**
1. **Edit config:**
- Location: `~/.crush/config.json`
2. **Add server:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path**
**✅ Verify:** Crush integration working
36. Augment Code - ⭐ Easy - AI code augmentation tool
**Prerequisites:**
- Augment Code installed
- `mcp-go` binary installed
**Steps:**
1. **Open Augment Code Settings:**
- Settings → MCP Servers
2. **Add configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
3. **Update path and restart**
**✅ Verify:** Augment Code can use Go tools
### Standalone Usage
**Run MCP Go Server directly:**
```bash
mcp-go
```
The server communicates via stdio (standard input/output) using JSON-RPC 2.0 protocol.
**💡 Tip:** Useful for testing or custom integrations
Troubleshooting - Common issues and their solutions
Common issues and their solutions. Use the symptoms to find your problem quickly.
### Installation Issues
#### ❌ "Command not found: mcp-go"
**Symptoms:**
- Terminal says `mcp-go: command not found`
- Binary exists but can't be run
**Solutions:**
1. **Check if binary is installed:**
```bash
which mcp-go # macOS/Linux
where mcp-go # Windows
```
2. **Add to PATH:**
- **macOS/Linux:** Add `$HOME/go/bin` to PATH
```bash
export PATH=$PATH:$HOME/go/bin
```
- **Windows:** Add `%USERPROFILE%\go\bin` to PATH in Environment Variables
3. **Verify PATH:**
```bash
echo $PATH # macOS/Linux
echo %PATH% # Windows
```
**✅ Success:** `mcp-go --version` should work
#### ❌ "Permission denied"
**Symptoms:**
- `Permission denied` error when running `mcp-go`
**Solutions:**
1. **Make binary executable:**
```bash
chmod +x /path/to/mcp-go
```
2. **Check file permissions:**
```bash
ls -l /path/to/mcp-go
```
3. **On Windows:** Run as Administrator if needed
#### ❌ "Go version too old"
**Symptoms:**
- Error about Go version
- Requires Go 1.24+
**Solutions:**
1. **Check Go version:**
```bash
go version
```
2. **Update Go:**
- Visit [golang.org](https://golang.org/dl/)
- Download latest version
- Install and restart terminal
### Configuration Issues
#### ❌ "Config file not found"
**Symptoms:**
- Platform can't find config file
- Server doesn't start
**Solutions:**
1. **Create config file** if it doesn't exist
2. **Check file location** (see platform-specific guides)
3. **Verify JSON syntax** is valid
4. **Check file permissions** (readable)
#### ❌ "Invalid JSON in config"
**Symptoms:**
- Config file has syntax errors
- Server fails to start
**Solutions:**
1. **Validate JSON:**
- Use online JSON validator
- Or: `python -m json.tool config.json`
2. **Common mistakes:**
- Missing commas
- Trailing commas
- Unclosed brackets
3. **Fix and restart** your MCP client
#### ❌ "Binary path incorrect"
**Symptoms:**
- Server can't find `mcp-go` binary
- Path errors in logs
**Solutions:**
1. **Find correct path:**
```bash
which mcp-go # macOS/Linux
where mcp-go # Windows
```
2. **Use absolute path** in config (not relative)
3. **On Windows:** Use forward slashes or double backslashes:
```json
"command": "C:/Program Files/mcp-go/mcp-go.exe"
// or
"command": "C:\\Program Files\\mcp-go\\mcp-go.exe"
```
### Platform-Specific Issues
#### ❌ Claude Desktop: Tools don't appear
**Symptoms:**
- Config file looks correct
- Tools not available in Claude
**Solutions:**
1. **Restart Claude Desktop** completely
2. **Check config file location:**
- macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
- Windows: `%APPDATA%\Claude\claude_desktop_config.json`
3. **Validate JSON** syntax
4. **Check Claude Desktop logs** for errors
5. **Verify binary path** is correct and executable
#### ❌ VS Code: MCP extension not working
**Symptoms:**
- MCP extension installed but not working
- No tools available
**Solutions:**
1. **Check extension is enabled**
2. **Reload VS Code window:** `Cmd+Shift+P` → "Reload Window"
3. **Check Output panel** for MCP messages
4. **Verify settings JSON** syntax
5. **Try workspace settings** instead of user settings
#### ❌ Docker: Container won't start
**Symptoms:**
- Docker container exits immediately
- Permission errors
**Solutions:**
1. **Check Docker is running:**
```bash
docker ps
```
2. **Check image exists:**
```bash
docker images | grep golang-mcp
```
3. **Check volume mounts:**
- Verify paths are correct
- Check permissions on mounted directories
4. **View logs:**
```bash
docker logs
```
### Runtime Issues
#### ❌ "Go command not found"
**Symptoms:**
- MCP server can't find `go` command
- Go tools fail
**Solutions:**
1. **Verify Go is installed:**
```bash
go version
```
2. **Check PATH includes Go:**
```bash
echo $PATH # Should include Go bin directory
```
3. **Set GOROOT** if needed:
```bash
export GOROOT=/usr/local/go
```
#### ❌ "LSP tools not available"
**Symptoms:**
- LSP tools don't appear
- `ENABLE_LSP=true` but no tools
**Solutions:**
1. **Check gopls is installed:**
```bash
which gopls
go install golang.org/x/tools/gopls@latest
```
2. **Verify ENABLE_LSP is set:**
```bash
echo $ENABLE_LSP # Should be "true"
```
3. **Restart MCP server** after setting environment variable
#### ❌ "Permission prompts keep appearing"
**Symptoms:**
- Permission prompts for every command
- Want to disable them
**Solutions:**
1. **Set DISABLE_NOTIFICATIONS:**
```bash
export DISABLE_NOTIFICATIONS=true
```
2. **Add to config file** `env` section:
```json
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
```
3. **Restart MCP client**
### Performance Issues
#### ❌ "Server is slow"
**Symptoms:**
- Commands take too long
- Timeouts
**Solutions:**
1. **Enable debug logging:**
```bash
export DEBUG_MCP=true
```
2. **Check system resources** (CPU, memory)
3. **Check Go proxy:**
```bash
go env GOPROXY
```
4. **Try different GOPROXY:**
```bash
export GOPROXY=https://proxy.golang.org
```
### Getting More Help
**Still having issues?**
1. **Check logs:**
- Enable `DEBUG_MCP=true`
- Check platform-specific log locations
2. **Verify installation:**
```bash
mcp-go --version
go version
```
3. **Test standalone:**
```bash
echo '{"jsonrpc":"2.0","id":1,"method":"tools/list"}' | mcp-go
```
4. **Check GitHub Issues:**
- Search existing issues
- Create new issue with:
- Error messages
- Platform information
- Config file (sanitized)
- Debug logs
## FAQ
Common questions and quick answers.
### Installation
**Q: Do I need Go installed to use MCP Go Server?**
**A:** No. You can use pre-built binaries or Docker. Go is only needed if building from source.
**Q: Which installation method should I use?**
**A:**
- **Most users:** Go Install (easiest)
- **No Go installed:** Pre-built Binaries
- **Development:** From Source
- **Containers:** Docker
**Q: Can I install on Windows?**
**A:** Yes. Download the Windows binary from releases or use Go Install. See [Windows (Detailed)](#29-windows-detailed) guide.
**Q: Do I need to add mcp-go to PATH?**
**A:** Yes, if using Go Install or binaries. Docker doesn't need PATH setup.
### Configuration
**Q: Where is the config file?**
**A:** Depends on your platform. See [Platform-Specific Guides](#platform-specific-guides) for your platform's location.
**Q: Can I use environment variables?**
**A:** Yes. See [Configuration](#configuration) section for available variables.
**Q: Do I need to restart after changing config?**
**A:** Yes. Restart your MCP client (Claude Desktop, VS Code, etc.) after config changes.
**Q: Can I use multiple MCP servers?**
**A:** Yes. Add multiple entries in your `mcpServers` object.
### Platform Support
**Q: Does it work with [Platform X]?**
**A:** If your platform supports MCP protocol, it should work. See [Platform-Specific Guides](#platform-specific-guides) for setup instructions.
**Q: Can I use it in multiple IDEs?**
**A:** Yes. Configure it separately in each IDE's settings.
**Q: Does it work offline?**
**A:** Most features work offline. Package documentation tools require internet for fetching from go.dev.
### Features
**Q: What tools are available?**
**A:** 22 tools total. See [Quick Reference](#quick-reference) or [Available Tools](#available-tools) for complete list.
**Q: Do I need LSP support?**
**A:** Optional. Set `ENABLE_LSP=true` and install `gopls` if you want LSP tools.
**Q: Can I run Go tests?**
**A:** Yes. Use the `go_test` tool with various options for coverage, benchmarks, etc.
**Q: Can I build for different platforms?**
**A:** Yes. Use `go_cross_compile` tool to build for different OS/architectures.
### Troubleshooting
**Q: Tools don't appear in my client. What's wrong?**
**A:**
1. Check config file JSON is valid
2. Verify binary path is correct
3. Restart your MCP client
4. Check logs for errors
**Q: "Command not found" error?**
**A:** Add `mcp-go` to your PATH. See [Troubleshooting](#troubleshooting) section.
**Q: Permission prompts keep appearing?**
**A:** Set `DISABLE_NOTIFICATIONS=true` in your config or environment.
**Q: How do I enable debug logging?**
**A:** Set `DEBUG_MCP=true` environment variable or in config file.
### Development
**Q: Can I contribute?**
**A:** Yes! See [Contributing](#contributing) section. Pull requests welcome.
**Q: Where do I report bugs?**
**A:** Create an issue on GitHub with details about the problem.
**Q: How do I build from source?**
**A:** See [From Source](#from-source) in Installation Methods section.
**Q: Can I customize the server?**
**A:** Yes, if building from source. Fork the repository and modify as needed.
## Available Tools
**22 comprehensive tools** for Go development, testing, optimization, and management.
View detailed tool documentation
### Code Execution Tools
#### ✅ go_run
Execute a Go file directly using `go run`.
**Parameters:**
- `file` (string, required): Path to the Go file to run
- `args` ([]string, optional): Command line arguments to pass to the program
- `working_dir` (string, optional): Working directory for the command
- `env_vars` (map[string]string, optional): Additional environment variables
**Examples:**
Run a simple Go file:
```json
{
"name": "go_run",
"arguments": {
"file": "main.go"
}
}
```
Run with command line arguments:
```json
{
"name": "go_run",
"arguments": {
"file": "server.go",
"args": ["--port", "8080", "--host", "localhost"]
}
}
```
Run with environment variables:
```json
{
"name": "go_run",
"arguments": {
"file": "app.go",
"env_vars": {
"DEBUG": "true",
"LOG_LEVEL": "info"
}
}
}
```
### Go Tools
**🔧 7 tools** for building, testing, formatting, and managing Go code.
#### ✅ go_build
Build Go packages and dependencies with various build flags.
**Parameters:**
- `package` (string, optional): Package path to build (default: current directory)
- `output` (string, optional): Output file name
- `race` (bool, optional): Enable race detector
- `tags` ([]string, optional): Build tags
- `ldflags` (string, optional): Linker flags
- `trimpath` (bool, optional): Remove file system paths from executable
- `working_dir` (string, optional): Working directory
**Examples:**
Basic build:
```json
{
"name": "go_build",
"arguments": {
"output": "myapp"
}
}
```
Build with race detector:
```json
{
"name": "go_build",
"arguments": {
"output": "myapp",
"race": true
}
}
```
Build with build tags and version info:
```json
{
"name": "go_build",
"arguments": {
"output": "myapp",
"tags": ["production", "linux"],
"ldflags": "-X main.version=1.0.0 -X main.buildTime=$(date +%s)",
"trimpath": true
}
}
```
#### go_test
Run Go tests with coverage, benchmarks, and race detection.
**Parameters:**
- `package` (string, optional): Package path to test
- `cover` (bool, optional): Enable coverage analysis
- `cover_pkg` (string, optional): Packages to cover
- `bench` (bool, optional): Run benchmarks
- `race` (bool, optional): Enable race detector
- `verbose` (bool, optional): Verbose output
- `timeout` (string, optional): Test timeout
**Examples:**
Run all tests:
```json
{
"name": "go_test",
"arguments": {
"verbose": true
}
}
```
Run tests with coverage:
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"cover_pkg": "./..."
}
}
```
Run tests with benchmarks and race detection:
```json
{
"name": "go_test",
"arguments": {
"bench": true,
"race": true,
"timeout": "30s"
}
}
```
#### go_fmt
Format Go code using `go fmt`.
**Parameters:**
- `paths` ([]string, optional): Paths to format (default: current directory)
- `working_dir` (string, optional): Working directory
**Examples:**
Format current directory:
```json
{
"name": "go_fmt",
"arguments": {}
}
```
Format specific files:
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./cmd", "./internal"]
}
}
```
#### go_mod
Manage Go modules (init, tidy, download, vendor, get).
**Parameters:**
- `operation` (string, required): Module operation: init, tidy, download, vendor, get
- `module_path` (string, optional): Module path (for init or get)
- `packages` ([]string, optional): Package paths (for get)
- `working_dir` (string, optional): Working directory
**Examples:**
Initialize a new module:
```json
{
"name": "go_mod",
"arguments": {
"operation": "init",
"module_path": "github.com/user/project"
}
}
```
Tidy dependencies:
```json
{
"name": "go_mod",
"arguments": {
"operation": "tidy"
}
}
```
Add a dependency:
```json
{
"name": "go_mod",
"arguments": {
"operation": "get",
"packages": ["github.com/gin-gonic/gin@latest"]
}
}
```
Vendor dependencies:
```json
{
"name": "go_mod",
"arguments": {
"operation": "vendor"
}
}
```
#### go_doc
Generate documentation for Go packages.
**Parameters:**
- `package` (string, required): Package path
- `all` (bool, optional): Show all documentation
- `working_dir` (string, optional): Working directory
**Examples:**
View package documentation:
```json
{
"name": "go_doc",
"arguments": {
"package": "net/http"
}
}
```
View all documentation including unexported symbols:
```json
{
"name": "go_doc",
"arguments": {
"package": "./internal/utils",
"all": true
}
}
```
#### go_lint
Lint Go code using golangci-lint or go vet.
**Parameters:**
- `package` (string, optional): Package path to lint
- `linter` (string, optional): Linter to use: golangci-lint or vet (default: vet)
- `working_dir` (string, optional): Working directory
**Examples:**
Lint with go vet:
```json
{
"name": "go_lint",
"arguments": {
"package": "./..."
}
}
```
Lint with golangci-lint:
```json
{
"name": "go_lint",
"arguments": {
"linter": "golangci-lint",
"package": "./cmd"
}
}
```
#### go_cross_compile
Cross-compile Go code for different platforms.
**Parameters:**
- `package` (string, optional): Package path to build
- `output` (string, required): Output file name
- `goos` (string, required): Target OS (e.g., linux, darwin, windows)
- `goarch` (string, required): Target architecture (e.g., amd64, arm64)
- `working_dir` (string, optional): Working directory
**Examples:**
Build for Linux:
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp-linux",
"goos": "linux",
"goarch": "amd64"
}
}
```
Build for Windows:
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp.exe",
"goos": "windows",
"goarch": "amd64"
}
}
```
Build for macOS ARM:
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp-darwin-arm64",
"goos": "darwin",
"goarch": "arm64"
}
}
```
### Optimization Tools
**⚡ 6 tools** for profiling, benchmarking, and optimizing Go code performance.
#### ✅ go_profile
Generate performance profile using pprof.
**Parameters:**
- `type` (string, required): Profile type: cpu or mem
- `output` (string, required): Output profile file path
- `duration` (string, optional): Profile duration
- `package` (string, optional): Package to profile
- `working_dir` (string, optional): Working directory
**Examples:**
Generate CPU profile:
```json
{
"name": "go_profile",
"arguments": {
"type": "cpu",
"output": "cpu.prof"
}
}
```
Generate memory profile:
```json
{
"name": "go_profile",
"arguments": {
"type": "mem",
"output": "mem.prof",
"package": "./internal/handlers"
}
}
```
#### go_trace
Generate execution trace for Go programs.
**Parameters:**
- `output` (string, required): Output trace file path
- `package` (string, optional): Package to trace
- `working_dir` (string, optional): Working directory
**Example:**
```json
{
"name": "go_trace",
"arguments": {
"output": "trace.out",
"package": "./..."
}
}
```
#### go_benchmark
Run benchmarks and analyze results.
**Parameters:**
- `pattern` (string, optional): Benchmark pattern to match
- `count` (int, optional): Number of iterations
- `timeout` (string, optional): Benchmark timeout
- `package` (string, optional): Package to benchmark
- `working_dir` (string, optional): Working directory
**Examples:**
Run all benchmarks:
```json
{
"name": "go_benchmark",
"arguments": {}
}
```
Run specific benchmark pattern:
```json
{
"name": "go_benchmark",
"arguments": {
"pattern": "BenchmarkSort",
"count": 5
}
}
```
Run benchmarks with timeout:
```json
{
"name": "go_benchmark",
"arguments": {
"timeout": "10m",
"package": "./internal/cache"
}
}
```
#### go_race_detect
Detect race conditions in Go code.
**Parameters:**
- `package` (string, optional): Package to test
- `working_dir` (string, optional): Working directory
**Example:**
```json
{
"name": "go_race_detect",
"arguments": {
"package": "./..."
}
}
```
#### go_memory_profile
Generate memory profile for analysis.
**Parameters:**
- `output` (string, required): Output profile file path
- `package` (string, optional): Package to profile
- `working_dir` (string, optional): Working directory
**Example:**
```json
{
"name": "go_memory_profile",
"arguments": {
"output": "mem.prof",
"package": "./internal/processor"
}
}
```
#### go_optimize_suggest
Analyze code and provide optimization suggestions based on profiling and benchmarking.
**Parameters:**
- `package` (string, optional): Package to analyze
- `working_dir` (string, optional): Working directory
**Examples:**
Analyze current package:
```json
{
"name": "go_optimize_suggest",
"arguments": {}
}
```
Analyze specific package:
```json
{
"name": "go_optimize_suggest",
"arguments": {
"package": "./internal/processor"
}
}
```
This tool runs benchmarks and static analysis to provide optimization suggestions including:
- Benchmark results for performance baseline
- Static analysis issues from `go vet`
- General optimization recommendations
- Suggestions for race detection, profiling, and concurrency improvements
### Server Management Tools
**🚀 5 tools** for managing long-running Go servers in the background.
#### ✅ go_server_start
Start a long-running Go server in the background.
**Parameters:**
- `id` (string, required): Unique server ID
- `name` (string, required): Server name
- `command` (string, required): Command to run (usually 'go' or binary path)
- `args` ([]string, required): Command arguments
- `working_dir` (string, optional): Working directory
- `env_vars` (map[string]string, optional): Environment variables
- `log_size` (int, optional): Maximum log lines to keep (default: 1000)
#### go_server_stop
Stop a running server.
**Parameters:**
- `id` (string, required): Server ID
- `force` (bool, optional): Force kill the server (SIGKILL)
#### go_server_list
List all running servers.
#### go_server_logs
Get logs from a running server.
**Parameters:**
- `id` (string, required): Server ID
- `count` (int, optional): Number of recent log lines (0 for all)
#### go_server_status
Get detailed status of a server.
**Parameters:**
- `id` (string, required): Server ID
### Package Documentation Tools
**📚 3 tools** for discovering and exploring Go package documentation.
#### ✅ go_pkg_docs
Fetch package documentation from go.dev (pkg.go.dev). Returns package overview, functions, types, and examples.
**Parameters:**
- `package` (string, required): Package path (e.g., github.com/gin-gonic/gin, net/http)
- `version` (string, optional): Package version
**Examples:**
Fetch standard library documentation:
```json
{
"name": "go_pkg_docs",
"arguments": {
"package": "net/http"
}
}
```
Fetch third-party package documentation:
```json
{
"name": "go_pkg_docs",
"arguments": {
"package": "github.com/gin-gonic/gin",
"version": "v1.9.1"
}
}
```
The tool returns:
- Package overview and description
- List of functions with signatures and descriptions
- List of types with their kinds and descriptions
- Code examples (if available)
#### go_pkg_search
Search for packages on go.dev. Returns a list of matching package paths.
**Parameters:**
- `query` (string, required): Search query
**Examples:**
Search for HTTP routers:
```json
{
"name": "go_pkg_search",
"arguments": {
"query": "http router"
}
}
```
Search for database drivers:
```json
{
"name": "go_pkg_search",
"arguments": {
"query": "database driver postgres"
}
}
```
The tool returns a list of package paths matching your query, which you can then use with `go_pkg_docs` to review documentation.
#### go_pkg_examples
Extract examples from package documentation.
**Parameters:**
- `package` (string, required): Package path
- `version` (string, optional): Package version
**Examples:**
Extract examples from standard library:
```json
{
"name": "go_pkg_examples",
"arguments": {
"package": "net/http"
}
}
```
Extract examples from third-party package:
```json
{
"name": "go_pkg_examples",
"arguments": {
"package": "github.com/gin-gonic/gin",
"version": "v1.9.1"
}
}
```
### LSP Tools
**🔌 5 tools** for Language Server Protocol integration (optional).
> **⚠️ Note**: LSP tools are optional and require `ENABLE_LSP=true` environment variable to be set. These tools provide Language Server Protocol integration for advanced IDE features.
#### ✅ lsp_start_session
Start an LSP session for a workspace root URI.
**Parameters:**
- `root_uri` (string, required): Workspace root URI (file:// path)
- `gopls_path` (string, optional): Path to gopls binary (default: searches PATH)
- `args` ([]string, optional): Additional arguments for gopls
- `env` (map[string]string, optional): Environment variables for gopls
**Examples:**
Start session with default gopls:
```json
{
"name": "lsp_start_session",
"arguments": {
"root_uri": "file:///path/to/workspace"
}
}
```
Start session with custom gopls path:
```json
{
"name": "lsp_start_session",
"arguments": {
"root_uri": "file:///path/to/workspace",
"gopls_path": "/usr/local/bin/gopls",
"args": ["-rpc.trace"],
"env": {
"GOPATH": "/custom/gopath"
}
}
}
```
#### lsp_shutdown_session
Shutdown an LSP session for a workspace root URI.
**Parameters:**
- `root_uri` (string, required): Workspace root URI
**Example:**
```json
{
"name": "lsp_shutdown_session",
"arguments": {
"root_uri": "file:///path/to/workspace"
}
}
```
#### lsp_request
Send a request to an LSP session and wait for a result.
**Parameters:**
- `root_uri` (string, required): Workspace root URI
- `method` (string, required): LSP method name (e.g., "textDocument/hover", "textDocument/completion")
- `params` (object, optional): Request parameters
**Examples:**
Get hover information:
```json
{
"name": "lsp_request",
"arguments": {
"root_uri": "file:///path/to/workspace",
"method": "textDocument/hover",
"params": {
"textDocument": {
"uri": "file:///path/to/workspace/main.go"
},
"position": {
"line": 10,
"character": 5
}
}
}
}
```
Get code completion:
```json
{
"name": "lsp_request",
"arguments": {
"root_uri": "file:///path/to/workspace",
"method": "textDocument/completion",
"params": {
"textDocument": {
"uri": "file:///path/to/workspace/main.go"
},
"position": {
"line": 15,
"character": 20
}
}
}
}
```
#### lsp_notify
Send a notification to an LSP session (does not wait for response).
**Parameters:**
- `root_uri` (string, required): Workspace root URI
- `method` (string, required): LSP method name (e.g., "textDocument/didChange", "textDocument/didOpen")
- `params` (object, optional): Notification parameters
**Example:**
```json
{
"name": "lsp_notify",
"arguments": {
"root_uri": "file:///path/to/workspace",
"method": "textDocument/didOpen",
"params": {
"textDocument": {
"uri": "file:///path/to/workspace/main.go",
"languageId": "go",
"version": 1,
"text": "package main\n\nfunc main() {\n}"
}
}
}
}
```
#### lsp_subscribe_diagnostics
Subscribe to diagnostics published by an LSP session.
**Parameters:**
- `root_uri` (string, required): Workspace root URI
**Example:**
```json
{
"name": "lsp_subscribe_diagnostics",
"arguments": {
"root_uri": "file:///path/to/workspace"
}
}
```
This enables receiving diagnostic notifications (errors, warnings, etc.) from the LSP server for the specified workspace.
## Available Resources
**📦 8 discovery resources** for exploring your Go workspace and accessing package documentation.
### ✅ go://modules
List of Go modules and dependencies in the current workspace.
**Use for:** Understanding project dependencies, checking versions, planning updates
### ✅ go://build-tags
Build tags and constraints found in the project.
**Use for:** Finding platform-specific code, feature flags, conditional builds
### ✅ go://tests
List of test files and benchmarks in the project.
**Use for:** Discovering test coverage, finding benchmarks, understanding test structure
### ✅ go://workspace
Go workspace structure and configuration.
**Use for:** Understanding project layout, finding main packages, planning refactoring
### ✅ go://pkg-docs/{path}
Fetch package documentation from go.dev. Supports versioned paths (e.g., go://pkg-docs/encoding/json@v1.0.0).
**Use for:** Quick access to standard library docs, viewing third-party package documentation
### ✅ go://tools
List of all available tools with their names, descriptions, and parameter schemas. Use this resource to discover what tools are available in the MCP server.
**Use for:** Discovering available tools, understanding tool parameters, finding the right tool
### ✅ go://prompts
List of all available prompts with their names, descriptions, and arguments. Use this resource to discover what prompts are available for guided workflows.
**Use for:** Finding prompts for specific tasks, understanding prompt arguments, discovering workflows
### ✅ go://resources
List of all available resources with their URIs, names, and descriptions. Use this resource to discover what resources are available in the MCP server.
**Use for:** Understanding available resources, finding resource URIs, planning resource-based workflows
## Available Prompts
**💡 7 guided prompts** for step-by-step workflows and best practices.
Prompts provide guided workflows and step-by-step instructions for common Go development tasks. Each prompt accepts arguments to customize the guidance.
### ✅ setup-go-project
Guide for setting up a new Go project with module initialization, directory structure, and best practices.
**Arguments:**
- `project_name` (string, required): Name of the Go project to set up
- `module_path` (string, optional): Go module path (e.g., github.com/username/project)
**Use Cases:**
- Initializing a new Go project from scratch
- Setting up project structure following Go best practices
- Creating a proper module-based project
**Example:**
```json
{
"name": "setup-go-project",
"arguments": {
"project_name": "my-api",
"module_path": "github.com/user/my-api"
}
}
```
This prompt guides you through:
1. Initializing Go module
2. Creating standard directory structure (cmd/, internal/, pkg/, etc.)
3. Setting up README and .gitignore
4. Creating initial main.go
5. Running go mod tidy
### ✅ write-go-tests
Template for writing comprehensive Go tests including unit tests, benchmarks, and table-driven tests.
**Arguments:**
- `package_path` (string, required): Package path to write tests for
- `test_type` (string, optional): Type of tests to write: unit, benchmark, integration, or all (default: all)
**Use Cases:**
- Writing tests for new packages
- Adding test coverage to existing code
- Creating benchmarks for performance-critical code
- Setting up integration tests
**Examples:**
Write all test types:
```json
{
"name": "write-go-tests",
"arguments": {
"package_path": "./internal/processor",
"test_type": "all"
}
}
```
Write only unit tests:
```json
{
"name": "write-go-tests",
"arguments": {
"package_path": "./internal/utils",
"test_type": "unit"
}
}
```
This prompt provides guidance on:
- Table-driven test patterns
- Test organization with subtests
- Error case testing
- Benchmark creation
- Integration test setup
### ✅ optimize-go-performance
Guide for profiling and optimizing Go code performance using pprof, benchmarks, and race detection.
**Arguments:**
- `package_path` (string, required): Package to optimize
- `optimization_goal` (string, optional): Optimization goal: cpu, memory, concurrency, or general (default: general)
**Use Cases:**
- Identifying performance bottlenecks
- Optimizing CPU-intensive code
- Reducing memory allocations
- Improving concurrency performance
**Examples:**
General optimization:
```json
{
"name": "optimize-go-performance",
"arguments": {
"package_path": "./internal/processor",
"optimization_goal": "general"
}
}
```
CPU-focused optimization:
```json
{
"name": "optimize-go-performance",
"arguments": {
"package_path": "./internal/processor",
"optimization_goal": "cpu"
}
}
```
This prompt guides you through:
1. Establishing baseline with benchmarks
2. Profiling CPU and memory usage
3. Analyzing profiles with pprof
4. Identifying and fixing bottlenecks
5. Measuring improvements
6. Race condition detection
### ✅ debug-go-issue
Systematic approach to debugging Go programs including race conditions, panics, and performance issues.
**Arguments:**
- `issue_type` (string, optional): Type of issue: panic, race, performance, deadlock, or unknown (default: unknown)
- `package_path` (string, optional): Package where the issue occurs
**Use Cases:**
- Debugging panics and crashes
- Finding race conditions
- Investigating performance problems
- Resolving deadlocks
**Examples:**
Debug a panic:
```json
{
"name": "debug-go-issue",
"arguments": {
"issue_type": "panic",
"package_path": "./internal/handlers"
}
}
```
Debug race conditions:
```json
{
"name": "debug-go-issue",
"arguments": {
"issue_type": "race",
"package_path": "./internal/worker"
}
}
```
This prompt provides:
- Step-by-step debugging workflow
- Issue-specific debugging strategies
- Tool recommendations (go_test, go_race_detect, go_trace, etc.)
- Verification steps after fixes
### ✅ add-go-dependency
Guide for adding and managing Go dependencies using go mod.
**Arguments:**
- `package_path` (string, required): Package path to add (e.g., github.com/gin-gonic/gin)
- `version` (string, optional): Specific version or latest (default: latest)
**Use Cases:**
- Adding new dependencies to a project
- Updating existing dependencies
- Managing dependency versions
**Examples:**
Add latest version:
```json
{
"name": "add-go-dependency",
"arguments": {
"package_path": "github.com/gin-gonic/gin"
}
}
```
Add specific version:
```json
{
"name": "add-go-dependency",
"arguments": {
"package_path": "github.com/gin-gonic/gin",
"version": "v1.9.1"
}
}
```
This prompt guides you through:
1. Reviewing package documentation first
2. Adding the dependency with go mod get
3. Reviewing go.mod and go.sum changes
4. Running go mod tidy
5. Verifying the build
6. Best practices for dependency management
### ✅ go-code-review
Checklist for reviewing Go code including style, performance, security, and best practices.
**Arguments:**
- `package_path` (string, optional): Package to review
**Use Cases:**
- Code review preparation
- Quality assurance checks
- Pre-commit validation
- Release preparation
**Example:**
```json
{
"name": "go-code-review",
"arguments": {
"package_path": "./internal/api"
}
}
```
This prompt provides a comprehensive checklist covering:
1. Code quality (formatting, linting, error handling)
2. Testing (coverage, edge cases, benchmarks)
3. Concurrency (race conditions, synchronization)
4. Performance (allocations, data structures)
5. Documentation (comments, examples, README)
6. Dependencies (security, versions, cleanup)
7. Build and deployment (compilation, cross-compilation)
### ✅ go-server-deployment
Guide for building and deploying Go servers including cross-compilation, optimization, and production best practices.
**Arguments:**
- `target_os` (string, optional): Target operating system: linux, darwin, windows (default: linux)
- `target_arch` (string, optional): Target architecture: amd64, arm64, 386 (default: amd64)
**Use Cases:**
- Preparing production builds
- Cross-compiling for different platforms
- Setting up deployment pipelines
- Production server configuration
**Examples:**
Deploy for Linux:
```json
{
"name": "go-server-deployment",
"arguments": {
"target_os": "linux",
"target_arch": "amd64"
}
}
```
Deploy for macOS ARM:
```json
{
"name": "go-server-deployment",
"arguments": {
"target_os": "darwin",
"target_arch": "arm64"
}
}
```
This prompt covers:
1. Pre-deployment testing and validation
2. Production build configuration
3. Cross-compilation setup
4. Security considerations
5. Performance optimization
6. Monitoring and logging setup
7. Post-deployment verification
Usage Examples - Practical examples and workflows
This section provides practical, copy-pasteable examples demonstrating common workflows, tool combinations, and real-world scenarios.
### Common Development Workflows
#### Quick Start Workflow
Initialize a new project, format code, run tests, and build:
```json
{
"name": "go_mod",
"arguments": {
"operation": "init",
"module_path": "github.com/user/myproject"
}
}
```
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./..."]
}
}
```
```json
{
"name": "go_test",
"arguments": {
"verbose": true
}
}
```
```json
{
"name": "go_build",
"arguments": {
"output": "myapp"
}
}
```
#### Testing Workflow
Run comprehensive tests with coverage and race detection:
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"cover_pkg": "./...",
"race": true,
"verbose": true
}
}
```
```json
{
"name": "go_race_detect",
"arguments": {
"package": "./..."
}
}
```
#### Performance Analysis Workflow
Benchmark, profile, and optimize code:
```json
{
"name": "go_benchmark",
"arguments": {
"pattern": "Benchmark.*",
"count": 5
}
}
```
```json
{
"name": "go_profile",
"arguments": {
"type": "cpu",
"output": "cpu.prof",
"duration": "30s",
"package": "./internal/processor"
}
}
```
```json
{
"name": "go_memory_profile",
"arguments": {
"output": "mem.prof",
"package": "./internal/processor"
}
}
```
#### Cross-Compilation Workflow
Build for multiple platforms:
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp-linux-amd64",
"goos": "linux",
"goarch": "amd64"
}
}
```
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp-darwin-arm64",
"goos": "darwin",
"goarch": "arm64"
}
}
```
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "myapp-windows-amd64.exe",
"goos": "windows",
"goarch": "amd64"
}
}
```
### Multi-Tool Examples
#### Complete CI/CD-like Workflow
Format, lint, test, and build with production flags:
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./..."]
}
}
```
```json
{
"name": "go_lint",
"arguments": {
"linter": "golangci-lint",
"package": "./..."
}
}
```
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"cover_pkg": "./...",
"race": true
}
}
```
```json
{
"name": "go_build",
"arguments": {
"output": "myapp",
"trimpath": true,
"ldflags": "-X main.version=1.0.0 -X main.buildTime=$(date +%s)"
}
}
```
#### Server Development Workflow
Build, start, monitor, and stop a server:
```json
{
"name": "go_build",
"arguments": {
"output": "server"
}
}
```
```json
{
"name": "go_server_start",
"arguments": {
"id": "api-server",
"name": "API Server",
"command": "./server",
"args": ["--port", "8080"],
"env_vars": {
"ENV": "development",
"LOG_LEVEL": "debug"
}
}
}
```
```json
{
"name": "go_server_logs",
"arguments": {
"id": "api-server",
"count": 50
}
}
```
```json
{
"name": "go_server_status",
"arguments": {
"id": "api-server"
}
}
```
```json
{
"name": "go_server_stop",
"arguments": {
"id": "api-server"
}
}
```
#### Package Research Workflow
Search for packages, fetch documentation, and extract examples:
```json
{
"name": "go_pkg_search",
"arguments": {
"query": "http router"
}
}
```
```json
{
"name": "go_pkg_docs",
"arguments": {
"package": "github.com/gin-gonic/gin"
}
}
```
```json
{
"name": "go_pkg_examples",
"arguments": {
"package": "github.com/gin-gonic/gin"
}
}
```
### Integration Examples
#### Claude Desktop Setup
**macOS Configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true",
"GOPROXY": "https://proxy.golang.org"
}
}
}
}
```
**Windows Configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "C:\\Program Files\\mcp-go\\mcp-go.exe",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
**Linux Configuration:**
```json
{
"mcpServers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true",
"GOROOT": "/usr/local/go"
}
}
}
}
```
**Troubleshooting:**
- Verify installation: Check that `mcp-go --version` works in terminal
- Check permissions: Ensure the binary is executable (`chmod +x /path/to/mcp-go`)
- Test connection: Restart Claude Desktop after configuration changes
- View logs: Check Claude Desktop logs for connection errors
#### VS Code Setup
**Workspace Settings (.vscode/settings.json):**
```json
{
"mcp.servers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": [],
"env": {
"DISABLE_NOTIFICATIONS": "true"
}
}
}
}
```
**User Settings (Global):**
```json
{
"mcp.servers": {
"mcp-go": {
"command": "/usr/local/bin/mcp-go",
"args": []
}
}
}
```
**Debugging Tips:**
- Enable MCP logging in VS Code settings
- Check Output panel for MCP server messages
- Verify Go environment: Ensure `go version` works in integrated terminal
- Test tools: Try calling `go_fmt` or `go_test` to verify connection
#### Standalone Usage
**Testing the Server Directly:**
```bash
echo '{"jsonrpc": "2.0", "id": 1, "method": "tools/list", "params": {}}' | mcp-go
```
**JSON-RPC Request Example:**
```json
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "go_run",
"arguments": {
"file": "main.go"
}
}
}
```
**JSON-RPC Response Example:**
```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{
"type": "text",
"text": "Hello, World!"
}
]
}
}
```
### Real-World Scenarios
#### Building a REST API
Complete workflow for developing and testing a REST API:
```json
{
"name": "go_pkg_search",
"arguments": {
"query": "gin echo fiber"
}
}
```
```json
{
"name": "go_pkg_docs",
"arguments": {
"package": "github.com/gin-gonic/gin"
}
}
```
```json
{
"name": "go_mod",
"arguments": {
"operation": "get",
"packages": ["github.com/gin-gonic/gin@latest"]
}
}
```
```json
{
"name": "go_server_start",
"arguments": {
"id": "rest-api",
"name": "REST API Server",
"command": "go",
"args": ["run", "main.go"],
"env_vars": {
"PORT": "8080",
"ENV": "development"
}
}
}
```
```json
{
"name": "go_server_logs",
"arguments": {
"id": "rest-api",
"count": 100
}
}
```
```json
{
"name": "go_profile",
"arguments": {
"type": "cpu",
"output": "api-cpu.prof",
"duration": "60s"
}
}
```
```json
{
"name": "go_server_stop",
"arguments": {
"id": "rest-api"
}
}
```
#### Library Development
Workflow for developing and publishing a Go library:
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./..."]
}
}
```
```json
{
"name": "go_lint",
"arguments": {
"linter": "golangci-lint",
"package": "./..."
}
}
```
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"cover_pkg": "./...",
"bench": true
}
}
```
```json
{
"name": "go_benchmark",
"arguments": {
"pattern": "Benchmark.*",
"count": 10
}
}
```
```json
{
"name": "go_doc",
"arguments": {
"package": "./...",
"all": false
}
}
```
```json
{
"name": "go_cross_compile",
"arguments": {
"output": "lib-test-linux",
"goos": "linux",
"goarch": "amd64"
}
}
```
#### Debugging Performance Issues
Identify and fix performance bottlenecks:
```json
{
"name": "go_benchmark",
"arguments": {
"pattern": "BenchmarkSlowFunction",
"count": 20
}
}
```
```json
{
"name": "go_profile",
"arguments": {
"type": "cpu",
"output": "slow-cpu.prof",
"duration": "30s",
"package": "./internal/slow"
}
}
```
```json
{
"name": "go_trace",
"arguments": {
"output": "slow-trace.out",
"package": "./internal/slow"
}
}
```
```json
{
"name": "go_memory_profile",
"arguments": {
"output": "slow-mem.prof",
"package": "./internal/slow"
}
}
```
```json
{
"name": "go_race_detect",
"arguments": {
"package": "./internal/slow"
}
}
```
After profiling, analyze results:
```bash
go tool pprof cpu.prof
go tool trace trace.out
go tool pprof mem.prof
```
## Resources Usage
Resources provide structured information about your Go workspace. Access them through the MCP resource protocol.
### Using go://modules
Discover project dependencies and module information:
**Access Pattern:**
```
Resource URI: go://modules
```
**Use Cases:**
- Understanding project dependencies before adding new packages
- Checking module versions
- Identifying unused dependencies
- Planning dependency updates
**Example Workflow:**
1. Access `go://modules` to see current dependencies
2. Use `go_pkg_search` to find alternatives
3. Use `go_mod` with `operation: "get"` to add new packages
4. Use `go_mod` with `operation: "tidy"` to clean up
### Using go://build-tags
Discover build tags and conditional compilation:
**Access Pattern:**
```
Resource URI: go://build-tags
```
**Use Cases:**
- Understanding platform-specific code
- Finding feature flags
- Planning cross-compilation
- Identifying conditional builds
**Example Workflow:**
1. Access `go://build-tags` to see available tags
2. Use `go_build` with `tags: ["production", "linux"]` for specific builds
3. Use `go_cross_compile` with appropriate tags for platform builds
### Using go://tests
Discover test files and benchmarks:
**Access Pattern:**
```
Resource URI: go://tests
```
**Use Cases:**
- Finding all test files in the project
- Discovering benchmark functions
- Planning test coverage improvements
- Understanding test structure
**Example Workflow:**
1. Access `go://tests` to see all test files
2. Use `go_test` with `cover: true` to run with coverage
3. Use `go_benchmark` to run specific benchmarks
4. Use `go_race_detect` to check for race conditions
### Using go://workspace
Understand project structure and configuration:
**Access Pattern:**
```
Resource URI: go://workspace
```
**Use Cases:**
- Understanding project layout
- Finding main packages
- Discovering module structure
- Planning refactoring
**Example Workflow:**
1. Access `go://workspace` to understand structure
2. Use `go_build` with appropriate package paths
3. Use `go_test` with specific package paths
4. Use `go_fmt` with targeted paths
### Using go://pkg-docs/{path}
Access package documentation directly:
**Access Pattern:**
```
Resource URI: go://pkg-docs/net/http
Resource URI: go://pkg-docs/github.com/gin-gonic/gin
```
**Use Cases:**
- Quick access to standard library docs
- Viewing third-party package documentation
- Learning package APIs
- Finding usage examples
**Example Workflow:**
1. Access `go://pkg-docs/net/http` for HTTP package docs
2. Use `go_pkg_examples` to get code examples
3. Use `go_doc` for local package documentation
4. Integrate examples into your code
**Example with version:**
```
Resource URI: go://pkg-docs/github.com/gin-gonic/gin@v1.9.1
```
### Using go://tools
Discover all available tools and their capabilities:
**Access Pattern:**
```
Resource URI: go://tools
```
**Use Cases:**
- Discovering available tools when starting with the server
- Understanding tool parameters and schemas
- Finding the right tool for a specific task
- Exploring tool capabilities
**Example Workflow:**
1. Access `go://tools` to see all 22 available tools
2. Review tool descriptions and parameter schemas
3. Select appropriate tools for your workflow
4. Use tools in combination for complex tasks
**Example Response Structure:**
The resource returns a JSON object with:
- `tools`: Array of tool metadata including name, description, and input schema
- `count`: Total number of tools available
### Using go://prompts
Discover all available prompts for guided workflows:
**Access Pattern:**
```
Resource URI: go://prompts
```
**Use Cases:**
- Finding prompts for specific development tasks
- Understanding prompt arguments and requirements
- Discovering guided workflows
- Planning development processes
**Example Workflow:**
1. Access `go://prompts` to see all 7 available prompts
2. Review prompt descriptions and arguments
3. Use appropriate prompts for your development phase
4. Combine prompts with tools for complete workflows
**Example Response Structure:**
The resource returns a JSON object with:
- `prompts`: Array of prompt metadata including name, description, and arguments
- `count`: Total number of prompts available
### Using go://resources
Discover all available resources:
**Access Pattern:**
```
Resource URI: go://resources
```
**Use Cases:**
- Understanding what resources are available
- Finding resource URIs and descriptions
- Planning resource-based workflows
- Discovering workspace discovery capabilities
**Example Workflow:**
1. Access `go://resources` to see all 8 available resources
2. Review resource URIs and descriptions
3. Use resources to gather workspace information
4. Combine resources with tools for informed decision-making
**Example Response Structure:**
The resource returns a JSON object with:
- `resources`: Array of resource metadata including URI, name, description, and MIME type
- `count`: Total number of resources available
### Resource Integration Examples
#### Complete Project Analysis Workflow
1. **Understand project structure:**
- Access `go://workspace` to see project layout
- Access `go://modules` to understand dependencies
2. **Analyze code quality:**
- Access `go://tests` to see test coverage
- Access `go://build-tags` to understand conditional compilation
3. **Plan improvements:**
- Access `go://tools` to find appropriate tools
- Access `go://prompts` for guided workflows
4. **Execute improvements:**
- Use tools based on resource insights
- Follow prompts for structured workflows
#### Dependency Management Workflow
1. Access `go://modules` to see current dependencies
2. Use `go_pkg_search` to find alternatives
3. Access `go://pkg-docs/{package}` to review documentation
4. Use `go_mod` to add dependencies
5. Access `go://modules` again to verify changes
#### Test Coverage Analysis Workflow
1. Access `go://tests` to see all test files
2. Use `go_test` with `cover: true` to get coverage report
3. Identify gaps in test coverage
4. Use `write-go-tests` prompt for guidance
5. Access `go://tests` again to verify new tests
Advanced Patterns - Complex workflows and best practices
### Combining Tools in Complex Workflows
#### Pre-commit Workflow
Automated checks before committing code:
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./..."]
}
}
```
```json
{
"name": "go_lint",
"arguments": {
"linter": "golangci-lint",
"package": "./..."
}
}
```
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"race": true
}
}
```
#### Release Preparation Workflow
Prepare a release with multiple platform builds:
```json
{
"name": "go_mod",
"arguments": {
"operation": "tidy"
}
}
```
```json
{
"name": "go_test",
"arguments": {
"cover": true,
"cover_pkg": "./..."
}
}
```
```json
{
"name": "go_build",
"arguments": {
"output": "myapp",
"trimpath": true,
"ldflags": "-X main.version=1.0.0"
}
}
```
Then cross-compile for all target platforms.
#### Continuous Profiling Workflow
Monitor performance over time:
```json
{
"name": "go_server_start",
"arguments": {
"id": "monitored-server",
"name": "Monitored Server",
"command": "go",
"args": ["run", "main.go"]
}
}
```
```json
{
"name": "go_profile",
"arguments": {
"type": "cpu",
"output": "profile-$(date +%s).prof",
"duration": "5m"
}
}
```
Periodically check logs and profiles to identify trends.
### Using Resources with Tools
#### Dependency Management Workflow
Use resources to inform tool usage:
1. Access `go://modules` to see current dependencies
2. Use `go_pkg_search` to find alternatives
3. Compare with `go_pkg_docs` for each option
4. Use `go_mod` to add the chosen package
5. Access `go://modules` again to verify
#### Test-Driven Development Workflow
Use resources to guide testing:
1. Access `go://tests` to see existing test structure
2. Use `go_test` with `cover: true` to see coverage gaps
3. Write new tests based on coverage report
4. Use `go_benchmark` to ensure performance
5. Access `go://tests` to verify new tests are included
### Error Handling and Troubleshooting
#### Build Failures
When builds fail, use this diagnostic workflow:
```json
{
"name": "go_fmt",
"arguments": {
"paths": ["./..."]
}
}
```
```json
{
"name": "go_lint",
"arguments": {
"package": "./..."
}
}
```
```json
{
"name": "go_mod",
"arguments": {
"operation": "tidy"
}
}
```
```json
{
"name": "go_build",
"arguments": {
"output": "myapp"
}
}
```
#### Test Failures
When tests fail, investigate systematically:
```json
{
"name": "go_test",
"arguments": {
"verbose": true,
"package": "./internal/failing"
}
}
```
```json
{
"name": "go_race_detect",
"arguments": {
"package": "./internal/failing"
}
}
```
```json
{
"name": "go_trace",
"arguments": {
"output": "test-trace.out",
"package": "./internal/failing"
}
}
```
#### Server Issues
When servers behave unexpectedly:
```json
{
"name": "go_server_status",
"arguments": {
"id": "problematic-server"
}
}
```
```json
{
"name": "go_server_logs",
"arguments": {
"id": "problematic-server",
"count": 0
}
}
```
```json
{
"name": "go_profile",
"arguments": {
"type": "mem",
"output": "server-mem.prof",
"duration": "60s"
}
}
```
### Best Practices
#### For Development
- Use `go_fmt` before every commit
- Run `go_test` with `race: true` for concurrent code
- Use `go_lint` regularly to catch issues early
- Access `go://workspace` to understand project structure
#### For Production
- Always use `trimpath: true` in builds
- Include version info via `ldflags`
- Test with `go_race_detect` before releases
- Cross-compile and test on target platforms
#### For Performance
- Benchmark before and after optimizations
- Profile with realistic workloads
- Use `go_trace` for concurrency issues
- Monitor memory profiles for leaks
#### For Package Management
- Use `go://modules` to understand dependencies
- Search packages before adding (`go_pkg_search`)
- Review docs (`go_pkg_docs`) before integration
- Use `go_mod tidy` regularly to clean up
## Security Considerations
- All command executions require user permission (unless `DISABLE_NOTIFICATIONS=true`)
- Commands run with the same permissions as the MCP server process
- Command validation prevents injection attacks
- The permission system can use system notifications or console prompts
## License
This project is licensed under the MIT License - see the LICENSE file for details.
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
## Changelog
See [CHANGELOG.md](CHANGELOG.md) for version history.