io.github.tuannvm/mcp-trino
平台与服务by tuannvm
用于访问 Trino 分布式 SQL 查询引擎的 MCP server,便于统一执行与管理查询。
把 Trino 查询纳入统一工具链时很省心,借助 MCP 接口集中执行和管理 SQL,比零散脚本对接更稳也更好维护。
什么是 io.github.tuannvm/mcp-trino?
用于访问 Trino 分布式 SQL 查询引擎的 MCP server,便于统一执行与管理查询。
README
Trino MCP Server in Go
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
graph TB
subgraph "AI Clients"
CC[Claude Code]
CD[Claude Desktop]
CR[Cursor]
WS[Windsurf]
CW[ChatWise]
end
subgraph "Authentication (Optional)"
OP[OAuth Provider<br/>Okta/Google/Azure AD]
JWT[JWT Tokens]
end
subgraph "MCP Server (mcp-trino)"
HTTP[HTTP Transport<br/>/mcp endpoint]
STDIO[STDIO Transport]
AUTH[OAuth Middleware]
TOOLS[MCP Tools<br/>• execute_query<br/>• list_catalogs<br/>• list_schemas<br/>• list_tables<br/>• get_table_schema<br/>• explain_query]
end
subgraph "Data Layer"
TRINO[Trino Cluster<br/>Distributed SQL Engine]
CATALOGS[Data Sources<br/>• PostgreSQL<br/>• MySQL<br/>• S3/Hive<br/>• BigQuery<br/>• MongoDB]
end
%% Connections
CC -.->|OAuth Flow| OP
OP -.->|JWT Token| JWT
CC -->|HTTP + JWT| HTTP
CD -->|STDIO| STDIO
CR -->|HTTP + JWT| HTTP
WS -->|STDIO| STDIO
CW -->|HTTP + JWT| HTTP
HTTP --> AUTH
AUTH -->|Validated| TOOLS
STDIO --> TOOLS
TOOLS -->|SQL Queries| TRINO
TRINO --> CATALOGS
%% Styling
classDef client fill:#e1f5fe
classDef auth fill:#f3e5f5
classDef server fill:#e8f5e8
classDef data fill:#fff3e0
class CC,CD,CR,WS,CW client
class OP,JWT auth
class HTTP,STDIO,AUTH,TOOLS server
class TRINO,CATALOGS data
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/Infoheaders - User Impersonation (opt-in): Execute queries as OAuth user via
X-Trino-Userheader
- Query Attribution (automatic): Tags queries with OAuth user via
Installation & Quick Start
Install:
# Homebrew
brew install tuannvm/mcp/mcp-trino
# Or one-liner (macOS/Linux)
curl -fsSL https://raw.githubusercontent.com/tuannvm/mcp-trino/main/install.sh | bash
Run (Local Development):
export TRINO_HOST=localhost TRINO_USER=trino
mcp-trino
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:
# Interactive REPL mode
mcp-trino --interactive
# Execute a query directly
mcp-trino query "SELECT * FROM my_table LIMIT 10"
# List catalogs, schemas, tables
mcp-trino catalogs
mcp-trino schemas my_catalog
mcp-trino tables my_catalog my_schema
# Describe a table
mcp-trino describe my_catalog.my_schema.my_table
# Explain a query
mcp-trino explain "SELECT COUNT(*) FROM my_table"
# Output formats
mcp-trino --format json query "SELECT 1"
mcp-trino --format csv query "SELECT 1"
mcp-trino --format table query "SELECT 1" # default
Named Profiles
mcp-trino supports named connection profiles for easy switching between Trino environments:
Configuration File (~/.config/trino/config.yaml):
current: prod
profiles:
prod:
host: trino.example.com
port: 443
user: prod_user
password: prod_password
catalog: hive
schema: analytics
ssl:
enabled: true
insecure: false
dev:
host: localhost
port: 8080
user: trino
catalog: memory
schema: default
staging:
host: staging-trino.example.com
port: 443
user: staging_user
output:
format: table
Profile Management Commands:
# List all profiles
mcp-trino config profile list
# Set default profile
mcp-trino config profile use prod
# Show profile details
mcp-trino config profile show staging
# Use a specific profile (overrides config file)
mcp-trino --profile dev catalogs
Configuration Precedence (highest to lowest):
- CLI flags (
--host,--port, etc.) --profileflagTRINO_PROFILEenvironment variablecurrentfield in config filedefaultprofile fallback- Environment variables (
TRINO_HOST, etc.)
Environment Variables (lowest priority - overridden by profiles and flags):
export TRINO_HOST=trino.example.com
export TRINO_PORT=443
export TRINO_USER=myuser
export TRINO_PASSWORD=mypass
export TRINO_CATALOG=hive
export TRINO_SCHEMA=analytics
export TRINO_SSL=true
Secret Manager Source (optional):
# Enable dynamic secret loading for config keys such as:
# TRINO_USER, TRINO_PASSWORD, OIDC_CLIENT_SECRET, JWT_SECRET, etc.
export TRINO_SECRET_SOURCE=vault://secret/data/mcp-trino
# Optional: fail startup if secret retrieval fails
export TRINO_SECRET_REQUIRED=true
REPL Meta-Commands (in interactive mode):
\help- Show help\quit,\exit,\q- Exit REPL\history- Show command history\catalogs- List all catalogs\schemas [catalog]- List schemas\tables [catalog schema]- List tables\describe <table>- Describe table\format <table|json|csv>- Change output format
Usage
Supported Clients: Claude Desktop, Claude Code, Cursor, Windsurf, ChatWise
Available Tools: execute_query, list_catalogs, list_schemas, list_tables, get_table_schema, explain_query
For client integration and tool documentation, see Integration Guide and Tools Reference.
Configuration
Key Variables: TRINO_HOST, TRINO_USER, TRINO_SCHEME, MCP_TRANSPORT, OAUTH_PROVIDER
Secret Sources:
# HashiCorp Vault KV (requires VAULT_ADDR + VAULT_TOKEN)
export VAULT_ADDR=https://vault.company.com
export VAULT_TOKEN=...
export TRINO_SECRET_SOURCE=vault://secret/data/mcp-trino
# 1Password CLI (requires authenticated `op`)
export TRINO_SECRET_SOURCE=op://Engineering/Trino
# Generic command adapter (must print JSON object to stdout)
export TRINO_SECRET_SOURCE=command://local
export TRINO_SECRET_COMMAND='printf "%s" "{\"TRINO_PASSWORD\":\"secret\"}"'
OAuth Configuration:
# Native mode (most secure - zero server-side secrets)
export OAUTH_ENABLED=true OAUTH_MODE=native OAUTH_PROVIDER=okta
export OIDC_ISSUER=https://company.okta.com OIDC_AUDIENCE=https://mcp-server.com
# Proxy mode (centralized credential management)
export OAUTH_MODE=proxy OIDC_CLIENT_ID=app-id OIDC_CLIENT_SECRET=secret
export OAUTH_REDIRECT_URI=https://mcp-server.com/oauth/callback # Fixed mode (localhost-only)
export OAUTH_REDIRECT_URI=https://app1.com/cb,https://app2.com/cb # Allowlist mode
export JWT_SECRET=$(openssl rand -hex 32) # Required for multi-pod deployments
Performance Optimization:
# Focus AI on specific schemas only (10-20x performance improvement)
export TRINO_ALLOWED_SCHEMAS="hive.analytics,hive.marts,hive.reporting"
User Identity Tracking:
# Query Attribution is AUTOMATIC when OAuth is enabled
# Queries are tagged with X-Trino-Client-Tags and X-Trino-Client-Info headers
# For full impersonation (Trino enforces user permissions):
export TRINO_ENABLE_IMPERSONATION=true
export TRINO_IMPERSONATION_FIELD=email # Options: username, email, subject
For complete configuration, see Deployment Guide, OAuth Guide, Allowlists Guide, and User Identity Guide.
OAuth Implementation
mcp-trino uses oauth-mcp-proxy - a standalone OAuth 2.1 library for Go MCP servers.
Why a separate library?
- ✅ Reusable across any Go MCP server
- ✅ Independent testing and versioning
- ✅ Dedicated documentation and examples
- ✅ Community-maintained OAuth implementation
For OAuth details:
- oauth-mcp-proxy Documentation - Complete OAuth guide
- Provider Setup Guides - Okta, Google, Azure AD
- Security Best Practices - Production security
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Related Projects
- oauth-mcp-proxy - OAuth 2.1 authentication library used by mcp-trino (reusable for any Go MCP server)
CI/CD and Releases
This project uses GitHub Actions for continuous integration and GoReleaser for automated releases.
Continuous Integration Checks
Our CI pipeline performs the following checks on all PRs and commits to the main branch:
Code Quality
- Linting: Using golangci-lint to check for common code issues and style violations
- Go Module Verification: Ensuring go.mod and go.sum are properly maintained
- Formatting: Verifying code is properly formatted with gofmt
Security
- Vulnerability Scanning: Using govulncheck to check for known vulnerabilities in dependencies
- Dependency Scanning: Using Trivy to scan for vulnerabilities in dependencies (CRITICAL, HIGH, and MEDIUM)
- SBOM Generation: Creating a Software Bill of Materials for dependency tracking
- SLSA Provenance: Creating verifiable build provenance for supply chain security
Testing
- Unit Tests: Running tests with race detection and code coverage reporting
- Build Verification: Ensuring the codebase builds successfully
CI/CD Security
- Least Privilege: Workflows run with minimum required permissions
- Pinned Versions: All GitHub Actions use specific versions to prevent supply chain attacks
- Dependency Updates: Automated dependency updates via Dependabot
Release Process
When changes are merged to the main branch:
- CI checks are run to validate code quality and security
- If successful, a new release is automatically created with:
- Semantic versioning based on commit messages
- Binary builds for multiple platforms
- Docker image publishing to GitHub Container Registry
- SBOM and provenance attestation
常见问题
io.github.tuannvm/mcp-trino 是什么?
用于访问 Trino 分布式 SQL 查询引擎的 MCP server,便于统一执行与管理查询。
相关 Skills
MCP构建
by anthropics
聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。
✎ 想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。
Slack动图
by anthropics
面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。
✎ 帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。
MCP服务构建器
by alirezarezvani
从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。
✎ 帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。
相关 MCP Server
Slack 消息
编辑精选by Anthropic
Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。
✎ 这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。
by netdata
io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。
✎ 这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。
by d4vinci
Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。
✎ 这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。