A simple Model Context Protocol (MCP) server for Trino with OAuth support
Project description
Trino MCP Server
A simple Model Context Protocol (MCP) server for Trino query engine with OAuth support (without explicit JWT tokens).
Quick Start (TLDR)
Using with VS Code? Add to .vscode/mcp.json:
{
"servers": {
"trino": {
"command": "uvx",
"args": ["trino-mcp"],
"env": {
"TRINO_HOST": "${trino_host_address}",
"TRINO_USER": "${env:USER}",
"AUTH_METHOD": "OAuth2"
// "ALLOW_WRITE_QUERIES": "true" // Enable write operations (disabled by default)
}
}
}
}
Want to run standalone?
# Set your Trino connection
export TRINO_HOST=localhost
export TRINO_PORT=8080
export TRINO_USER=trino
# Run directly (no installation needed)
uvx trino-mcp
That's it! The server will connect to your Trino cluster and provide query capabilities.
Features
- Core Trino Operations: Query catalogs, schemas, tables, and execute SQL
- OAuth Support: Built-in OAuth2 authentication without requiring explicit JWT tokens
- Basic Authentication: Also supports username/password authentication
- Simple & Focused: Core Trino features without over-complication
- uvx Compatible: Run directly with
uvxwithout installation - Write Protection: Separate tools (
execute_queryandexecute_query_read_only) withALLOW_WRITE_QUERIESconfiguration to prevent accidental database modifications - Query Watermarking: Automatically adds watermark comments to queries for tracking and auditing (includes username and version)
Prerequisites
- Python 3.10 or higher
- A running Trino server
- (Optional) Trino credentials for authentication
- (Optional) uvx
Setup & Configuration
General recommendation: using uvx or uv.
# From PyPI
uv pip install trino-mcp
# From PyPI
uvx trino-mcp
# Clone to local directory and install
uv pip install .
trino-mcp
Using with Claude Desktop
Add to your Claude Desktop configuration (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"trino": {
"command": "uvx",
"args": ["trino-mcp"],
"env": {
"TRINO_HOST": "localhost",
"TRINO_PORT": "8080",
"TRINO_USER": "trino"
// "ALLOW_WRITE_QUERIES": "true" // Enable write operations if needed
}
}
}
}
Using with VS Code
Add to .vscode/mcp.json:
{
"servers": {
"trino": {
"command": "uvx",
"args": ["trino-mcp"],
"env": {
"TRINO_HOST": "${trino_host_address}",
"TRINO_USER": "${env:USER}",
"AUTH_METHOD": "OAuth2"
// "ALLOW_WRITE_QUERIES": "true" // Enable write operations if needed
}
}
}
}
Environment Variables
Configure the server using environment variables or a .env file:
# Required
TRINO_HOST=localhost # Your Trino server hostname
TRINO_PORT=8080 # Trino server port
TRINO_USER=trino # Username for authentication
TRINO_HTTP_SCHEME=http # http or https
# Optional
TRINO_CATALOG=my_catalog # Default catalog
TRINO_SCHEMA=my_schema # Default schema
# Authentication (choose one):
TRINO_PASSWORD=your_password # For basic authentication
TRINO_OAUTH_TOKEN=your_token # For OAuth2 authentication
# Security
ALLOW_WRITE_QUERIES=true # Enable write operations (INSERT, UPDATE, DELETE, etc.)
# Disabled by default for safety
Available Tools
The Trino MCP server provides the following tools. For the most up-to-date documentation, see the CI-generated tool documentation (available as artifacts in CI runs).
Quick summary:
list_catalogs- List all available Trino catalogslist_schemas- List all schemas in a cataloglist_tables- List all tables in a schemadescribe_table- Describe the structure of a tableexecute_query_read_only- Execute read-only SQL queries (SELECT, SHOW, DESCRIBE, EXPLAIN)execute_query- Execute any SQL query (requiresALLOW_WRITE_QUERIES=truefor write operations)show_create_table- Show the CREATE TABLE statement for a tableget_table_stats- Get statistics for a table
To generate the detailed tool documentation locally:
python3 scripts/generate_tool_docs.py
# This creates TOOLS.md and tools.json with complete documentation
OAuth Authentication
This server is designed to work with Trino's OAuth2 authentication mechanism. The Trino Python client supports OAuth2 authentication through a redirect handler mechanism that doesn't require you to manually manage JWT tokens.
How OAuth Works with Trino
- Server Configuration: Configure your Trino cluster with OAuth2 authentication
- Client Connection: The Trino Python client handles the OAuth2 flow automatically
- Token Management: Tokens are managed by the client library - no manual JWT handling required
Note: OAuth2 support in the Trino Python client requires implementing a redirect handler. This server provides the foundation for OAuth2 integration. For production use with OAuth2, you may need to extend the configuration to implement your specific OAuth2 flow based on your identity provider.
Architecture
trino-mcp/
├── src/
│ └── trino_mcp/
│ ├── __init__.py
│ ├── config.py # Configuration management
│ ├── client.py # Trino client wrapper
│ └── server.py # MCP server implementation
├── pyproject.toml # Project configuration
├── .env.example # Example environment variables
└── README.md # This file
Development
# Install development dependencies
uv pip install -e ".[dev]"
# Run tests (when available)
pytest
# Format code
black src/
# Type checking
mypy src/
License
MIT License - see LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
For issues and questions:
- Open an issue on GitHub
- Check Trino documentation: https://trino.io/docs/
- Check MCP documentation: https://modelcontextprotocol.io/
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trino_mcp-0.1.2.tar.gz.
File metadata
- Download URL: trino_mcp-0.1.2.tar.gz
- Upload date:
- Size: 121.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
78774f4b8701c1c95443654f26503ca7298eb403ad397990dd808449049a9d8d
|
|
| MD5 |
984f6f2c9a780469c1e2e298f033ef94
|
|
| BLAKE2b-256 |
6e6d72bc934435f8daad8aef4b176565e65813907a9e2f493d5ebf950762369a
|
Provenance
The following attestation bundles were made for trino_mcp-0.1.2.tar.gz:
Publisher:
publish-to-pypi.yml on weijie-tan3/trino-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trino_mcp-0.1.2.tar.gz -
Subject digest:
78774f4b8701c1c95443654f26503ca7298eb403ad397990dd808449049a9d8d - Sigstore transparency entry: 709886216
- Sigstore integration time:
-
Permalink:
weijie-tan3/trino-mcp@a0797f6f7fc8890e2129d18e43349c4a070e14c7 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/weijie-tan3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a0797f6f7fc8890e2129d18e43349c4a070e14c7 -
Trigger Event:
release
-
Statement type:
File details
Details for the file trino_mcp-0.1.2-py3-none-any.whl.
File metadata
- Download URL: trino_mcp-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
68f347cf5616103051eed62842281b11e4a4b45a08829e5e2d51ad836d798fcd
|
|
| MD5 |
2c1cd94aedeaca31f2c86e4df19deea7
|
|
| BLAKE2b-256 |
147cff3f476dd7e57724ba6f48ca3bda9af36ea083d347e2a99df04658c088a0
|
Provenance
The following attestation bundles were made for trino_mcp-0.1.2-py3-none-any.whl:
Publisher:
publish-to-pypi.yml on weijie-tan3/trino-mcp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trino_mcp-0.1.2-py3-none-any.whl -
Subject digest:
68f347cf5616103051eed62842281b11e4a4b45a08829e5e2d51ad836d798fcd - Sigstore transparency entry: 709886218
- Sigstore integration time:
-
Permalink:
weijie-tan3/trino-mcp@a0797f6f7fc8890e2129d18e43349c4a070e14c7 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/weijie-tan3
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-to-pypi.yml@a0797f6f7fc8890e2129d18e43349c4a070e14c7 -
Trigger Event:
release
-
Statement type: