go-mcp-server

febriansyahnr/go-mcp-server

3.2

If you are the rightful owner of go-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

pg-mcp-go is an enterprise-grade Model Context Protocol (MCP) server built in Go, offering comprehensive infrastructure integrations.

Tools
  1. calculator

    A tool for performing basic arithmetic operations.

pg-mcp-go

pg-mcp-go is an enterprise-grade Model Context Protocol (MCP) server built in Go by Paper Indonesia Development Team. It provides MCP tools as HTTP/SSE services with comprehensive enterprise infrastructure integrations including databases, caching, messaging, monitoring, and observability.

Features

  • MCP Protocol Support: Full implementation of Model Context Protocol with HTTP and SSE endpoints
  • Enterprise Infrastructure: Built-in integrations for MySQL, Redis, RabbitMQ, and cloud services
  • Clean Architecture: Layered architecture with clear separation of concerns
  • Comprehensive Observability: OpenTelemetry tracing, metrics collection, and structured logging
  • Production Ready: Circuit breakers, rate limiting, health checks, and error handling
  • Extensible Tool System: Easy-to-add MCP tools with schema validation

Project Structure

pg-mcp-go/
ā”œā”€ā”€ cmd/                        # CLI commands and server setup
│   ā”œā”€ā”€ cmd.go                  # Root command configuration
│   ā”œā”€ā”€ serveHTTP.go           # HTTP server command
│   └── setupMCP.go            # MCP server setup
ā”œā”€ā”€ config/                     # Configuration management
│   ā”œā”€ā”€ config.go              # Application configuration
│   ā”œā”€ā”€ secret.go              # Secret management
│   └── ...
ā”œā”€ā”€ constant/                   # Application constants
│   ā”œā”€ā”€ constant.go            # General constants
│   ā”œā”€ā”€ error.go               # Error constants
│   └── ...
ā”œā”€ā”€ internal/                   # Private application code
│   ā”œā”€ā”€ handlers/              # Request handlers
│   │   ā”œā”€ā”€ extra/             # MCP tool handlers
│   │   │   ā”œā”€ā”€ calculator_handler.go
│   │   │   └── type.go
│   │   └── handlers.go
│   ā”œā”€ā”€ model/                 # Data structures
│   │   ā”œā”€ā”€ common/            # Common models
│   │   ā”œā”€ā”€ disbursement/      # Domain-specific models
│   │   └── model.go
│   ā”œā”€ā”€ repository/            # Data access layer
│   │   ā”œā”€ā”€ backendPortal/     # Backend portal repository
│   │   └── repository.go
│   └── service/               # Business logic layer
│       └── service.go
ā”œā”€ā”€ pkg/                       # Reusable packages
│   ā”œā”€ā”€ consulExt/             # Consul service discovery
│   ā”œā”€ā”€ dictionary/            # Data dictionary utilities
│   ā”œā”€ā”€ error/                 # Error handling utilities
│   ā”œā”€ā”€ gcs/                   # Google Cloud Storage
│   ā”œā”€ā”€ httpRequestExt/        # HTTP client extensions
│   ā”œā”€ā”€ logger/                # Structured logging
│   ā”œā”€ā”€ monitor/               # Monitoring utilities
│   ā”œā”€ā”€ mySqlExt/              # MySQL extensions
│   ā”œā”€ā”€ rabbitMqExt/           # RabbitMQ messaging
│   ā”œā”€ā”€ redisExt/              # Redis caching
│   ā”œā”€ā”€ slackExt/              # Slack notifications
│   ā”œā”€ā”€ util/                  # General utilities
│   └── validatorExt/          # Validation extensions
ā”œā”€ā”€ tools/                     # MCP tool definitions
│   ā”œā”€ā”€ calculator.go          # Calculator tool schema
│   └── tools.go               # Tool registry
ā”œā”€ā”€ mocks/                     # Generated test mocks
ā”œā”€ā”€ main.go                    # Application entry point
ā”œā”€ā”€ Makefile                   # Build and development commands
ā”œā”€ā”€ CLAUDE.md                  # Claude Code instructions
└── README.md                  # This file

Quick Start

Prerequisites

  • Go 1.24.2+
  • MySQL database
  • Redis server
  • RabbitMQ (optional)

Installation

  1. Clone the repository:
git clone <repository-url>
cd pg-mcp-go
  1. Install dependencies:
go mod download
  1. Configure the application:
# Copy and edit configuration files
cp .config.yaml.example .config.yaml
cp .secret.yaml.example .secret.yaml
  1. Start the HTTP server:
go run main.go serveHTTP --config .config.yaml --secret .secret.yaml

Development Commands

# Run HTTP server
go run main.go serveHTTP --config .config.yaml --secret .secret.yaml

# Run SSE server
make run-sse

# Run consumer mode
make run-consumer

# Run tests
go test ./...

# Generate mocks
make gen-mocks

Architecture

Clean Architecture Layers

  • cmd/: CLI commands and server setup using Cobra
  • internal/: Private application code with handlers, services, and repositories
  • pkg/: Reusable packages with enterprise integrations
  • tools/: MCP tool definitions and schemas

Enterprise Infrastructure

  • Database: MySQL with master/slave configuration via PDK
  • Caching: Redis with rate limiting and distributed locking
  • Messaging: RabbitMQ for async communication
  • Monitoring: New Relic, OpenTelemetry, Statsd via PDK
  • Service Discovery: Consul integration
  • Secrets: Vault for production secret management
  • Cloud Storage: Google Cloud Storage integration

MCP Tool Development

Adding New Tools

  1. Define tool schema in tools/ directory
  2. Implement handler in internal/handlers/extra/
  3. Register tool in MCP server setup

Example Tool

// Define tool schema in tools/
var NewTool = mcp.NewTool("tool_name",
    mcp.WithDescription("Tool description"),
    mcp.WithString("param1", mcp.Required(), mcp.Description("Parameter description")),
)

// Implement handler in internal/handlers/extra/
func (h *Handler) HandleToolName(ctx context.Context, params map[string]interface{}) (*mcp.CallToolResult, error) {
    // Implementation
}

Configuration

The application uses two configuration files:

  • .config.yaml: Application settings and service endpoints
  • .secret.yaml: Sensitive data (database credentials, API keys)

Both files are required for all server commands.

Testing

The project uses comprehensive testing with mock generation:

# Run all tests
go test ./...

# Run specific package tests
go test -v ./pkg/util/...
go test -v ./internal/service/...

# Generate mocks after interface changes
make gen-mocks

Dependencies

Core Dependencies

  • PDK: github.com/paper-indonesia/pdk/v2 - Platform Development Kit for standardized integrations
  • MCP Framework: github.com/mark3labs/mcp-go - MCP protocol implementation
  • Cobra: CLI framework for command-line interface
  • Viper: Configuration management

Enterprise Integrations

  • MySQL with connection pooling and tracing
  • Redis with distributed locking and rate limiting
  • RabbitMQ for async messaging
  • OpenTelemetry for observability
  • New Relic for monitoring
  • Consul for service discovery

Contributing

  1. Follow the established architecture patterns
  2. Add tests for new functionality
  3. Generate mocks after interface changes: make gen-mocks
  4. Ensure all tests pass: go test ./...
  5. Follow Go best practices and the existing code style

License

[Add license information here]

Support

[Add support information here]

Contributors