Trino Model Context Protocol MCP Server in Go
Deploy a high-performance MCP server for Trino in Go to accelerate model context handling, scale queries, and simplify integration.
npx -y @tuannvm/mcp-trinoOverview
The Trino Model Context Protocol (MCP) server is a lightweight, high-performance Go service that exposes model context from Trino for use by language models and other AI systems. It turns Trino SQL query results into consumable context blocks via a simple HTTP/JSON API, so model-serving systems can fetch up-to-date structured data and textual context without embedding Trino access logic into the model runtime.
Designed for production use, the server focuses on low latency, concurrent request handling, and operational observability. Developers can run it as a standalone service, inside containers, or on Kubernetes to centralize context retrieval, apply caching and rate-limiting, and provide a consistent interface for multiple model consumers.
Features
- Trino-backed context retrieval: run SQL against Trino and return results formatted for model consumption.
- Go-based implementation for low latency and small resource footprint.
- HTTP/JSON API compatible with MCP-style client workflows.
- Connection pooling and concurrent query execution to scale throughput.
- Configurable SQL templates and request limits to guard downstream models.
- Docker image and straightforward build-from-source workflow.
- Operational endpoints: health checks and Prometheus metrics.
- Flexible configuration via environment variables or YAML file.
- Structured logging and graceful shutdown for safe deployments.
Installation / Configuration
Build from source:
Run a local binary (example environment variables):
Docker (build and run):
# Build image locally
# Run container with environment variables
Sample YAML configuration (if supported):
server:
addr: ":8080"
trino:
coordinator: "http://trino-coordinator:8080"
catalog: "hive"
schema: "default"
limits:
max_rows: 1000
max_concurrency: 20
logging:
level: "info"
metrics:
enabled: true
Common environment variables
| Variable | Purpose | Default |
|---|---|---|
| TRINO_COORDINATOR | Trino coordinator URL | required |
| TRINO_CATALOG | Trino catalog | none |
| TRINO_SCHEMA | Trino schema | none |
| MCP_ADDR | HTTP listen address | :8080 |
| LOG_LEVEL | logging verbosity | info |
| CACHE_SIZE | optional in-memory cache size | 0 (disabled) |
Adjust limits (max rows, per-request timeouts, and concurrency) to protect Trino and downstream model runtimes.
Available Resources
Typical HTTP endpoints (defaults — check configuration):
| Endpoint | Method | Purpose |
|---|---|---|
| /mcp/context | POST | Submit a context request (query/template) and receive model-ready context |
| /healthz | GET | Liveness and readiness probe |
| /metrics | GET | Prometheus metrics endpoint |
Example request payload (JSON):
Example response (JSON):
Notes
- The server can format rows as JSON, plain text, or other model-friendly shapes depending on configuration.
- Metrics include request latencies, query counts, and connection pool statistics.
Use Cases
- Retrieval-augmented generation (RAG): use Trino to fetch compact document snippets or metadata that an LLM should condition on. The MCP server centralizes SQL, formatting, and limits so LLM clients only call a single HTTP endpoint.
- Multi-tenant model context service: provide a shared context API in front of Trino for many model processes, allowing observability, caching, and enforcement of per-tenant quotas.
- Real-time context stitching: combine recent events or time-series slices (queried from Trino) into a single context payload for conversational agents that need up-to-date facts.
- Offloading query logic from model servers: keep SQL templates and schema access in the MCP server so model