io.github.txn2/mcp-trino

平台与服务

by txn2

面向 Trino data warehouse 的 MCP server,可执行 query、分析 plan,并探索 schema。

什么是 io.github.txn2/mcp-trino

面向 Trino data warehouse 的 MCP server,可执行 query、分析 plan,并探索 schema。

README

txn2/mcp-trino

GitHub license Go Reference Go Report Card codecov OpenSSF Scorecard SLSA 3

mcp-trino.txn2.com | Installation | Library Docs

A Model Context Protocol (MCP) server for Trino, enabling AI assistants to query and explore data warehouses with optional semantic context from metadata catalogs.

AI assistants excel at querying data but lack organizational context: which tables are trustworthy, what metrics mean, and which columns contain sensitive data. mcp-trino bridges this gap by connecting Trino to AI assistants through the MCP protocol, with an optional semantic layer that surfaces business metadata alongside query results.

MCP Data Platform Ecosystem

mcp-trino is part of a broader suite of open-source MCP servers designed to work together as a composable data platform. Each component can run standalone or be combined to give AI assistants unified access to storage, query engines, and metadata catalogs.

Core Capabilities

Composable Architecture

  • Import as a Go library to build custom MCP servers
  • Add authentication, tenant isolation, audit logging without forking
  • Middleware and interceptor patterns for enterprise requirements

Semantic Context

  • Surface business descriptions, ownership, and data quality from metadata catalogs
  • Mark sensitive columns for AI assistants
  • Connect to DataHub, static files, or build custom metadata providers

Multi-Cluster Connectivity

  • Query multiple Trino servers from a single MCP installation
  • Unified interface across production, staging, and development environments

Secure Defaults

  • Read-only mode prevents accidental data modification
  • Query limits and timeouts prevent runaway operations
  • SLSA Level 3 provenance for supply chain security

Features

  • Execute SQL Queries: Run queries with configurable row limits and timeouts
  • Analyze Execution Plans: Inspect logical, distributed, and I/O query plans
  • Discover Schema: Browse catalogs, schemas, and tables across clusters
  • Describe Tables: View column definitions with optional data samples
  • Enrich with Context: Surface business metadata, ownership, and data quality
  • Compose Custom Servers: Import as a Go library with middleware and interceptors

Installation

Homebrew (macOS)

bash
brew install txn2/tap/mcp-trino

Claude Desktop

Claude Desktop is the GUI application for chatting with Claude. Install the mcp-trino extension to enable Trino queries in your conversations.

Option 1: One-Click Install (Recommended)

Download the .mcpb bundle for your Mac from the releases page and double-click to install:

Mac TypeChipDownload
MacBook Air/Pro (2020+), Mac Mini (2020+), iMac (2021+), Mac StudioApple M1, M2, M3, M4 (arm64)mcp-trino_*_darwin_arm64.mcpb
MacBook Air/Pro (pre-2020), Mac Mini (pre-2020), iMac (pre-2021)Intel (amd64)mcp-trino_*_darwin_amd64.mcpb

Tip: Not sure which chip you have? Click → "About This Mac". Look for "Chip" (Apple Silicon) or "Processor" (Intel).

Option 2: Manual Configuration

Add to your claude_desktop_config.json (find via Claude Desktop → Settings → Developer):

json
{
  "mcpServers": {
    "trino": {
      "command": "/opt/homebrew/bin/mcp-trino",
      "env": {
        "TRINO_HOST": "trino.example.com",
        "TRINO_USER": "your_user",
        "TRINO_PASSWORD": "your_password",
        "TRINO_CATALOG": "hive",
        "TRINO_SCHEMA": "default"
      }
    }
  }
}

Claude Code CLI

Claude Code is the terminal-based coding assistant. Add mcp-trino as an MCP server:

bash
# Install via Homebrew first (see above), then:
claude mcp add trino \
  -e TRINO_HOST=trino.example.com \
  -e TRINO_USER=your_user \
  -e TRINO_PASSWORD=your_password \
  -e TRINO_CATALOG=hive \
  -- mcp-trino

Or download and install manually:

bash
# Download the latest release for your architecture
curl -L https://github.com/txn2/mcp-trino/releases/latest/download/mcp-trino_$(uname -s)_$(uname -m).tar.gz | tar xz

