Trino MCP Server
Provides secure read-only access to Trino databases: executing SELECT/SHOW/DESCRIBE/EXPLAIN queries, listing catalogs, schemas, tables, and columns, describing table structures, sampling table data, retrieving table statistics and row counts, testing connections, and automatically masking detected PII in results.
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
Trino MCP Server
A production-ready Model Context Protocol (MCP) server that provides secure, read-only access to Trino databases. Perfect for data engineers and analysts who want to leverage AI tools (like Cursor) to query and explore Trino databases.
🚀 Quick Start
Get up and running in 5 minutes:
Prerequisites: Docker Desktop, Cursor IDE, and access to a Trino server
Build:
docker build -t trino-mcp-server:latest .Configure: Add MCP server to Cursor configuration
Test: Ask Cursor to "show me all catalogs in Trino"
See Installation for detailed platform-specific instructions.
Related MCP server: VAST DB MCP Server
📋 Features
Core Capabilities
✅ Read-Only Safety: All write operations (INSERT, UPDATE, DELETE, etc.) are blocked
✅ Query Execution: Execute SELECT, SHOW, DESCRIBE, EXPLAIN queries
✅ Database Exploration: List catalogs, schemas, tables, and columns
✅ Data Sampling: Preview table data with configurable limits
✅ Table Statistics: Get row counts and column statistics
✅ Optional Authentication: Support for password-based authentication
✅ Health Checks: Built-in connection testing tool
✅ PII Masking: Automatic detection and masking of sensitive data (emails, phones, addresses, etc.)
Available Tools
Tool | Description |
| Execute read-only SQL queries (SELECT, SHOW, DESCRIBE only) |
| List all available catalogs in Trino |
| Show all schemas in a specific catalog |
| List all tables in a schema |
| Get the structure and column details of a table |
| Show detailed column information for a table |
| Get statistics about a table including row count |
| Get a sample of rows from a table (default 10, max 100) |
| Test connection to Trino and get server information |
🎯 Use Cases
For Data Engineers
Database Exploration: Quickly discover available catalogs, schemas, and tables
Schema Analysis: Understand table structures and relationships
Data Quality Checks: Sample data and check statistics before running full queries
Query Development: Test and refine SQL queries with AI assistance
For Data Analysts
Ad-Hoc Analysis: Run analytical queries without writing complex SQL
Data Discovery: Explore datasets and understand their structure
Quick Insights: Get table statistics and sample data for rapid analysis
Report Generation: Use AI to generate queries for common reporting needs
Installation
Prerequisites
Before you begin, ensure you have:
Docker Desktop installed and running
Verify installation:
docker --version
Cursor IDE installed
Ensure MCP Toolkit is enabled in settings
Trino Server access
A running Trino server (local or remote)
Connection details (host, port, user, catalog, schema)
Network access to the Trino server
Step 1: Clone or Download
git clone https://github.com/dikshantks/trino-mcp-server.git
cd trino-mcp-serverOr download and extract the project files.
Step 2: Build Docker Image
docker build -t trino-mcp-server:latest .Verify the image was created:
docker images | grep trino-mcp-serverStep 3: Configure Environment Variables
The server uses environment variables for configuration. You'll set these when configuring Cursor MCP.
Required Variables:
TRINO_HOST: Trino server hostname (default:host.docker.internal)TRINO_PORT: Trino server port (default:8088)TRINO_USER: Trino username (default:trino)TRINO_CATALOG: Default catalog name (default:tpch)TRINO_SCHEMA: Default schema name (default:tiny)
Optional Variables:
TRINO_PASSWORD: Password for authentication (if required)TRINO_USE_HTTPS: Use HTTPS instead of HTTP (true/false, default:false)LOG_LEVEL: Logging level (DEBUG,INFO,WARNING,ERROR, default:INFO)
💻 Platform-Specific Setup
Windows
1. Install Docker Desktop
Download Docker Desktop for Windows
Install and start Docker Desktop
Enable WSL 2 backend (recommended) if prompted
2. Build the Image
Open PowerShell or Command Prompt:
cd path\to\trino-mcp-server
docker build -t trino-mcp-server:latest .3. Configure Cursor MCP
Open Cursor Settings (Ctrl+,)
Navigate to MCP or search for "MCP"
Open the MCP configuration file:
%APPDATA%\Cursor\mcp.jsonAdd the Trino MCP server configuration (see Cursor MCP Integration)
Linux
1. Install Docker
Ubuntu/Debian:
sudo apt-get update
sudo apt-get install docker.io docker-compose
sudo systemctl start docker
sudo systemctl enable docker2. Build the Image
cd trino-mcp-server
docker build -t trino-mcp-server:latest .3. Configure Cursor MCP
Open Cursor Settings
Navigate to MCP
Open the MCP configuration file:
Add the Trino MCP server configuration
Linux-Specific Configuration
Common Linux Issues
Permission denied: Add user to docker group (see above)
host.docker.internal not working: Use
--network hostor--add-hostflagFirewall blocking: Check firewall rules for Docker
macOS
1. Install Docker Desktop
Download Docker Desktop for Mac
Install and start Docker Desktop
Verify installation:
docker --version
2. Build the Image
Open Terminal:
cd path/to/trino-mcp-server
docker build -t trino-mcp-server:latest .3. Configure Cursor MCP
Open Cursor Settings (Cmd+,)
Navigate to MCP
Open the MCP configuration file:
~/cursor/mcp.jsonAdd the Trino MCP server configuration
🔌 Cursor MCP Integration
Step-by-Step Configuration
Open Cursor Settings
Go to File → Preferences → Settings
Navigate to MCP Settings
Search for "MCP" in settings
Or manually navigate to the MCP configuration file (see platform-specific paths above)
Edit Configuration File
Open the
mcp.jsonfileAdd the Trino MCP server configuration
$ /.cursor/mcp.json
{
"mcpServers": {
"trino": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--network", "host",
"-e", "TRINO_HOST=localhost",
"-e", "TRINO_PORT=8088",
"-e", "TRINO_USER=trino",
"-e", "TRINO_CATALOG=iceberg",
"-e", "TRINO_SCHEMA=tiny",
"trino-mcp-test:latest"
]
}
}
}
Restart Cursor
Fully quit and restart Cursor to load the new configuration
Test Connection
Open a chat in Cursor
Ask: "Show me all catalogs in Trino"
The AI should use the Trino MCP tools
Configuration Examples
Basic Configuration (Local Trino)
{
"mcpServers": {
"trino": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TRINO_HOST=host.docker.internal",
"-e", "TRINO_PORT=8088",
"-e", "TRINO_USER=trino",
"-e", "TRINO_CATALOG=tpch",
"-e", "TRINO_SCHEMA=tiny",
"trino-mcp-server:latest"
]
}
}
}With Authentication
{
"mcpServers": {
"trino": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TRINO_HOST=host.docker.internal",
"-e", "TRINO_PORT=8088",
"-e", "TRINO_USER=admin",
"-e", "TRINO_PASSWORD=your_password_here",
"-e", "TRINO_CATALOG=my_catalog",
"-e", "TRINO_SCHEMA=my_schema",
"trino-mcp-server:latest"
]
}
}
}Remote Trino via SSH Tunnel
First, establish SSH tunnel in a separate terminal:
ssh -L 8088:localhost:8088 user@trino-server-hostThen use this configuration:
{
"mcpServers": {
"trino": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"--network", "host",
"-e", "TRINO_HOST=localhost",
"-e", "TRINO_PORT=8088",
"-e", "TRINO_USER=trino",
"-e", "TRINO_CATALOG=tpch",
"-e", "TRINO_SCHEMA=tiny",
"trino-mcp-server:latest"
]
}
}
}HTTPS Connection
{
"mcpServers": {
"trino": {
"command": "docker",
"args": [
"run", "-i", "--rm",
"-e", "TRINO_HOST=trino.example.com",
"-e", "TRINO_PORT=8443",
"-e", "TRINO_USER=trino",
"-e", "TRINO_USE_HTTPS=true",
"-e", "TRINO_CATALOG=tpch",
"-e", "TRINO_SCHEMA=tiny",
"trino-mcp-server:latest"
]
}
}
}Verifying the Connection
Check MCP Server Status
Look for MCP server status in Cursor's status bar
Or check Cursor's MCP panel (if available)
Test with a Simple Query
Ask Cursor: "Test the Trino connection"
Or: "Show me all catalogs in Trino"
The AI should successfully use the MCP tools
Check Logs (if issues occur)
Docker logs:
docker psto find container, thendocker logs <container-id>Cursor logs: Check Cursor's developer console
⚙️ Configuration Reference
Environment Variables
Variable | Required | Default | Description |
| Yes |
| Trino server hostname |
| Yes |
| Trino server port |
| Yes |
| Trino username |
| Yes |
| Default catalog name |
| Yes |
| Default schema name |
| No | - | Password for authentication (if required) |
| No |
| Use HTTPS instead of HTTP |
| No |
| Logging level (DEBUG, INFO, WARNING, ERROR) |
| No |
| Enable PII masking to redact sensitive data |
| No |
| Masking style: |
| No | - | Additional column names to always mask (comma-separated) |
| No | - | Column names to never mask (comma-separated, overrides auto-detection) |
PII Masking
The server includes a configurable PII masking feature to prevent sensitive data from being exposed to the LLM:
How it works:
Column-Name Detection: Automatically detects columns with names like
email,phone,address,aadhaar,pan, etc.Content Scanning: Scans cell values for patterns that look like PII (emails, phone numbers, credit cards, etc.)
Smart Masking: Masks data while preserving format context (e.g.,
j***n@g***.comfor emails)
Configuration:
PII_MASKING_ENABLED=true- Enable masking (off by default)PII_MASK_STYLE=partial- Show partial characters for context, orfullfor complete redactionPII_MASKED_COLUMNS=custom_field,secret_data- Force masking on specific columnsPII_ALLOWED_COLUMNS=order_email,system_phone- Skip masking on specific columns
Detected PII Types:
Email addresses
Phone numbers (international and Indian formats)
IP addresses
Credit card numbers
Indian Aadhaar numbers
Indian PAN numbers
Names, addresses, and other personal identifiers
Example output with masking:
| email | phone | name |
|-----------------|--------------|---------|
| j***n@g***.com | ***-***-4567 | J***n |
[PII Masking Active] Masked columns: email (email), phone (phone), name (personal)Authentication
The server supports optional password-based authentication:
No Authentication: If
TRINO_PASSWORDis not set, connections use no authenticationBasic Authentication: If
TRINO_PASSWORDis set, BasicAuth is usedHTTPS: Set
TRINO_USE_HTTPS=truefor secure connections
Network Configuration
Local Trino Server:
Use
host.docker.internalasTRINO_HOST(Windows/macOS)On Linux, use
--network hostor--add-hostflag
Remote Trino Server:
Use SSH tunnel:
ssh -L 8088:localhost:8088 user@hostSet
TRINO_HOST=localhostand use--network hostOr use direct connection with proper firewall rules
📖 Usage Examples
Basic Database Exploration
User: Show me all catalogs in Trino
AI: [Uses show_catalogs tool]
User: What schemas are in the tpch catalog?
AI: [Uses show_schemas tool with catalog="tpch"]
User: List all tables in tpch.tiny
AI: [Uses show_tables tool]Table Analysis
User: Describe the customer table structure
AI: [Uses describe_table tool]
User: Show me 5 sample rows from the orders table
AI: [Uses sample_table tool with limit=5]
User: Get statistics for the lineitem table
AI: [Uses get_table_stats tool]Query Execution
User: Run this query: SELECT COUNT(*) FROM tpch.tiny.customer
AI: [Uses execute_query tool]
User: Show me the top 10 customers by order count
AI: [Uses execute_query with a JOIN query]Data Engineering Workflows
User: Help me explore the sales database
AI: [Uses multiple tools: show_catalogs, show_schemas, show_tables]
User: What's the schema of the transactions table?
AI: [Uses describe_table tool]
User: Check if the transactions table has any data
AI: [Uses get_table_stats tool]🔧 Troubleshooting
Connection Issues
Problem: Cannot connect to Trino server
Solutions:
Verify Trino server is running:
curl http://localhost:8088/v1/infoCheck environment variables are correct:
TRINO_HOSTmatches your Trino server addressTRINO_PORTmatches your Trino server portTRINO_USERis valid
For Docker networking:
Windows/macOS: Use
host.docker.internalLinux: Use
--network hostor--add-host=host.docker.internal:host-gateway
Check firewall rules and network connectivity
Problem: Connection works locally but not in Docker
Solutions:
Use
host.docker.internalinstead oflocalhostOn Linux, add
--add-host=host.docker.internal:host-gatewayOr use
--network hostmode
Cursor MCP Integration Issues
Problem: MCP server not appearing in Cursor
Solutions:
Verify JSON syntax in configuration file
Check Docker image exists:
docker images | grep trino-mcp-serverTest Docker run manually:
docker run -i --rm -e TRINO_HOST=host.docker.internal -e TRINO_PORT=8088 trino-mcp-server:latestFully restart Cursor (not just reload window)
Check Cursor logs for errors
Problem: Tools not working in Cursor
Solutions:
Use the
test_connectiontool to verify connectivityCheck Docker container logs
Verify environment variables are set correctly
Ensure Trino server is accessible from Docker container
Query Execution Issues
Problem: Query execution fails
Solutions:
Verify query is read-only (SELECT, SHOW, DESCRIBE only)
Check table/schema/catalog names are correct
Verify user has read permissions
Check Trino server logs for detailed errors
Problem: "Only read-only queries are allowed" error
Solutions:
The server blocks all write operations for safety
Use only SELECT, SHOW, DESCRIBE, EXPLAIN, WITH queries
Check query doesn't contain INSERT, UPDATE, DELETE, etc.
Authentication Issues
Problem: Authentication failed
Solutions:
Verify
TRINO_USERis correctCheck
TRINO_PASSWORDis set correctly (if required)Verify user has read permissions on the catalog
Check Trino server authentication configuration
Docker Issues
Problem: Docker build fails
Solutions:
Check Docker is running:
docker psVerify Dockerfile syntax
Check internet connection (for downloading dependencies)
Try rebuilding:
docker build --no-cache -t trino-mcp-server:latest .
Problem: Container exits immediately
Solutions:
Check logs:
docker logs <container-id>Verify environment variables are set
Test connection manually
Check Trino server is accessible
🛠️ Development
Local Development Setup
Install Python dependencies:
pip install -r requirements.txtSet environment variables:
export TRINO_HOST="localhost" export TRINO_PORT="8088" export TRINO_USER="trino" export TRINO_CATALOG="tpch" export TRINO_SCHEMA="tiny"Run server directly:
python trino_server.pyTest MCP protocol:
echo '{"jsonrpc":"2.0","method":"tools/list","id":1}' | python trino_server.py
Adding New Tools
Add function to
trino_server.pyDecorate with
@mcp.tool()Ensure it validates queries for read-only access (if executing queries)
Add comprehensive docstring
Test locally
Rebuild Docker image
Code Style
Follow PEP 8 Python style guide
Use type hints for all functions
Add docstrings with examples
Keep functions focused and single-purpose
📄 License
MIT License - see LICENSE file for details.
🤝 Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
📚 Additional Resources
Happy Querying! 🚀
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Governed access to production AI-agent traces in an existing ClickHouse store.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides AI models with structured access to Trino's distributed SQL query engine, enabling LLMs to directly query and analyze data stored in Trino databases.310MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to securely query VAST Data databases for schema, metadata, and sample data via read-only SQL and MCP resources.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute read-only SQL against Spark, Hive, and HiveServer2-compatible clusters, discover databases and table schemas, and connect using multiple authentication modes.MIT
- AlicenseAqualityBmaintenanceEnables AI assistants such as Claude, ChatGPT and Cursor to safely explore database schemas and answer business questions by running read-only SQL queries in plain English.4MIT