Golang Dev Tools
Golang Dev Tools
README
Go Development MCP Server
The Go Development MCP Server is a comprehensive solution for integrating Go development workflows with AI assistants like Claude Desktop or other MCP-compatible tools. It enables AI assistants to compile, test, run, and analyze Go code directly through the Model Context Protocol (MCP).
Features
- Go Build: Compile Go code and receive detailed feedback
- Go Test: Run tests on Go code with support for coverage analysis
- Go Run: Compile and execute Go programs with command-line arguments
- Go Mod: Manage Go module dependencies (init, tidy, download, etc.)
- Go Format: Format Go code according to standard conventions
- Go Analyze: Analyze Go code for issues using static analysis tools
- Go Workspace: Manage Go workspaces for multi-module development (NEW!)
New in This Release
- MCP v0.29.0 Compatibility: Updated to use the latest Model Context Protocol v0.29.0
- Go Workspace Support: Complete workspace management for multi-module Go projects
- Project Path Support: All tools now support working with existing Go project directories
- Workspace-Aware Execution: All tools can operate within Go workspace context
- Strategy Pattern: Flexible execution strategies for code snippets vs. project directories vs. workspaces
- Enhanced Response Formatting: Better structured responses with natural language metadata
- Improved Error Handling: More detailed and helpful error messages
- End-to-End Testing: Comprehensive behavioral testing scripts to verify functionality
- Modern Testing Framework: New Go-based testing framework with parallel test execution
Go Workspace Support
The server now includes comprehensive support for Go workspaces, enabling multi-module development workflows. This feature allows you to:
- Initialize Workspaces: Create new Go workspaces with
go work init - Manage Modules: Add, remove, and organize modules within workspaces
- Unified Operations: Run Go commands across all modules in a workspace
- Dependency Synchronization: Keep dependencies consistent across modules
- Workspace-Aware Tools: All existing tools (build, test, run, etc.) work seamlessly with workspaces
Workspace Commands
The go_workspace tool provides the following subcommands:
init: Initialize a new Go workspaceuse: Add modules to an existing workspacesync: Synchronize workspace dependenciesedit: View and modify workspace configurationvendor: Vendor all workspace dependenciesinfo: Get detailed workspace information
Workspace Integration
All existing tools support workspace contexts through the workspace_path parameter:
{
"tool": "go_build",
"arguments": {
"workspace_path": "/path/to/workspace",
"module": "specific-module",
"code": "package main..."
}
}
Testing
The server includes comprehensive testing capabilities to verify that it works correctly with real Go projects. Testing is provided through two frameworks:
- Go Testing Framework: Modern, parallel test framework using Go's native testing facilities and testify
- PowerShell Testing: Legacy end-to-end behavioral tests (for backward compatibility)
The tests verify all input modes (code-only, project path, and hybrid) and ensure that the execution strategies work as expected.
Running the Tests
Go Tests (Recommended)
# Run all Go tests
cd go-dev-mcp
.\scripts\testing\run_tests.ps1 -TestType go -UseGoTests -WithCoverage
# Run with race detection
.\scripts\testing\run_tests.ps1 -TestType go -UseGoTests -WithRaceDetection
# Run directly with Go
go test -v ./internal/tools/...
PowerShell Tests (Legacy)
# Quick tests
cd go-dev-mcp\scripts\testing
.\basic\simple_test.ps1
# Comprehensive tests
cd go-dev-mcp\scripts\testing
.\core\all_tools_test.ps1 -Verbose
# Strategy-specific tests
cd go-dev-mcp\scripts\testing
.\strategies\hybrid_strategy_test.ps1 -Verbose
For detailed information about the testing framework, see the Testing Documentation.
The testing scripts are organized into categories:
- Basic tests: Simple, quick-running tests for sanity checks
- Core tests: Comprehensive tests covering all tools and input modes
- Strategy tests: Tests focused on specific execution strategies like hybrid execution
See the testing README for more details.
Installation
Prerequisites
- Go 1.21 or higher
- Git
Windows
Manual Installation
-
Clone the repository:
git clone https://github.com/MrFixit96/go-dev-mcp.git cd go-dev-mcp -
Build the executable:
go build -o go-dev-mcp.exe ./cmd/server -
Move the executable to a location in your PATH or reference it directly in your Claude Desktop configuration.
Using WinGet (Coming Soon)
winget install go-dev-mcp
macOS
Using Homebrew (Coming Soon)
brew install go-dev-mcp
Manual Installation (macOS)
-
Clone the repository:
git clone https://github.com/MrFixit96/go-dev-mcp.git cd go-dev-mcp -
Build the executable:
go build -o go-dev-mcp ./cmd/server -
Move the executable to a location in your PATH:
sudo mv go-dev-mcp /usr/local/bin/
Linux
-
Clone the repository:
git clone https://github.com/MrFixit96/go-dev-mcp.git cd go-dev-mcp -
Build the executable:
go build -o go-dev-mcp ./cmd/server -
Move the executable to a location in your PATH:
sudo mv go-dev-mcp /usr/local/bin/
Claude Desktop Integration
To integrate with Claude Desktop, update your claude_desktop_config.json file:
Windows Configuration
{
"mcpServers": {
"go-dev": {
"command": "C:\\path\\to\\go-dev-mcp.exe",
"args": [],
"env": {
"GOCACHE": "%LOCALAPPDATA%\\go-build",
"LOCALAPPDATA": "%LOCALAPPDATA%",
"GOPATH": "%USERPROFILE%\\go",
"GOROOT": "%GOROOT%",
"PATH": "%PATH%",
"DEBUG": "*"
},
"disabled": false,
"autoApprove": []
}
}
}
Environment Variables Used:
%LOCALAPPDATA%: Resolves toC:\Users\{username}\AppData\Local%USERPROFILE%: Resolves toC:\Users\{username}%GOROOT%: Go installation directory (automatically set by Go installer)%PATH%: System PATH for Go binary access
Alternative using Go Environment Variables:
{
"mcpServers": {
"go-dev": {
"command": "C:\\path\\to\\go-dev-mcp.exe",
"args": [],
"env": {
"DEBUG": "*"
},
"disabled": false,
"autoApprove": []
}
}
}
Note: The alternative configuration relies on Go's default environment detection. Go automatically uses
%LOCALAPPDATA%\go-buildfor GOCACHE and%USERPROFILE%\gofor GOPATH when not explicitly set.
macOS and Linux
{
"mcpServers": {
"go-dev": {
"command": "/path/to/go-dev-mcp",
"args": [],
"env": {},
"disabled": false,
"autoApprove": []
}
}
}
Usage
Working with Code Snippets
All tools accept Go code directly through the code parameter:
// Use go_build to compile code
go_build(code: "package main\n\nfunc main() {\n\tfmt.Println(\"Hello World\")\n}")
// Run tests with go_test
go_test(code: "package main", testCode: "package main\n\nimport \"testing\"\n\nfunc TestHello(t *testing.T) {...}")
Working with Project Directories
All tools now support working with existing Go project directories through the new project_path parameter:
// Compile a project
go_build(project_path: "/path/to/your/go/project")
// Run tests in a project
go_test(project_path: "/path/to/your/go/project", verbose: true, coverage: true)
// Format all files in a project
go_fmt(project_path: "/path/to/your/go/project")
// Analyze a project for issues
go_analyze(project_path: "/path/to/your/go/project", vet: true)
Configuration
The server uses a configuration file located at:
- Windows:
%APPDATA%\go-dev-mcp\config.json - macOS:
~/Library/Application Support/go-dev-mcp/config.json - Linux:
~/.config/go-dev-mcp/config.json
A default configuration file will be created on first run, which you can customize:
{
"version": "1.0.0",
"logLevel": "info",
"sandboxType": "process",
"resourceLimits": {
"cpuLimit": 2,
"memoryLimit": 512,
"timeoutSecs": 30
}
}
Security
The Go Development MCP Server runs commands in a sandboxed environment with:
- Process isolation
- Resource limits (CPU, memory, execution time)
- Temporary directory containment
- No network access by default
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Roadmap
- [ ] Add support for Go workspaces
- [ ] Implement Docker-based sandbox for stronger isolation
- [ ] Add debugging capabilities
- [ ] Support for Go race detector
- [ ] Improved error reporting with suggestions
Workspace Usage Examples
Basic Workspace Operations
Creating a New Workspace
{
"tool": "go_workspace",
"arguments": {
"command": "init",
"workspace_path": "/path/to/my-workspace",
"modules": ["./module1", "./module2"]
}
}
Adding Modules to Existing Workspace
{
"tool": "go_workspace",
"arguments": {
"command": "use",
"workspace_path": "/path/to/my-workspace",
"modules": ["./new-module", "../external-module"]
}
}
Getting Workspace Information
{
"tool": "go_workspace",
"arguments": {
"command": "info",
"workspace_path": "/path/to/my-workspace"
}
}
Multi-Module Development Workflow
1. Initialize Workspace Structure
# Create workspace directory
mkdir my-project-workspace
cd my-project-workspace
# Initialize with MCP
{
"tool": "go_workspace",
"arguments": {
"command": "init",
"workspace_path": ".",
"modules": ["./api", "./client", "./shared"]
}
}
2. Build Across All Modules
{
"tool": "go_build",
"arguments": {
"workspace_path": "/path/to/my-workspace"
}
}
3. Test Specific Module
{
"tool": "go_test",
"arguments": {
"workspace_path": "/path/to/my-workspace",
"module": "api",
"coverage": true
}
}
4. Synchronize Dependencies
{
"tool": "go_workspace",
"arguments": {
"command": "sync",
"workspace_path": "/path/to/my-workspace"
}
}
Advanced Workspace Features
Workspace with Custom Code
{
"tool": "go_run",
"arguments": {
"workspace_path": "/path/to/my-workspace",
"module": "api",
"code": "package main\n\nimport \"fmt\"\n\nfunc main() {\n fmt.Println(\"Running in workspace context\")\n}"
}
}
Vendor All Dependencies
{
"tool": "go_workspace",
"arguments": {
"command": "vendor",
"workspace_path": "/path/to/my-workspace"
}
}
Format All Modules
{
"tool": "go_fmt",
"arguments": {
"workspace_path": "/path/to/my-workspace"
}
}
Error Handling and Troubleshooting
Common Workspace Issues
- Missing go.work file: Use
initcommand to create workspace - Module not found: Use
usecommand to add modules - Dependency conflicts: Use
synccommand to resolve - Build failures: Check module-specific issues with targeted commands
Workspace Validation
{
"tool": "go_workspace",
"arguments": {
"command": "info",
"workspace_path": "/path/to/my-workspace"
}
}
Returns detailed workspace structure and validation status.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。