Trino MCP Server
Allows querying Trino databases with OAuth2/SSO authentication, providing tools for listing catalogs, schemas, tables, describing table structures, sampling data, and executing arbitrary SQL queries.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Trino MCP Serverlist tables in hive.default"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Trino MCP Server
Python MCP server for querying Trino with SSO via OAuth2 external authentication. It uses trino-python-client, launches the browser on first authenticated query, and communicates with MCP clients over stdio.
This repository is intended to be simple, local-first, and compatible with Cursor.
Features
Python 3.10+
trino-python-clientwithOAuth2Authentication()MCP server built with
@modelcontextprotocol/python-sdkstdiotransport for Cursor compatibilityReusable Trino connection
JSON-compatible responses for every tool
Simple logging to
stderrSafer identifier handling for catalog, schema, and table names
Related MCP server: Trino MCP Server
Project structure
trino_mcp/
├── server.py
└── requirements.txtRequirements
Python 3.10+
Network access to the target Trino cluster
A Trino environment configured for OAuth2 / external authentication
Quick start
Install directly from GitHub:
pip install "git+https://github.com/ThainaJardim/trino-mcp-python.git"Then create a local .cursor/mcp.json like this:
{
"mcpServers": {
"trino": {
"command": "/absolute/path/to/python",
"args": ["-m", "trino_mcp.server"],
"env": {
"TRINO_HOST": "your-trino-host.example.com",
"TRINO_PORT": "443",
"TRINO_USER": "your-user",
"TRINO_CATALOG": "hive",
"TRINO_SCHEMA": "default",
"TRINO_HTTP_SCHEME": "https"
}
}
}
}After reloading Cursor, test with:
list_catalogsexecute_querywith{ "sql": "SELECT 1 AS ok" }
Expected behavior:
the MCP server starts over
stdiothe first real query opens the browser for OAuth2 / SSO login
after login, the query result returns as structured JSON
Installation from source
pip install -r trino_mcp/requirements.txtOr install the project itself:
pip install .Configuration
The server can be configured with environment variables.
Variable | Default |
|
|
|
|
| current OS user |
|
|
|
|
|
|
|
|
Example:
export TRINO_HOST=trino.example.com
export TRINO_PORT=443
export TRINO_USER="$USER"
export TRINO_CATALOG=hive
export TRINO_SCHEMA=default
export TRINO_HTTP_SCHEME=httpsRun locally
python trino_mcp/server.pyOr, after pip install .:
trino-mcpExpected behavior:
The server starts and waits for MCP requests over
stdioThe browser does not open immediately
The OAuth2 login flow starts only when a tool executes the first real query
Cursor setup
Create a local .cursor/mcp.json file like this:
{
"mcpServers": {
"trino": {
"command": "/absolute/path/to/python",
"args": ["-m", "trino_mcp.server"],
"env": {
"TRINO_HOST": "your-trino-host.example.com",
"TRINO_PORT": "443",
"TRINO_USER": "your-user",
"TRINO_CATALOG": "hive",
"TRINO_SCHEMA": "default",
"TRINO_HTTP_SCHEME": "https"
}
}
}
}Why use this format:
commandshould point to the exact Python wheretrino-mcpwas installed-m trino_mcp.serveravoids depending on the shellPATHenvkeeps the Trino connection settings local to the MCP server
If you are developing from a local checkout instead of installing from GitHub, this also works:
{
"mcpServers": {
"trino": {
"command": "/absolute/path/to/python",
"args": ["./trino_mcp/server.py"],
"env": {
"TRINO_HOST": "your-trino-host.example.com",
"TRINO_PORT": "443",
"TRINO_USER": "your-user",
"TRINO_CATALOG": "hive",
"TRINO_SCHEMA": "default",
"TRINO_HTTP_SCHEME": "https"
}
}
}
}The .cursor/ directory is intentionally ignored by Git because it contains machine-specific local configuration.
Available tools
Tool | Description | Input |
| Execute an arbitrary SQL query |
|
| Run |
|
| Run |
|
| Run |
|
| Run |
|
| Run |
|
Response format
Successful tool calls return a JSON-compatible object like:
{
"ok": true,
"sql": "SHOW CATALOGS",
"columns": ["Catalog"],
"row_count": 2,
"rows": [
{ "Catalog": "hive" },
{ "Catalog": "system" }
]
}Errors are returned in a structured format:
{
"ok": false,
"sql": "SHOW CATALOGS",
"error": "..."
}How OAuth2 login works
This project relies on OAuth2Authentication() from trino-python-client, which supports external browser login flows. In practice:
Cursor calls a tool such as
list_catalogsThe server opens a Trino connection
trino-python-clientlaunches the browser for the OAuth2 login if neededAfter authentication, the query is executed and the response is returned to Cursor
This is different from adding OAuth to the MCP server itself. The OAuth flow here is specifically for the Trino connection.
Troubleshooting
Cursor says the MCP server errored
The most common cause is an interpreter mismatch:
pythonin your shell hasmcpandtrinoCursor starts the server with another interpreter such as system
python3
Check both:
python -c "import sys; print(sys.executable); import mcp, trino; print('ok')"
python3 -c "import sys; print(sys.executable); import mcp, trino; print('ok')"If only one of them works, use that exact interpreter in .cursor/mcp.json.
The browser does not open
Make sure the first tool call actually reached Trino
Check that the environment has a GUI/browser available
Confirm the Trino cluster is configured for OAuth2 external authentication
Authentication keeps repeating
OAuth token caching behavior depends on the trino-python-client process lifetime. If the MCP process is restarted frequently, the login flow may repeat.
Manual test
You can test the server with the MCP Inspector:
npx -y @modelcontextprotocol/inspector /absolute/path/to/python -m trino_mcp.serverThen call list_catalogs and verify that:
the browser login opens
the query succeeds
the response returns structured JSON
Development
Install development dependencies:
pip install .[dev]Run tests:
pytestThis server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Latest Blog Posts
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/ThainaJardim/trino-mcp-python'
If you have feedback or need assistance with the MCP directory API, please join our Discord server