# Mcp Sdk Go

> A professional, high-performance implementation of the Model Context Protocol (MCP) specification (2025-03-26) in Go.

- **Type:** MCP server
- **Install:** `agentstack add mcp-ajitpratap0-mcp-sdk-go`
- **Verified:** Yes — security-reviewed for prompt injection and unsafe behavior
- **Seller:** [ajitpratap0](https://agentstack.voostack.com/s/ajitpratap0)
- **Installs:** 0
- **Category:** [AI & ML](https://agentstack.voostack.com/c/ai-and-ml)
- **Latest version:** 0.1.0
- **License:** MIT
- **Upstream author:** [ajitpratap0](https://github.com/ajitpratap0)
- **Source:** https://github.com/ajitpratap0/mcp-sdk-go

## Install

```sh
agentstack add mcp-ajitpratap0-mcp-sdk-go
```

Requires the [AgentStack CLI](https://agentstack.voostack.com/docs/cli). Works with Claude Code, Cursor, and any MCP-compatible agent.

## About

# Model Context Protocol Go SDK

> **Enterprise-Grade MCP Implementation** • **98% Specification Compliance** • **Production Ready**

A comprehensive, high-performance implementation of the [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) specification in Go, featuring enterprise authentication, observability, and developer tools.

[](https://pkg.go.dev/github.com/ajitpratap0/mcp-sdk-go)
[](https://github.com/ajitpratap0/mcp-sdk-go/blob/main/LICENSE)
[](https://codecov.io/gh/ajitpratap0/mcp-sdk-go)
[](https://goreportcard.com/report/github.com/ajitpratap0/mcp-sdk-go)
[](https://github.com/ajitpratap0/mcp-sdk-go/actions)

## 🎯 Overview

This SDK provides the **most comprehensive Go implementation** of the Model Context Protocol, designed for production deployments with enterprise-grade features:

- **🏗️ Production Ready**: Enterprise authentication, observability, and deployment tools
- **⚡ High Performance**: Sub-10ms latency, 50,000+ ops/s batch throughput, zero memory leaks
- **🔐 Enterprise Security**: Bearer tokens, API keys, RBAC, rate limiting, and session management
- **📊 Full Observability**: OpenTelemetry tracing, Prometheus metrics, and comprehensive monitoring
- **🛠️ Developer Experience**: Hot reload server, code generation, protocol validation, and debugging tools
- **🚀 Cloud Native**: Docker/Kubernetes deployment, auto-scaling, and production monitoring

### 📈 **Project Status**
- **MCP Compliance**: 98% specification compliant
- **Test Coverage**: 40+ test files with >85% coverage
- **Architecture**: Modern, middleware-based design with configuration-driven approach
- **Production Deployments**: Battle-tested enterprise features

## 🌟 **Key Features**

### 🏗️ **Core Protocol**
- **Full JSON-RPC 2.0 Implementation** with batch processing support
- **Complete MCP Lifecycle Management** with capability negotiation
- **Modern Configuration-Driven Architecture** with middleware composition
- **Comprehensive Error Handling** with proper MCP error codes and recovery

### 🚀 **Transport Layer**
- **Intelligent Transport Selection**: Stdio (MCP required) and Streamable HTTP with reliability
- **Built-in Middleware Stack**: Authentication, rate limiting, observability, and reliability
- **Connection Management**: Pooling, retry logic, circuit breakers, and graceful degradation
- **Batch Processing**: High-performance JSON-RPC 2.0 batch operations

### 🔐 **Enterprise Authentication**
- **Pluggable Auth Providers**: Bearer tokens, API keys, extensible for OAuth2/OIDC
- **Role-Based Access Control (RBAC)**: Hierarchical permissions with inheritance
- **Rate Limiting**: Token bucket algorithm with per-user/per-token/global limits
- **Session Management**: Secure token generation, caching, and lifecycle management

### 📊 **Production Observability**
- **OpenTelemetry Integration**: Distributed tracing with OTLP, gRPC, and HTTP exporters
- **Prometheus Metrics**: MCP-specific metrics with custom dashboards
- **Performance Monitoring**: Sub-millisecond latency tracking and regression detection
- **Health Checks**: Comprehensive health endpoints with dependency monitoring

### 🛠️ **Developer Experience**
- **Hot Reload Development Server**: File watching with real-time dashboard
- **Code Generation Tools**: Provider scaffolding with comprehensive templates
- **Protocol Validation**: MCP compliance testing and performance benchmarking
- **Advanced Debugging**: Request tracing, error analysis, and performance profiling

### 🏢 **Production Deployment**
- **Container Support**: Docker images with multi-stage builds and security scanning
- **Kubernetes Integration**: Helm charts, operators, and auto-scaling configurations
- **Load Balancing**: HAProxy configurations and traffic management
- **Monitoring Stack**: Grafana dashboards, Prometheus, and alerting rules

## 🚀 **Quick Start**

### Basic Client

```go
import (
    "context"
    "log"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/client"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/protocol"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/transport"
)

func main() {
    // Modern config-driven transport creation
    config := transport.DefaultTransportConfig(transport.TransportTypeStreamableHTTP)
    config.Endpoint = "https://api.example.com/mcp"

    // Enable enterprise features
    config.Features.EnableAuthentication = true
    config.Features.EnableObservability = true
    config.Features.EnableReliability = true

    transport, err := transport.NewTransport(config)
    if err != nil {
        log.Fatal(err)
    }

    client := client.New(transport,
        client.WithName("MyClient"),
        client.WithVersion("1.0.0"),
        client.WithCapability(protocol.CapabilitySampling, true),
    )

    ctx := context.Background()
    if err := client.Initialize(ctx); err != nil {
        log.Fatal(err)
    }
    defer client.Close()

    // Use client with automatic pagination and error handling
    allTools, err := client.ListAllTools(ctx, "")
    if err != nil {
        log.Printf("Error listing tools: %v", err)
        return
    }

    for _, tool := range allTools {
        log.Printf("Tool: %s - %s", tool.Name, tool.Description)
    }
}
```

### Enterprise Server

```go
import (
    "context"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/server"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/transport"
    "github.com/ajitpratap0/mcp-sdk-go/pkg/auth"
)

func main() {
    // Configure enterprise-grade transport
    config := transport.DefaultTransportConfig(transport.TransportTypeStreamableHTTP)
    config.Endpoint = "https://api.example.com/mcp"

    // Enable authentication
    config.Features.EnableAuthentication = true
    config.Security.Authentication = &transport.AuthenticationConfig{
        Type:        "bearer",
        Required:    true,
        TokenExpiry: 10 * time.Minute,
    }

    // Enable comprehensive observability
    config.Features.EnableObservability = true
    config.Observability.EnableMetrics = true
    config.Observability.EnableTracing = true
    config.Observability.EnableLogging = true

    transport, err := transport.NewTransport(config)
    if err != nil {
        log.Fatal(err)
    }

    server := server.New(transport,
        server.WithName("Enterprise MCP Server"),
        server.WithVersion("2.0.0"),
        server.WithToolsProvider(createEnterpriseToolsProvider()),
        server.WithResourcesProvider(createResourcesProvider()),
    )

    ctx := context.Background()
    log.Println("Starting enterprise MCP server...")
    if err := server.Start(ctx); err != nil {
        log.Fatal(err)
    }
}
```

## 📚 **Comprehensive Examples**

### 🏗️ **Core Examples**
- **[Simple Server](examples/simple-server/)** - Basic MCP server implementation
- **[Streamable HTTP Client/Server](examples/streamable-http-*)** - HTTP transport examples
- **[Stdio Client](examples/stdio-client/)** - Standard stdio transport
- **[Batch Processing](examples/batch-processing/)** - High-performance batch operations
- **[Pagination](examples/pagination-example/)** - Manual and automatic pagination

### 🔐 **Enterprise Features**
- **[Authentication](examples/authentication/)** - Bearer tokens, API keys, RBAC integration
- **[Observability](examples/observability/)** - OpenTelemetry tracing and Prometheus metrics
- **[Metrics Reporting](examples/metrics-reporting/)** - Comprehensive monitoring and alerting
- **[Error Recovery](examples/error-recovery/)** - Advanced error handling patterns

### 🛠️ **Developer Tools**
- **[Development Server](examples/development-server/)** - Hot reload with live dashboard
- **[Code Generator](examples/code-generator/)** - Provider scaffolding and templates
- **[Protocol Validator](examples/protocol-validator/)** - MCP compliance testing
- **[Custom Transport](examples/custom-transport/)** - Building custom transport implementations

### 🏢 **Production Deployment**
- **[Production Deployment](examples/production-deployment/)** - Docker, Kubernetes, monitoring
- **[Multi-Server Setup](examples/multi-server/)** - Load balancing and failover
- **[LLM Integration](examples/llm-completion/)** - AI provider integration patterns
- **[Plugin Architecture](examples/plugin-architecture/)** - Extensible provider system

## 🏗️ **Architecture**

### Layered Design

```
┌─────────────────────────────────────────────────────────┐
│  Examples & Production Deployments                     │
├─────────────────────────────────────────────────────────┤
│  Client & Server APIs                                  │
│  • Authentication & Authorization                      │
│  • Resource Management & Subscriptions                 │
│  • Tool Execution & Context Management                 │
├─────────────────────────────────────────────────────────┤
│  Middleware Stack                                      │
│  • Authentication (Bearer, API Key, RBAC)             │
│  • Rate Limiting (Token Bucket Algorithm)             │
│  • Observability (OpenTelemetry, Prometheus)          │
│  • Reliability (Retries, Circuit Breakers)            │
├─────────────────────────────────────────────────────────┤
│  Transport Layer                                       │
│  • StdioTransport (MCP Required)                      │
│  • StreamableHTTPTransport (Production)               │
│  • Custom Transport Interface                         │
├─────────────────────────────────────────────────────────┤
│  Protocol Layer                                        │
│  • JSON-RPC 2.0 with Batch Processing                │
│  • MCP Message Types & Validation                     │
│  • Error Handling & Recovery                          │
├─────────────────────────────────────────────────────────┤
│  Core Utilities                                        │
│  • Pagination & Collection Management                 │
│  • Schema Validation & Type Safety                    │
│  • Performance Benchmarking & Testing                 │
└─────────────────────────────────────────────────────────┘
```

### Modern Configuration System

```go
// Enterprise transport configuration
config := transport.DefaultTransportConfig(transport.TransportTypeStreamableHTTP)

// Security configuration
config.Security.Authentication = &transport.AuthenticationConfig{
    Type:         "bearer",
    Required:     true,
    TokenExpiry:  10 * time.Minute,
    EnableCache:  true,
    CacheTTL:     5 * time.Minute,
}

config.Security.RateLimit = &transport.RateLimitConfig{
    RequestsPerMinute: 1000,
    BurstLimit:       100,
    EnablePerUser:    true,
}

// Observability configuration
config.Observability.Tracing = &transport.TracingConfig{
    EnableTracing:    true,
    ServiceName:      "mcp-server",
    SamplingRate:     0.1,
    ExporterType:     "otlp",
    ExporterEndpoint: "http://jaeger:14268/api/traces",
}

config.Observability.Metrics = &transport.MetricsConfig{
    EnableMetrics:    true,
    MetricsPath:      "/metrics",
    EnableCustom:     true,
    ExporterType:     "prometheus",
}

// Reliability configuration
config.Reliability.Retry = &transport.RetryConfig{
    EnableRetry:        true,
    MaxRetries:         3,
    InitialDelay:       time.Second,
    MaxDelay:          30 * time.Second,
    BackoffMultiplier: 2.0,
}

transport, err := transport.NewTransport(config)
```

## 📊 **Performance & Benchmarks**

### Performance Targets (All Met)
- **Latency**: P99 85% coverage, race detection
- **⚡ Performance**: Sub-10ms latency, 50,000+ ops/s throughput
- **🔐 Security**: Enterprise authentication, RBAC, rate limiting
- **📊 Observability**: OpenTelemetry, Prometheus, comprehensive monitoring
- **🛠️ Developer Experience**: Hot reload, code generation, protocol validation
- **🏢 Production**: Docker/K8s deployment, auto-scaling, monitoring

## 📄 **License**

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

---

**Built for Production** • **Enterprise Ready** • **Developer Friendly**

*The most comprehensive Model Context Protocol implementation for Go*

## Source & license

This open-source MCP server is cataloged on AgentStack and links to its original source — we do not rehost the code.

- **Author:** [ajitpratap0](https://github.com/ajitpratap0)
- **Source:** [ajitpratap0/mcp-sdk-go](https://github.com/ajitpratap0/mcp-sdk-go)
- **License:** MIT

Install and usage instructions live in the source repository linked above.

## Pricing

- **Free** — Free

## Security capabilities

Automated source analysis of v0.1.0 — what this tool can access:

- **Network access:** no
- **Filesystem access:** no
- **Shell / process execution:** no
- **Environment & secrets:** no
- **Dynamic code execution:** no

*"Yes" means the capability is present in the source — more access means more to trust, not that it is unsafe.*


## Versions

- **0.1.0** — security scan: passed — Imported from the upstream source.

## Links

- Listing page: https://agentstack.voostack.com/l/mcp-ajitpratap0-mcp-sdk-go
- Seller: https://agentstack.voostack.com/s/ajitpratap0
- Browse the marketplace: https://agentstack.voostack.com/browse

---
Listed on AgentStack — the marketplace for AI agent skills and MCP servers. Every listing is security-reviewed. Creators keep 70%.
