Trino MCP Server in Go
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
A high-performance Model Context Protocol (MCP) server for Trino implemented in Go. This project enables AI assistants to seamlessly interact with Trino's distributed SQL query engine through standardized MCP tools.
Overview
This project implements a Model Context Protocol (MCP) server for Trino in Go. It enables AI assistants to access Trino's distributed SQL query engine through standardized MCP tools.
Trino (formerly PrestoSQL) is a powerful distributed SQL query engine designed for fast analytics on large datasets.
Architecture
**Key Components:**
- **AI Clients**: Various MCP-compatible applications
- **Authentication**: Optional OAuth 2.0 with OIDC providers
- **MCP Server**: Go-based server with dual transport support
- **CLI Mode**: Interactive SQL shell for direct Trino access (psql-like)
- **Data Layer**: Trino cluster connecting to multiple data sources
Features
- ✅ **Dual Mode**: Works as both MCP server AND interactive CLI
- **CLI Mode**: psql-like interactive SQL shell for direct Trino access
- **MCP Mode**: Full MCP server for AI assistant integration
- ✅ MCP server implementation in Go
- ✅ Trino SQL query execution through MCP tools
- ✅ Catalog, schema, and table discovery
- ✅ Docker container support
- ✅ Supports both STDIO and HTTP transports
- ✅ OAuth 2.1 authentication via oauth-mcp-proxy library
- **4 Providers**: HMAC, Okta, Google, Azure AD
- **Native mode**: Client handles OAuth directly (zero server-side secrets)
- **Proxy mode**: Server proxies OAuth flow for simple clients
- **Production-ready**: Token caching, PKCE, defense-in-depth security
- **Reusable**: OAuth library available for any Go MCP server
- ✅ StreamableHTTP support with JWT authentication (upgraded from SSE)
- ✅ Backward compatibility with SSE endpoints
- ✅ Compatible with Cursor, Claude Desktop, Windsurf, ChatWise, and any MCP-compatible clients.
- ✅ User Identity Tracking:
- **Query Attribution** (automatic): Tags queries with OAuth user via X-Trino-Client-Tags/Info headers
- **User Impersonation** (opt-in): Execute queries as OAuth user via X-Trino-User header
Installation & Quick Start
**Install:**
**Run (Local Development):**
For production deployment with OAuth, see Deployment Guide and OAuth Architecture.
CLI Mode
mcp-trino can be used as an interactive CLI similar to psql or the Trino CLI:
Built-in Help
Every command has structured, LLM-friendly help output:
Help output follows Unix man-page conventions with sections: NAME, SYNOPSIS, DESCRIPTION, COMMANDS, FLAGS, EXAMPLES, ENVIRONMENT, and CONFIGURATION.
Exit Codes
| Code | Meaning |
|------|---------|
| 0 | Success |
| 1 | Runtime error (connection failed, query error, etc.) |
| 2 | Usage error (unknown command, invalid flags, missing arguments) |
Named Profiles
mcp-trino supports named connection profiles for easy switching between Trino environments.
**Configuration File** — supports both YAML (~/.config/trino/config.yaml) and JSON (~/.config/trino/config.json):
Or equivalently in JSON:
When both files exist, config.json takes precedence. New configs default to JSON.
**Profile Management Commands:**
**Configuration Precedence** (highest to lowest):
1. CLI flags (--host, --port, etc.)
2. --profile flag
3. TRINO_PROFILE environment variable
4. current field in config file
5. default profile fallback
6. Environment variables (TRINO_HOST, etc.)
**Environment Variables** (lowest priority - overridden by profiles and flags):