go-common-mcp-server
v2.0.0MCP server for browsing go-common modules, examples, and documentation.
A collection of production-ready, framework-agnostic Go packages for building backend services. Each module contains its own detailed README.md with usage examples and API references. Please navigate to the respective package directory to learn more: For new services, use foundation as the single owner of startup, OS signals, runtime supervision, readiness, and graceful shutdown.
Summary extracted from the README.
go-common
A collection of production-ready, framework-agnostic Go packages for building backend services.
Packages
| Package | Description |
|---|---|
foundation |
Supervised component lifecycle with startup rollback, runtime failure handling, graceful shutdown, and health state |
logger |
Async structured logger (log/slog) with optional lumberjack file rotation |
config |
Environment variable and configuration file loader (Viper wrapper) |
xerrors |
Structured error handling with HTTP status codes and string codes |
recovery |
Framework-independent structured panic capture with net/http / Fiber / Gin / Echo middleware adapters |
redis |
Redis client wrapper (single / cluster / sentinel) with health-check |
nats |
NATS client wrapper — Core Pub/Sub, JetStream streams/consumers, KV Store |
kafka |
Apache Kafka client wrapper (franz-go) — Producer, Consumer, Admin, TLS/SASL |
eventbus |
Transport-neutral, at-least-once task and event delivery over Memory, Redis Streams, NATS JetStream, and Kafka |
websocket |
Clustered, framework-agnostic real-time WebSocket server (net/http / Fiber / Gin / Echo) |
telemetry |
OpenTelemetry integration for distributed tracing and metrics via OTLP |
db |
Database abstraction (GORM & MongoDB) with auto-instrumented telemetry |
web |
Web core utilities (standard response, validator, net/http / Fiber / Gin / Echo middleware adapters) |
graphql |
Framework-agnostic GraphQL engine with Generic DataLoader & Telemetry |
utils |
Go Generics and cryptography helpers; includes legacy standalone graceful shutdown for applications not using foundation |
cache |
Multi-tier Caching (Ristretto Local + Redis Remote) & Redis Distributed Lock |
auth |
Enterprise Authentication with Encrypted JWT (AES-GCM) and Dynamic Token Binding |
httpclient |
Resilient REST Client with Circuit Breaker (gobreaker) and Auto-Retry |
ratelimit |
Distributed Rate Limiter (Fixed Window) using Redis Lua scripting |
cron |
Job scheduler with renewable Redis leases, slot deduplication, and graceful shutdown |
health |
Kubernetes-ready health checks (/live, /ready) with concurrent Checkers and HTTP adapters |
grpc |
Pre-configured gRPC server with unified Interceptors (Recovery, Logging, Auth) |
Requirements
- Go 1.26+
- Redis 6.x+ (Redis 6.2+ recommended for
XAUTOCLAIMsupport) - NATS Server 2.10+ with JetStream enabled (
-jsflag orjetstream: enabledin config) - Apache Kafka 2.8+ (or compatible brokers like Redpanda)
Installation
go get github.com/thanhbvha/go-common
Documentation
Each module contains its own detailed README.md with usage examples and API references. Please navigate to the respective package directory to learn more:
foundation— runnable lifecycle examplesloggerconfigxerrorsrecoveryredisnatskafkaeventbus— runnable exampleswebsockettelemetrydbwebgraphqlutilscacheauthhttpclientratelimitcronhealthgrpc
HTTP support matrix
| Capability | Core | net/http |
Fiber | Gin | Echo |
|---|---|---|---|---|---|
| Authentication | auth managers |
Middleware | Middleware | Middleware | Middleware |
| Request logging / ID | logger, ctxkey |
Middleware | Middleware | Middleware | Middleware |
| Health probes | health.Checker |
Handler | Handler | Handler | Handler |
| Rate limiting | ratelimit.Limiter |
Middleware | Middleware | Middleware | Middleware |
| Responses / recovery / telemetry | web primitives |
Adapter | Adapter | Adapter | Adapter |
| GraphQL | http.Handler |
Direct | Adapter | Adapter | Adapter |
| WebSocket | core.Conn |
Adapter | Adapter | Adapter | Adapter |
Lifecycle Selection
For new services, use foundation as the single owner of startup, OS signals,
runtime supervision, readiness, and graceful shutdown.
- Register dependencies with
foundation.Resourceorfoundation.Component. - Register long-running jobs with
foundation.Worker. - Register net/http, Fiber, or gRPC servers with the adapters under
foundation/adapter. - Finish
mainwithapp.Run(ctx); do not start server goroutines manually. - Do not combine a Foundation app with
utils/graceful. Two lifecycle coordinators can handle the same signal, close a resource twice, or violate dependency shutdown order. - Use
utils/gracefulfor small standalone processes that need a focused, one-shot shutdown coordinator without Foundation's runtime supervision. - If another process or host owns OS signals, create Foundation with
foundation.WithoutSignals()and control it through the parent context orapp.Shutdown(ctx).
Agents and MCP integrations should read the
foundation lifecycle contract and the
foundation examples before generating a
service bootstrap.
🤖 AI / MCP Integration (Cursor, Cline, VSCode)
This library is fully agentic. We provide an official Model Context Protocol (MCP) server that allows AI coding assistants to instantly fetch and read the latest source code, architectural rules, and boilerplate code directly from both our root modules and the examples/ directory.
This guarantees that the AI writes code adhering to our strict standards (e.g., proper graceful shutdown, structured error handling) and can adapt to the most recent changes in the library without leaving the editor.
Setup for Cursor IDE
- Open Cursor Settings -> Features -> MCP
- Click + Add New MCP Server
- Configure as follows:
- Type:
command - Command:
npx - Args:
-y go-common-mcp-server@latest
- Type:
Setup for VSCode (Cline)
Add this to your cline_mcp_settings.json:
{
"mcpServers": {
"go-common": {
"command": "npx",
"args": ["-y", "go-common-mcp-server@latest"]
}
}
}
License
This project is free and open-source software licensed under the MIT License.