# Add to Claude Code
claude mcp add trino \
  -e TRINO_HOST=trino.example.com \
  -e TRINO_USER=your_user \
  -e TRINO_PASSWORD=your_password \
  -e TRINO_CATALOG=hive \
  -- ./mcp-trino

Docker

bash
docker run --rm -i \
  -e TRINO_HOST=trino.example.com \
  -e TRINO_USER=your_user \
  -e TRINO_PASSWORD=your_password \
  ghcr.io/txn2/mcp-trino:latest

Go Install

bash
go install github.com/txn2/mcp-trino/cmd/mcp-trino@latest

Download Binary

Download pre-built binaries from the releases page. All releases are signed with Cosign and include SLSA provenance.

As a Library

bash
go get github.com/txn2/mcp-trino

Quick Start

Multiple Trino Servers

You can configure multiple Trino instances with different names:

bash
# Production
claude mcp add trino-prod \
  -e TRINO_HOST=trino.prod.example.com \
  -e TRINO_USER=prod_user \
  -- mcp-trino

# Staging
claude mcp add trino-staging \
  -e TRINO_HOST=trino.staging.example.com \
  -e TRINO_USER=staging_user \
  -- mcp-trino

Standalone Server

bash
export TRINO_HOST=trino.example.com
export TRINO_USER=your_user
export TRINO_PASSWORD=your_password
mcp-trino

Tools

ToolDescription
trino_queryExecute read-only SQL queries (SELECT, SHOW, DESCRIBE) with limit/timeout control
trino_executeExecute any SQL including write operations (INSERT, UPDATE, DELETE, CREATE, DROP)
trino_explainGet execution plans (logical/distributed/io/validate)
trino_browseBrowse catalog hierarchy: list catalogs, schemas, or tables
trino_describe_tableGet columns, sample data, and semantic context (if configured)
trino_list_connectionsList all configured server connections

Semantic Layer

AI agents operate more reliably when they understand organizational context: not just table structures, but which datasets are production-ready, what business terms mean, and which columns require careful handling.

mcp-trino's semantic layer integrates with metadata catalogs to surface this context alongside query results:

MetadataDescription
DescriptionsBusiness-friendly explanations of tables and columns
OwnershipData stewards and technical owners
Tags & DomainsClassification labels and business domains
Glossary TermsLinks to formal business definitions
Data QualityFreshness scores and quality metrics
SensitivityPII and sensitive data markers at column level
LineageUpstream and downstream data dependencies

Providers

ProviderDescription
DataHubConnect to DataHub's GraphQL API for enterprise metadata
Static FilesLoad metadata from YAML or JSON files with hot-reload
CustomImplement the semantic.Provider interface for any catalog

See the Semantic Layer Documentation for configuration, caching, and custom provider development.

Configuration

Environment VariableDescriptionDefault
TRINO_HOSTTrino server hostnamelocalhost
TRINO_PORTTrino server port443 (SSL) / 8080
TRINO_USERAuthentication username(required)
TRINO_PASSWORDAuthentication password(optional)
TRINO_CATALOGDefault catalogmemory
TRINO_SCHEMADefault schemadefault
TRINO_SSLEnable HTTPStrue for remote hosts
TRINO_SSL_VERIFYVerify SSL certificatestrue
TRINO_TIMEOUTQuery timeout (seconds)120
TRINO_SOURCEClient identifiermcp-trino
TRINO_ADDITIONAL_SERVERSAdditional servers (JSON)(optional)

Multi-Server Configuration

Connect to multiple Trino servers from a single installation. Configure your primary server with the standard environment variables, then add additional servers via JSON:

bash
export TRINO_HOST=prod.trino.example.com
export TRINO_USER=admin
export TRINO_PASSWORD=secret
export TRINO_ADDITIONAL_SERVERS='{
  "staging": {"host": "staging.trino.example.com"},
  "dev": {"host": "localhost", "port": 8080, "ssl": false}
}'

Additional servers inherit credentials and settings from the primary server unless overridden:

json
{
  "staging": {
    "host": "staging.trino.example.com",
    "user": "staging_user",
    "catalog": "iceberg"
  },
  "dev": {
    "host": "localhost",
    "port": 8080,
    "ssl": false,
    "user": "admin"
  }
}

