febriansyahnr/go-mcp-server
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.
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
- Clone the repository:
git clone <repository-url>
cd pg-mcp-go
- Install dependencies:
go mod download
- Configure the application:
# Copy and edit configuration files
cp .config.yaml.example .config.yaml
cp .secret.yaml.example .secret.yaml
- 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
- Define tool schema in
tools/
directory - Implement handler in
internal/handlers/extra/
- 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
- Follow the established architecture patterns
- Add tests for new functionality
- Generate mocks after interface changes:
make gen-mocks
- Ensure all tests pass:
go test ./...
- Follow Go best practices and the existing code style
License
[Add license information here]
Support
[Add support information here]