This file provides guidance to Claude Code when working with this project.
mcp-trino is a generic, open-source MCP (Model Context Protocol) server for Trino. It enables AI assistants to query and explore data warehouses via the MCP protocol.
Key Design Goals:
- Composable: Can be used standalone OR imported as a library
- Generic: No domain-specific logic; suitable for any Trino deployment
- Secure: Configurable limits and timeouts to prevent abuse
-
Idiomatic Go: All code must follow idiomatic Go patterns and conventions. Use
gofmt, follow Effective Go guidelines, and adhere to Go Code Review Comments. -
Test Coverage: Project must maintain >80% unit test coverage. Build mocks where necessary to achieve this. Use table-driven tests where appropriate.
-
Testing Definition: When asked to "test" or "testing" the code, this means running the full CI test suite:
- Unit tests with race detection (
make testorgo test -race ./...) - Linting (
make lint/ golangci-lint) - Security scanning (
gosec ./...) - Cyclomatic complexity (
gocyclo -over 15 .must return no results) - All checks that run in CI must pass locally before considering code "tested"
- Unit tests with race detection (
-
Human Review Required: A human must review and approve every line of code before it is committed. Therefore, commits are always performed by a human, not by Claude.
-
Go Report Card: The project MUST always maintain 100% across all categories on Go Report Card.
mcp-trino/
├── cmd/mcp-trino/main.go # Standalone server entrypoint
├── pkg/ # PUBLIC API (importable by other projects)
│ ├── client/ # Trino client wrapper
│ │ ├── client.go # Connection and query execution
│ │ └── config.go # Configuration from env/struct
│ └── tools/ # MCP tool definitions
│ ├── toolkit.go # NewToolkit() and RegisterAll()
│ ├── query.go # trino_query tool
│ ├── explain.go # trino_explain tool
│ └── schema.go # list_catalogs, list_schemas, etc.
├── internal/server/ # Default server setup (private)
├── go.mod
├── LICENSE # Apache 2.0
└── README.md
github.com/modelcontextprotocol/go-sdk- Official MCP SDK (v1.0.0)github.com/trinodb/trino-go-client- Trino Go driver
# Build
go build -o mcp-trino ./cmd/mcp-trino
# Run (requires Trino connection)
export TRINO_HOST=trino.example.com
export TRINO_USER=user
export TRINO_PASSWORD=pass
export TRINO_CATALOG=hive
export TRINO_SCHEMA=default
./mcp-trino# Start local Trino
docker run -d -p 8080:8080 --name trino trinodb/trino
# Configure for local testing
export TRINO_HOST=localhost
export TRINO_PORT=8080
export TRINO_USER=admin
export TRINO_SSL=false
export TRINO_CATALOG=memory
export TRINO_SCHEMA=default
./mcp-trinoThis package is designed to be imported by other MCP servers:
import (
"github.com/txn2/mcp-trino/pkg/client"
"github.com/txn2/mcp-trino/pkg/tools"
)
// Create client
trinoClient, _ := client.New(client.FromEnv())
// Create toolkit and register on your server
toolkit := tools.NewToolkit(trinoClient, tools.DefaultConfig())
toolkit.RegisterAll(yourMCPServer)| Tool | Description |
|---|---|
trino_query |
Execute read-only SQL (SELECT/SHOW/DESCRIBE), returns JSON/CSV/markdown |
trino_execute |
Execute any SQL including write ops (INSERT/UPDATE/DELETE/CREATE/DROP) |
trino_explain |
Get execution plan |
trino_browse |
Browse catalog hierarchy (catalogs → schemas → tables) |
trino_describe_table |
Get column definitions |
Environment variables:
TRINO_HOST- Server hostnameTRINO_PORT- Server portTRINO_USER- Username (required)TRINO_PASSWORD- PasswordTRINO_CATALOG- Default catalogTRINO_SCHEMA- Default schemaTRINO_SSL- Enable SSL (true/false)TRINO_SSL_VERIFY- Verify SSL certsTRINO_TIMEOUT- Query timeout in secondsTRINO_SOURCE- Client source identifier