go-docs
MCP server that provides real-time Go documentation and expert programming assistance by fetching from pkg.go.dev.
README
go-docs
A Mastra-based MCP server that provides expert Go programming assistance with real-time documentation from pkg.go.dev. Use it in your AI-powered code editor to get instant access to Go documentation, best practices, and code examples.
Production Deployment
| Host | Base URL | Highlights |
|---|---|---|
| Mastra Cloud | https://go-docs.mastra.cloud | Primary choice - Zero cold start, maximum responsiveness, reliable performance. |
- Append
/api/mcp/goDocsMcpServer/ssefor the SSE transport (best for editors that keep long-lived connections). - Append
/api/mcp/goDocsMcpServer/mcpfor the HTTP transport (handy for CLIs and quick one-off calls).
<details> <summary>Endpoint reference</summary>
- Mastra Cloud SSE: https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse
- Mastra Cloud HTTP: https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp
- Development SSE: http://localhost:4111/api/mcp/goDocsMcpServer/sse
- Development HTTP: http://localhost:4111/api/mcp/goDocsMcpServer/mcp
</details>
🎉 What's New
- ✅ Production deployment on Mastra Cloud
- ✅ Real-time Go documentation from pkg.go.dev
- ✅ Expert Go programming assistance with AI agent
- ✅ Support for all major AI code editors (Cursor, Windsurf, VS Code, Claude Desktop)
- ✅ HTTP and SSE transport protocols
- ✅ Automated versioning with semantic-release
🚀 Features
- Go Documentation Access: Fetches real-time documentation from pkg.go.dev
- MCP Protocol Support: HTTP SSE transport for seamless integration with MCP clients
- Intelligent Responses: Provides well-formatted answers with code examples
- Mastra Framework: Built on Mastra for scalable tool development
- TypeScript Support: Fully typed with TypeScript
- Multi-Client Support: Works with Cursor, VSCode, Claude Desktop, Windsurf, and other MCP-compatible tools
Editor Setup
Mastra Cloud is the recommended deployment for all editors. It offers zero cold start and maximum responsiveness. SSE works best for editors that keep a persistent connection, while HTTP is handy for one-off requests and scripts.
<details> <summary>Cursor</summary>
- Open Cursor Settings (
Cmd/Ctrl+,). - Navigate to "MCP" / "Model Context Protocol" and add a new server configuration.
Mastra Cloud — SSE example:
{
"go-docs": {
"type": "sse",
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse"
}
}
Mastra Cloud — HTTP example:
{
"go-docs": {
"type": "http",
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp"
}
}
Development (localhost):
{
"go-docs-dev": {
"type": "sse",
"url": "http://localhost:4111/api/mcp/goDocsMcpServer/sse"
}
}
</details>
<details> <summary>VS Code</summary>
Add to your .vscode/settings.json or use the Command Palette (Cmd/Ctrl+Shift+P) and run MCP: Add server:
For Production (SSE transport):
{
"mcpServers": {
"go-docs": {
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse",
"type": "sse"
}
}
}
For Production (HTTP transport):
{
"mcpServers": {
"go-docs": {
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp",
"type": "http"
}
}
}
For Development (localhost):
{
"mcpServers": {
"go-docs-dev": {
"url": "http://localhost:4111/api/mcp/goDocsMcpServer/sse",
"type": "sse"
}
}
}
</details>
<details> <summary>Windsurf</summary>
- Edit
~/.codeium/windsurf/mcp_config.json. - Add the SSE transport:
{
"mcpServers": {
"go-docs": {
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse",
"transport": "sse"
}
}
}
- Save, restart Windsurf, then open
mcp.jsonin Agent mode and click "start".
</details>
<details> <summary>Claude Desktop</summary>
Add to your claude_desktop_config.json:
For Production:
{
"mcpServers": {
"go-docs": {
"url": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse"
}
}
}
For Development:
{
"mcpServers": {
"go-docs-dev": {
"url": "http://localhost:4111/api/mcp/goDocsMcpServer/sse"
}
}
}
</details>
<details> <summary>Zed</summary>
- Open Zed settings (
Cmd/Ctrl+,). - Edit
~/.config/zed/settings.json:
{
"context_servers": {
"go-docs": {
"source": "custom",
"command": "npx",
"args": [
"-y",
"mcp-remote",
"https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse"
],
"env": {}
}
}
}
- Save, restart Zed, and confirm the server shows a green indicator in the Agent panel.
</details>
CLI & Agent Configuration
<details> <summary>Claude Code CLI (Anthropic)</summary>
-
Global settings (
~/.claude/settings.json):{ "mcpServers": { "go-docs": { "command": "npx", "args": [ "-y", "mcp-remote", "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp" ] } } } -
Command palette alternative:
claude mcp add go-docs --url https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp
</details>
<details> <summary>OpenAI Codex CLI</summary>
codex mcp add go-docs --url https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse
codex mcp list
</details>
<details> <summary>Gemini CLI (Google)</summary>
-
Create or edit
~/.gemini/settings.json:mkdir -p ~/.gemini nano ~/.gemini/settings.json -
Add the configuration:
{ "mcpServers": { "go-docs": { "httpUrl": "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp" } } } -
Or use the npx command variant:
{ "mcpServers": { "go-docs": { "command": "npx", "args": [ "mcp-remote", "https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp" ] } } }
</details>
Verification & Quick Tests
# Test MCP connection
npx mcp-remote https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp
# Check HTTP endpoint
curl -I https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/mcp
# Test SSE endpoint
curl -N https://go-docs.mastra.cloud/api/mcp/goDocsMcpServer/sse
Available Tools
Once installed, your AI assistant will have access to these tools:
- fetchGoDoc - Fetches real-time official Go documentation from pkg.go.dev. Use this to get package docs, function signatures, type definitions, and examples. Supports standard library packages like 'fmt', 'net/http', 'context', 'encoding/json', and third-party packages.
Example Usage
After installing the MCP server in your editor, you can ask your AI assistant:
- "How do I use the fmt package in Go?"
- "Show me examples of Go slices and arrays"
- "What are Go best practices for error handling?"
- "Explain Go interfaces with code examples"
- "How do I handle concurrency with goroutines?"
- "What's the difference between make and new in Go?"
📖 Programmatic Usage
import { MCPClient } from "@mastra/mcp";
// Use environment variable for URL (supports both dev and prod)
const mcpUrl =
process.env.MCP_SERVER_URL ||
"http://localhost:4111/api/mcp/goDocsMcpServer/sse";
const mcp = new MCPClient({
servers: {
goDocs: {
url: mcpUrl,
},
},
});
// Get available tools
const tools = await mcp.getTools();
// Call a tool directly
const result = await mcp.callTool("go-docs", "fetchGoDocs", {
query: "How do I use Go slices?",
});
🚀 Quick Start (Local Development)
These instructions assume you have Bun (or Node 20+) installed and an API key for your chosen model provider.
- Install dependencies:
bun install
- Copy the example environment and add your API key(s):
cp .env.example .env
# Edit .env and add your API key(s)
- Run in development mode:
bun run dev
- Build and run production:
bun run build
bun run start
Note: Studio (Mastra local UI) is available during dev at http://localhost:4111.
📦 Scripts
| Script | Description |
|---|---|
dev |
Start Mastra in development mode |
build |
Build the Mastra project for production |
start |
Start the built Mastra server |
check-versions |
Verify package.json and MCP server match |
sync-versions |
Sync version from package.json to MCP server |
⚙️ Environment Variables
Copy .env.example to .env and configure:
cp .env.example .env
| Variable | Description |
|---|---|
OPENAI_API_KEY |
API key for OpenAI |
GOOGLE_GENERATIVE_AI_API_KEY |
API key for Google Gemini (optional) |
MCP_SERVER_URL |
MCP server URL for programmatic access |
🗂️ Project Structure
src/
├─ mastra/
│ ├─ agents/
│ │ └─ go-docs-agent.ts # AI agent for Go documentation
│ ├─ mcp/
│ │ └─ go-docs-server.ts # MCP server configuration
│ ├─ tools/
│ │ └─ go-docs-tool.ts # Documentation fetching tool
│ └─ index.ts # Mastra configuration
scripts/
├─ check-versions.js # Version verification script
└─ sync-versions.js # Version synchronization script
🔧 How it Works
- MCP Protocol: Communicates via HTTP SSE or HTTP transport
- Documentation Fetching: The
go-docs-toolfetches documentation from pkg.go.dev - AI Agent: Expert Go agent provides contextual answers with code examples
- Tool Exposure: Makes Go documentation tools available to connected MCP clients
🛠️ Development
Extending the MCP Server
To add new capabilities:
- Add Tools: Create new tools in
src/mastra/tools/ - Modify MCP Server: Update
src/mastra/mcp/go-docs-server.ts - Test: Use the MCP client testing configuration
Building Custom Tools
import { createTool } from "@mastra/core/tools";
import { z } from "zod";
export const customTool = createTool({
id: "custom-tool",
description: "Description of what the tool does",
inputSchema: z.object({
param: z.string(),
}),
execute: async ({ context }) => {
return { result: "output" };
},
});
Version Management
Versions are synchronized between package.json and the MCP server:
# Check if versions match
bun run check-versions
# Sync versions (package.json is source of truth)
bun run sync-versions
Contributing
Contributions are welcome! Please follow these guidelines:
- Fork the repo and create a feature branch
- Follow Conventional Commits for commit messages
- Add tests or a demo if you change behavior
- Submit a PR describing your change
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。