Model Context Protocol (MCP) Implementation in Go
Golang MCP Server
vishymakthal
README
Model Context Protocol (MCP) Implementation in Go
This repository contains a Go implementation of the Model Context Protocol (MCP), a JSON-RPC based protocol for interaction between clients and servers in LLM-powered applications.
Contents
mcp/schema.go
: Go struct definitions for the MCP schema, translated from the TypeScript schemamcp/client.go
: A client implementation for interacting with MCP serversexamples/mcp_client_example.go
: A simple example showing how to use the client
MCP Overview
The Model Context Protocol (MCP) enables communication between model "hosts" (e.g., LLM clients or systems that interface with LLMs) and "servers" (systems that provide contextual information, tools, prompts, or resources to enhance LLM capabilities).
Key features of MCP include:
- Resources: Files, documents, and other data that a host can read
- Tools: Functions that a host can call on behalf of a model
- Prompts: Templates or pre-defined message sequences a host can use
- Roots: Filesystem or data roots that a server can operate on
Getting Started
Prerequisites
- Go 1.18 or later
Running the Example
# Set the MCP server URL (optional, defaults to http://localhost:3000/jsonrpc)
export MCP_SERVER_URL=http://your-mcp-server/jsonrpc
# Run the example
go run examples/mcp_client_example.go
Using the MCP Client
import (
"fmt"
"path/to/mcp"
)
func main() {
// Create a new client
client := mcp.NewClient("http://your-mcp-server/jsonrpc")
// Initialize the client
clientInfo := mcp.Implementation{
Name: "My MCP Client",
Version: "1.0.0",
}
capabilities := mcp.ClientCapabilities{
// Specify the capabilities your client supports
}
err := client.Initialize(clientInfo, capabilities)
if err != nil {
// Handle error
}
// Now you can use various client methods:
// List resources
resources, err := client.ListResources("")
// Read a resource
resource, err := client.ReadResource("resource-uri")
// Call a tool
result, err := client.CallTool("tool-name", map[string]interface{}{
"argument1": "value1",
"argument2": 123,
})
// Get a prompt
prompt, err := client.GetPrompt("prompt-name", map[string]string{
"argName": "argValue",
})
}
Implementation Details
Schema
The Go schema definitions in mcp/schema.go
provide type-safe structures for MCP messages. This includes:
- JSON-RPC protocol structures
- Resource, Prompt, and Tool definitions
- Content structures for text, images, and embedded resources
- Helper functions for handling polymorphic types via
json.RawMessage
Client
The client implementation in mcp/client.go
provides methods for:
- Initializing connections to MCP servers
- Sending requests and handling responses
- Converting Go structs to JSON-RPC messages
- Helper methods for common MCP operations
Contributing
Contributions are welcome! Here are some ways you can contribute:
- Implement a server
- Add WebSocket support to the client
- Improve error handling
- Add tests
- Document additional use cases
License
This project is licensed under the MIT License - see the LICENSE file for details.
References
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
MCP Package Docs Server
Facilitates LLMs to efficiently access and fetch structured documentation for packages in Go, Python, and NPM, enhancing software development with multi-language support and performance optimization.
Claude Code MCP
An implementation of Claude Code as a Model Context Protocol server that enables using Claude's software engineering capabilities (code generation, editing, reviewing, and file operations) through the standardized MCP interface.
@kazuph/mcp-taskmanager
Model Context Protocol server for Task Management. This allows Claude Desktop (or any MCP client) to manage and execute tasks in a queue-based system.
Linear MCP Server
Enables interaction with Linear's API for managing issues, teams, and projects programmatically through the Model Context Protocol.
mermaid-mcp-server
A Model Context Protocol (MCP) server that converts Mermaid diagrams to PNG images.
Jira-Context-MCP
MCP server to provide Jira Tickets information to AI coding agents like Cursor

Linear MCP Server
A Model Context Protocol server that integrates with Linear's issue tracking system, allowing LLMs to create, update, search, and comment on Linear issues through natural language interactions.

Sequential Thinking MCP Server
This server facilitates structured problem-solving by breaking down complex issues into sequential steps, supporting revisions, and enabling multiple solution paths through full MCP integration.