mcp-go-starter

by SamMorrowDrums

6 179 downloads Not rated yet MIT
GitHub

About

A feature-complete Model Context Protocol (MCP) server template in Go using the official go-sdk. It demonstrates all major MCP features with clean, idiomatic Go code, intended for developers building MCP servers in Go.

Details

License
MIT

Explore

| Category | Feature | Description |
|----------|---------|-------------|
| Tools | hello | Basic tool with annotations |
| | get_weather | Tool returning structured data |
| | ask_llm | Tool that invokes LLM sampling |
| | long_task | Tool with 5-second progress updates |
| | load_bonus_tool | Dynamically loads a new tool |
| Resources | info://about | Static informational resource |
| | file://example.md | File-based markdown resource |
| Templates | greeting://{name} | Personalized greeting |
| | data://items/{id} | Data lookup by ID |
| Prompts | greet | Greeting in various styles |
| | code_review | Code review with focus areas |

Setting up with Highlight

This MCP is not yet compatible with Highlight’s one-click setup. However, you can still use it with Highlight by following these steps:

  1. Download and install Highlight from highlightai.com/download
  2. Navigate to the plugins tab and select "Add Custom Plugin"
  3. Configure the plugin with the settings below
    Plugin Name mcp-go-starter
    Command (node, npx, python, etc.)

    Please refer to the README for specific instructions on how to obtain API keys or other required environment variables.

  4. Enable "Start Automatically" if you want the plugin to start when Highlight launches

From the repository

- Go 1.22+
- (Optional) air for live reload
- (Optional) golangci-lint for linting

stdio transport (for local development):

go run ./cmd/stdio

make install-tools

bash
npx @modelcontextprotocol/inspector -- go run ./cmd/stdio/main.go

Copy .env.example to .env and configure:

bash
cp .env.example .env
``

| Variable | Description | Default |
|----------|-------------|---------|
|
PORT | HTTP server port | 3000` |

mcp.AddTool(server, &mcp.Tool{
    Name:        "hello",
    Title:       "Say Hello",
    Description: "A friendly greeting tool",
    Annotations: &mcp.ToolAnnotations{
        ReadOnlyHint: ptr(true),
    },
}, helloHandler)

func helloHandler(ctx context.Context, req mcp.CallToolRequest, input helloInput) (mcp.CallToolResult, any, error) {
return &mcp.CallToolResult{
Content: []mcp.Content{
&mcp.TextContent{Text: fmt.Sprintf("Hello, %s!", input.Name)},
},
}, nil, nil
}

func longTaskHandler(ctx context.Context, req mcp.CallToolRequest, input longTaskInput) (mcp.CallToolResult, any, error) {
    progressToken := req.Params.GetProgressToken()
    
    for i := 0; i < 5; i++ {
        req.Session.NotifyProgress(ctx, &mcp.ProgressNotificationParams{
            ProgressToken: progressToken,
            Progress:      float64(i) / 5.0,
            Total:         1.0,
        })
        time.Sleep(time.Second)
    }
    
    return &mcp.CallToolResult{
        Content: []mcp.Content{&mcp.TextContent{Text: "Done!"}},
    }, nil, nil
}
result, err := req.Session.CreateMessage(ctx, &mcp.CreateMessageParams{
    Messages: []*mcp.SamplingMessage{
        {Role: "user", Content: &mcp.TextContent{Text: prompt}},
    },
    MaxTokens: 100,
})

Claude Desktop / Cursor

Paste into your MCP client config file to install this server.

{
    "mcpServers": {
        "mcp-go-starter": {
            "mcp-go-starter": {
                "command": "npx",
                "args": [
                    "@modelcontextprotocol/inspector",
                    "--",
                    "go",
                    "run",
                    "./cmd/stdio/main.go"
                ]
            }
        }
    }
}

McpServers

{
    "mcp-go-starter": {
        "command": "npx",
        "args": [
            "@modelcontextprotocol/inspector",
            "--",
            "go",
            "run",
            "./cmd/stdio/main.go"
        ]
    }
}

CI
Go Report Card
Go Version
License: MIT
MCP

A feature-complete Model Context Protocol (MCP) server template in Go using the official go-sdk. This starter demonstrates all major MCP features with clean, idiomatic Go code.

📚 Documentation

- Model Context Protocol
- Go SDK
- Building MCP Servers

✨ Features

| Category | Feature | Description |
|----------|---------|-------------|
| Tools | hello | Basic tool with annotations |
| | get_weather | Tool returning structured data |
| | ask_llm | Tool that invokes LLM sampling |
| | long_task | Tool with 5-second progress updates |
| | load_bonus_tool | Dynamically loads a new tool |
| Resources | info://about | Static informational resource |
| | file://example.md | File-based markdown resource |
| Templates | greeting://{name} | Personalized greeting |
| | data://items/{id} | Data lookup by ID |
| Prompts | greet | Greeting in various styles |
| | code_review | Code review with focus areas |

🚀 Quick Start

Prerequisites

- Go 1.22+
- (Optional) air for live reload
- (Optional) golangci-lint for linting

Installation

```bash

No reviews yet — be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.