Use the connection parameter in any tool to target a specific server:

code
"Query the staging server: SELECT * FROM users LIMIT 10"
→ trino_query(sql="...", connection="staging")

Use trino_list_connections to discover available connections.

File-Based Configuration

For production deployments using Kubernetes ConfigMaps, Vault, or other secret management systems, mcp-trino supports file-based configuration:

yaml
# config.yaml
trino:
  host: trino.example.com
  port: 443
  user: ${TRINO_USER}           # Supports env var expansion
  password: ${TRINO_PASSWORD}   # Secrets can come from env
  catalog: hive
  schema: default
  ssl: true
  timeout: 120s

toolkit:
  default_limit: 1000
  max_limit: 10000
  default_timeout: 120s
  max_timeout: 300s

extensions:
  logging: true
  readonly: true
  errors: true

Load configuration in your custom server:

go
import "github.com/txn2/mcp-trino/pkg/extensions"

// Load from file with env var overrides
cfg, err := extensions.LoadConfig("/etc/mcp-trino/config.yaml")

// Convert to individual configs
clientCfg := cfg.ClientConfig()
toolsCfg := cfg.ToolsConfig()
extCfg := cfg.ExtConfig()

Using as a Library

mcp-trino is designed to be composable. You can import its tools into your own MCP server:

go
package main

import (
    "context"
    "log"

    "github.com/modelcontextprotocol/go-sdk/mcp"
    "github.com/txn2/mcp-trino/pkg/client"
    "github.com/txn2/mcp-trino/pkg/tools"
)

func main() {
    // Create your MCP server
    server := mcp.NewServer(&mcp.Implementation{
        Name:    "my-data-server",
        Version: "1.0.0",
    }, nil)

    // Create Trino client
    trinoClient, err := client.New(client.Config{
        Host:    "trino.example.com",
        Port:    443,
        User:    "service_user",
        SSL:     true,
        Catalog: "hive",
        Schema:  "analytics",
    })
    if err != nil {
        log.Fatal(err)
    }
    defer trinoClient.Close()

    // Add Trino tools to your server
    toolkit := tools.NewToolkit(trinoClient, tools.Config{
        DefaultLimit: 1000,
        MaxLimit:     10000,
    })
    toolkit.RegisterAll(server)

    // Add your own custom tools here...
    // mcp.AddTool(server, &mcp.Tool{...}, handler)

    // Run the server
    if err := server.Run(context.Background(), &mcp.StdioTransport{}); err != nil {
        log.Fatal(err)
    }
}

Extensions

The standalone server includes optional extensions that can be enabled via environment variables:

Environment VariableDefaultDescription
MCP_TRINO_EXT_LOGGINGfalseStructured JSON logging of tool calls
MCP_TRINO_EXT_METRICSfalseIn-memory metrics collection
MCP_TRINO_EXT_READONLYtrueBlock modification statements (INSERT, UPDATE, DELETE, etc.)
MCP_TRINO_EXT_QUERYLOGfalseLog all SQL queries for audit
MCP_TRINO_EXT_METADATAfalseAdd execution metadata footer to results
MCP_TRINO_EXT_ERRORStrueAdd helpful hints to error messages

Using Extensions in Custom Servers

go
import (
    "github.com/txn2/mcp-trino/pkg/extensions"
    "github.com/txn2/mcp-trino/pkg/tools"
)

// Load extension config from environment
extCfg := extensions.FromEnv()

// Or configure programmatically
extCfg := extensions.Config{
    EnableLogging:   true,
    EnableReadOnly:  true,
    EnableErrorHelp: true,
}

// Build toolkit options from extensions
toolkitOpts := extensions.BuildToolkitOptions(extCfg)

// Create toolkit with extensions
toolkit := tools.NewToolkit(trinoClient, toolsCfg, toolkitOpts...)

Custom Middleware and Interceptors

You can create custom middleware, interceptors, and transformers:

go
// Custom middleware for authentication
authMiddleware := tools.MiddlewareFunc{
    BeforeFn: func(ctx context.Context, tc *tools.ToolContext) (context.Context, error) {
        // Validate user permissions
        return ctx, nil
    },
}

