TR

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.

Quick Install
npx -y @tuannvm/mcp-trino

Overview

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:

git clone https://github.com/tuannvm/mcp-trino.git
cd mcp-trino
go build -o mcp-trino ./cmd/server

Run a local binary (example environment variables):

export TRINO_COORDINATOR=http://trino-coordinator:8080
export TRINO_CATALOG=hive
export TRINO_SCHEMA=default
export MCP_ADDR=:8080
./mcp-trino

Docker (build and run):

# Build image locally
docker build -t mcp-trino:latest .

# Run container with environment variables
docker run -d --name mcp-trino \
  -e TRINO_COORDINATOR=http://trino-coordinator:8080 \
  -e TRINO_CATALOG=hive \
  -e TRINO_SCHEMA=default \
  -p 8080:8080 \
  mcp-trino:latest

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

VariablePurposeDefault
TRINO_COORDINATORTrino coordinator URLrequired
TRINO_CATALOGTrino catalognone
TRINO_SCHEMATrino schemanone
MCP_ADDRHTTP listen address:8080
LOG_LEVELlogging verbosityinfo
CACHE_SIZEoptional in-memory cache size0 (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):

EndpointMethodPurpose
/mcp/contextPOSTSubmit a context request (query/template) and receive model-ready context
/healthzGETLiveness and readiness probe
/metricsGETPrometheus metrics endpoint

Example request payload (JSON):

{
  "query": "SELECT id, title, content FROM articles WHERE topic = ? LIMIT ?",
  "params": ["ai", 20],
  "format": "json_lines"
}

Example response (JSON):

{
  "context": [
    {"id": 123, "title": "Intro to AI", "content": "Artificial intelligence ..."},
    {"id": 124, "title": "Scaling Trino", "content": "Trino scales by ..."}
  ],
  "meta": {
    "rows": 2,
    "query_time_ms": 45
  }
}

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