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. 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. T
Add this skill
npx mdskills install tuannvm/mcp-trinoProduction-ready MCP server with comprehensive OAuth, extensive tooling, and strong security practices
1# Trino MCP Server in Go23A 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.45[](https://github.com/tuannvm/mcp-trino/actions/workflows/build.yml)6[](https://github.com/tuannvm/mcp-trino/blob/main/go.mod)7[](https://github.com/tuannvm/mcp-trino/actions/workflows/build.yml)8[](https://slsa.dev)9[](https://goreportcard.com/report/github.com/tuannvm/mcp-trino)10[](https://pkg.go.dev/github.com/tuannvm/mcp-trino)11[](https://github.com/tuannvm/mcp-trino/pkgs/container/mcp-trino)12[](https://github.com/tuannvm/mcp-trino/releases/latest)13[](https://opensource.org/licenses/MIT)1415[](https://archestra.ai/mcp-catalog/tuannvm__mcp-trino)1617## Overview1819This 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.2021Trino (formerly PrestoSQL) is a powerful distributed SQL query engine designed for fast analytics on large datasets.2223## Architecture2425```mermaid26graph TB27 subgraph "AI Clients"28 CC[Claude Code]29 CD[Claude Desktop]30 CR[Cursor]31 WS[Windsurf]32 CW[ChatWise]33 end3435 subgraph "Authentication (Optional)"36 OP[OAuth Provider<br/>Okta/Google/Azure AD]37 JWT[JWT Tokens]38 end3940 subgraph "MCP Server (mcp-trino)"41 HTTP[HTTP Transport<br/>/mcp endpoint]42 STDIO[STDIO Transport]43 AUTH[OAuth Middleware]44 TOOLS[MCP Tools<br/>• execute_query<br/>• list_catalogs<br/>• list_schemas<br/>• list_tables<br/>• get_table_schema<br/>• explain_query]45 end4647 subgraph "Data Layer"48 TRINO[Trino Cluster<br/>Distributed SQL Engine]49 CATALOGS[Data Sources<br/>• PostgreSQL<br/>• MySQL<br/>• S3/Hive<br/>• BigQuery<br/>• MongoDB]50 end5152 %% Connections53 CC -.->|OAuth Flow| OP54 OP -.->|JWT Token| JWT5556 CC -->|HTTP + JWT| HTTP57 CD -->|STDIO| STDIO58 CR -->|HTTP + JWT| HTTP59 WS -->|STDIO| STDIO60 CW -->|HTTP + JWT| HTTP6162 HTTP --> AUTH63 AUTH -->|Validated| TOOLS64 STDIO --> TOOLS6566 TOOLS -->|SQL Queries| TRINO67 TRINO --> CATALOGS6869 %% Styling70 classDef client fill:#e1f5fe71 classDef auth fill:#f3e5f572 classDef server fill:#e8f5e873 classDef data fill:#fff3e07475 class CC,CD,CR,WS,CW client76 class OP,JWT auth77 class HTTP,STDIO,AUTH,TOOLS server78 class TRINO,CATALOGS data79```8081**Key Components:**8283- **AI Clients**: Various MCP-compatible applications84- **Authentication**: Optional OAuth 2.0 with OIDC providers85- **MCP Server**: Go-based server with dual transport support86- **Data Layer**: Trino cluster connecting to multiple data sources8788## Features8990- ✅ MCP server implementation in Go91- ✅ Trino SQL query execution through MCP tools92- ✅ Catalog, schema, and table discovery93- ✅ Docker container support94- ✅ Supports both STDIO and HTTP transports95- ✅ OAuth 2.1 authentication via [oauth-mcp-proxy](https://github.com/tuannvm/oauth-mcp-proxy) library96 - **4 Providers**: HMAC, Okta, Google, Azure AD97 - **Native mode**: Client handles OAuth directly (zero server-side secrets)98 - **Proxy mode**: Server proxies OAuth flow for simple clients99 - **Production-ready**: Token caching, PKCE, defense-in-depth security100 - **Reusable**: OAuth library available for any Go MCP server101- ✅ StreamableHTTP support with JWT authentication (upgraded from SSE)102- ✅ Backward compatibility with SSE endpoints103- ✅ Compatible with Cursor, Claude Desktop, Windsurf, ChatWise, and any MCP-compatible clients.104- ✅ User Identity Tracking:105 - **Query Attribution** (automatic): Tags queries with OAuth user via `X-Trino-Client-Tags/Info` headers106 - **User Impersonation** (opt-in): Execute queries as OAuth user via `X-Trino-User` header107108## Installation & Quick Start109110**Install:**111112```bash113# Homebrew114brew install tuannvm/mcp/mcp-trino115116# Or one-liner (macOS/Linux)117curl -fsSL https://raw.githubusercontent.com/tuannvm/mcp-trino/main/install.sh | bash118```119120**Run (Local Development):**121122```bash123export TRINO_HOST=localhost TRINO_USER=trino124mcp-trino125```126127For production deployment with OAuth, see [Deployment Guide](docs/deployment.md) and [OAuth Architecture](docs/oauth.md).128129## Usage130131**Supported Clients:** Claude Desktop, Claude Code, Cursor, Windsurf, ChatWise132133**Available Tools:** `execute_query`, `list_catalogs`, `list_schemas`, `list_tables`, `get_table_schema`, `explain_query`134135For client integration and tool documentation, see [Integration Guide](docs/integrations.md) and [Tools Reference](docs/tools.md).136137## Configuration138139**Key Variables:** `TRINO_HOST`, `TRINO_USER`, `TRINO_SCHEME`, `MCP_TRANSPORT`, `OAUTH_PROVIDER`140141**OAuth Configuration:**142143```bash144# Native mode (most secure - zero server-side secrets)145export OAUTH_ENABLED=true OAUTH_MODE=native OAUTH_PROVIDER=okta146export OIDC_ISSUER=https://company.okta.com OIDC_AUDIENCE=https://mcp-server.com147148# Proxy mode (centralized credential management)149export OAUTH_MODE=proxy OIDC_CLIENT_ID=app-id OIDC_CLIENT_SECRET=secret150export OAUTH_REDIRECT_URI=https://mcp-server.com/oauth/callback # Fixed mode (localhost-only)151export OAUTH_REDIRECT_URI=https://app1.com/cb,https://app2.com/cb # Allowlist mode152export JWT_SECRET=$(openssl rand -hex 32) # Required for multi-pod deployments153```154155**Performance Optimization:**156157```bash158# Focus AI on specific schemas only (10-20x performance improvement)159export TRINO_ALLOWED_SCHEMAS="hive.analytics,hive.marts,hive.reporting"160```161162**User Identity Tracking:**163164```bash165# Query Attribution is AUTOMATIC when OAuth is enabled166# Queries are tagged with X-Trino-Client-Tags and X-Trino-Client-Info headers167168# For full impersonation (Trino enforces user permissions):169export TRINO_ENABLE_IMPERSONATION=true170export TRINO_IMPERSONATION_FIELD=email # Options: username, email, subject171```172173For complete configuration, see [Deployment Guide](docs/deployment.md), [OAuth Guide](docs/oauth.md), [Allowlists Guide](docs/allowlists.md), and [User Identity Guide](docs/impersonation.md).174175## OAuth Implementation176177mcp-trino uses [oauth-mcp-proxy](https://github.com/tuannvm/oauth-mcp-proxy) - a standalone OAuth 2.1 library for Go MCP servers.178179**Why a separate library?**180- ✅ Reusable across any Go MCP server181- ✅ Independent testing and versioning182- ✅ Dedicated documentation and examples183- ✅ Community-maintained OAuth implementation184185**For OAuth details:**186- [oauth-mcp-proxy Documentation](https://github.com/tuannvm/oauth-mcp-proxy#readme) - Complete OAuth guide187- [Provider Setup Guides](https://github.com/tuannvm/oauth-mcp-proxy/tree/main/docs/providers) - Okta, Google, Azure AD188- [Security Best Practices](https://github.com/tuannvm/oauth-mcp-proxy/blob/main/docs/SECURITY.md) - Production security189190## Contributing191192Contributions are welcome! Please feel free to submit a Pull Request.193194## License195196This project is licensed under the MIT License - see the LICENSE file for details.197198## Related Projects199200- **[oauth-mcp-proxy](https://github.com/tuannvm/oauth-mcp-proxy)** - OAuth 2.1 authentication library used by mcp-trino (reusable for any Go MCP server)201202## CI/CD and Releases203204This project uses GitHub Actions for continuous integration and GoReleaser for automated releases.205206### Continuous Integration Checks207208Our CI pipeline performs the following checks on all PRs and commits to the main branch:209210#### Code Quality211212- **Linting**: Using golangci-lint to check for common code issues and style violations213- **Go Module Verification**: Ensuring go.mod and go.sum are properly maintained214- **Formatting**: Verifying code is properly formatted with gofmt215216#### Security217218- **Vulnerability Scanning**: Using govulncheck to check for known vulnerabilities in dependencies219- **Dependency Scanning**: Using Trivy to scan for vulnerabilities in dependencies (CRITICAL, HIGH, and MEDIUM)220- **SBOM Generation**: Creating a Software Bill of Materials for dependency tracking221- **SLSA Provenance**: Creating verifiable build provenance for supply chain security222223#### Testing224225- **Unit Tests**: Running tests with race detection and code coverage reporting226- **Build Verification**: Ensuring the codebase builds successfully227228#### CI/CD Security229230- **Least Privilege**: Workflows run with minimum required permissions231- **Pinned Versions**: All GitHub Actions use specific versions to prevent supply chain attacks232- **Dependency Updates**: Automated dependency updates via Dependabot233234### Release Process235236When changes are merged to the main branch:2372381. CI checks are run to validate code quality and security2392. If successful, a new release is automatically created with:240 - Semantic versioning based on commit messages241 - Binary builds for multiple platforms242 - Docker image publishing to GitHub Container Registry243 - SBOM and provenance attestation244
Full transparency — inspect the skill content before installing.