// Custom interceptor for tenant isolation
tenantInterceptor := tools.QueryInterceptorFunc(
    func(ctx context.Context, sql string, toolName tools.ToolName) (string, error) {
        // Add WHERE tenant_id = ? clause
        return sql, nil
    },
)

// Apply to toolkit
toolkit := tools.NewToolkit(client, cfg,
    tools.WithMiddleware(authMiddleware),
    tools.WithQueryInterceptor(tenantInterceptor),
)

Security Considerations

  • Credentials: Store passwords in environment variables or secret managers
  • Query Limits: Default 1000 rows, max 10000 to prevent data exfiltration
  • Timeouts: Default 120s timeout prevents runaway queries
  • Read-Only: ReadOnly interceptor enabled by default blocks modification statements
  • Access Control: Configure Trino roles and catalog access for defense in depth

Development

bash
# Clone the repository
git clone https://github.com/txn2/mcp-trino.git
cd mcp-trino

# Build
make build

# Run tests
make test

# Run linter
make lint

# Run all checks
make verify

# Run with a local Trino (e.g., via Docker)
make docker-trino
export TRINO_HOST=localhost
export TRINO_PORT=8080
export TRINO_USER=admin
export TRINO_SSL=false
./mcp-trino

Contributing

We welcome contributions for bug fixes, tests, and documentation. See CONTRIBUTING.md for guidelines.

License

Apache License 2.0


Open source by Craig Johnston, sponsored by Deasil Works, Inc.

常见问题

io.github.txn2/mcp-trino 是什么?

面向 Trino data warehouse 的 MCP server,可执行 query、分析 plan,并探索 schema。

相关 Skills

MCP构建

by anthropics

Universal
热门

聚焦高质量 MCP Server 开发,覆盖协议研究、工具设计、错误处理与传输选型,适合用 FastMCP 或 MCP SDK 对接外部 API、封装服务能力。

想让 LLM 稳定调用外部 API,就用 MCP构建:从 Python 到 Node 都有成熟指引,帮你更快做出高质量 MCP 服务器。

平台与服务
未扫描114.1k

Slack动图

by anthropics

Universal
热门

面向Slack的动图制作Skill,内置emoji/消息GIF的尺寸、帧率和色彩约束、校验与优化流程,适合把创意或上传图片快速做成可直接发送的Slack动画。

帮你快速做出适配 Slack 的动图,内置约束规则和校验工具,少踩上传与播放坑,做表情包和演示都更省心。

平台与服务
未扫描114.1k

MCP服务构建器

by alirezarezvani

Universal
热门

从 OpenAPI 一键生成 Python/TypeScript MCP server 脚手架,并校验 tool schema、命名规范与版本兼容性,适合把现有 REST API 快速发布成可生产演进的 MCP 服务。

帮你快速搭建 MCP 服务与后端 API,脚手架完善、扩展顺手,尤其适合想高效验证服务能力的开发者。

平台与服务
未扫描10.2k

相关 MCP Server

Slack 消息

编辑精选

by Anthropic

热门

Slack 是让 AI 助手直接读写你的 Slack 频道和消息的 MCP 服务器。

这个服务器解决了团队协作中需要 AI 实时获取 Slack 信息的痛点,特别适合开发团队让 Claude 帮忙汇总频道讨论或发送通知。不过,它目前只是参考实现,文档有限,不建议在生产环境直接使用——更适合开发者学习 MCP 如何集成第三方服务。

平台与服务
83.4k

by netdata

热门

io.github.netdata/mcp-server 是让 AI 助手实时监控服务器指标和日志的 MCP 服务器。

这个工具解决了运维人员需要手动检查系统状态的痛点,最适合 DevOps 团队让 Claude 自动分析性能数据。不过,它依赖 NetData 的现有部署,如果你没用过这个监控平台,得先花时间配置。

平台与服务
78.4k

by d4vinci

热门

Scrapling MCP Server 是专为现代网页设计的智能爬虫工具,支持绕过 Cloudflare 等反爬机制。

这个工具解决了爬取动态网页和反爬网站时的头疼问题,特别适合需要批量采集电商价格或新闻数据的开发者。不过,它依赖外部浏览器引擎,资源消耗较大,不适合轻量级任务。

平台与服务
35.4k

评论