Trino (SQL Query Engine) logo

Trino (SQL Query Engine)

Community
alaturqua

MCP Server for Trino developed via MCP Python SDK

Publisheralaturqua
Repositorymcp-trino-python
LanguagePython
Forks
12
Stars
23
Available tools
0
Transport typestdio
Categories
LicenseApache-2.0
Links
  • Connect tools to AI workflows

    Trino (SQL Query Engine) exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    23 stars and 12 forks from the linked repository.

MseeP.ai Security Assessment Badge

MCP Trino Server

smithery badge Python 3.12+ VS Code Docker License

The MCP Trino Server is a Model Context Protocol (MCP) server that provides seamless integration with Trino and Iceberg, enabling advanced data exploration, querying, and table maintenance capabilities through a standard interface.

Use Cases

  • Interactive data exploration and analysis in Trino
  • Automated Iceberg table maintenance and optimization
  • Building AI-powered tools that interact with Trino databases
  • Executing and managing SQL queries with proper result formatting

Prerequisites

  1. A running Trino server (or Docker Compose for local development)
  2. Python 3.12 or higher
  3. Docker (optional, for containerized deployment)

Quick Start

1. Clone the Repository

bash
git clone https://github.com/alaturqua/mcp-trino-python.git
cd mcp-trino-python

2. Create Environment File

Create a .env file in the root directory:

bash
TRINO_HOST=localhost
TRINO_PORT=8080
TRINO_USER=trino
TRINO_CATALOG=tpch
TRINO_SCHEMA=tiny

3. Run Trino Locally (Optional)

bash
docker-compose up -d trino

This starts a Trino server on localhost:8080 with sample TPC-H and TPC-DS data.

Installation

Installing via Smithery

To install MCP Trino Server for Claude Desktop automatically via Smithery:

bash
npx -y @smithery/cli install @alaturqua/mcp-trino-python --client claude

Using uv (Recommended)

bash
uv sync
uv run src/server.py

Using pip

bash
pip install -e .
python src/server.py

Transport Modes

The server supports three transport modes:

TransportDescriptionUse Case
stdioStandard I/O (default)VS Code, Claude Desktop, local MCP clients
streamable-httpHTTP with streamingRemote access, web clients, Docker
sseServer-Sent EventsLegacy HTTP transport

Running with Different Transports

bash
# stdio (default) - for VS Code and Claude Desktop
python src/server.py

# Streamable HTTP - for remote/web access
python src/server.py --transport streamable-http --host 0.0.0.0 --port 8000

# SSE - legacy HTTP transport
python src/server.py --transport sse --host 0.0.0.0 --port 8000

Usage with VS Code

Add to your VS Code settings (Ctrl+Shift+PPreferences: Open User Settings (JSON)):

json
{
  "mcp": {
    "servers": {
      "mcp-trino-python": {
        "command": "uv",
        "args": [
          "run",
          "--with",
          "mcp[cli]",
          "--with",
          "trino",
          "--with",
          "loguru",
          "mcp",
          "run",
          "/path/to/mcp-trino-python/src/server.py"
        ],
        "envFile": "/path/to/mcp-trino-python/.env"
      }
    }
  }
}

Or add to .vscode/mcp.json in your workspace (without the mcp wrapper key).

Usage with Claude Desktop

Add to your Claude Desktop configuration:

json
{
  "mcpServers": {
    "trino": {
      "command": "python",
      "args": ["./src/server.py"],
      "env": {
        "TRINO_HOST": "your-trino-host",
        "TRINO_PORT": "8080",
        "TRINO_USER": "trino"
      }
    }
  }
}

Docker Usage

Build the Image

bash
docker build -t mcp-trino-python .

Run with stdio (for VS Code)

bash
docker run -i --rm \
  -e TRINO_HOST=host.docker.internal \
  -e TRINO_PORT=8080 \
  -e TRINO_USER=trino \
  mcp-trino-python

Run with Streamable HTTP

bash
docker run -p 8000:8000 \
  -e TRINO_HOST=host.docker.internal \
  -e TRINO_PORT=8080 \
  mcp-trino-python \
  --transport streamable-http --host 0.0.0.0 --port 8000

Docker Compose

bash
# Start Trino + MCP server with Streamable HTTP
docker-compose up -d

# Start with SSE transport
docker-compose --profile sse up -d

# Run stdio for testing
docker-compose --profile stdio run --rm mcp-trino-stdio

VS Code with Docker

json
{
  "mcp": {
    "servers": {
      "mcp-trino-python": {
        "command": "docker",
        "args": [
          "run",
          "-i",
          "--rm",
          "--network",
          "mcp-trino-python_trino-network",
          "-e",
          "TRINO_HOST=trino",
          "-e",
          "TRINO_PORT=8080",
          "-e",
          "TRINO_USER=trino",
          "mcp-trino-python"
        ]
      }
    }
  }
}

Configuration

Environment Variables

VariableDescriptionDefault
TRINO_HOSTTrino server hostnamelocalhost
TRINO_PORTTrino server port8080
TRINO_USERTrino usernametrino
TRINO_CATALOGDefault catalogNone
TRINO_SCHEMADefault schemaNone
TRINO_HTTP_SCHEMEHTTP scheme (http/https)http
TRINO_PASSWORDTrino passwordNone

Tools

Query and Exploration Tools

  • show_catalogs

    • List all available catalogs
    • No parameters required
  • show_schemas

    • List all schemas in a catalog
    • Parameters:
      • catalog: Catalog name (string, required)
  • show_tables

    • List all tables in a schema
    • Parameters:
      • catalog: Catalog name (string, required)
      • schema: Schema name (string, required)
  • describe_table

    • Show detailed table structure and column information
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • execute_query

    • Execute a SQL query and return formatted results
    • Parameters:
      • query: SQL query to execute (string, required)
  • show_catalog_tree

    • Show a hierarchical tree view of catalogs, schemas, and tables
    • Returns a formatted tree structure with visual indicators
    • No parameters required
  • show_create_table

    • Show the CREATE TABLE statement for a table
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_create_view

    • Show the CREATE VIEW statement for a view
    • Parameters:
      • view: View name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_stats

    • Show statistics for a table
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)

Iceberg Table Maintenance

  • optimize

    • Optimize an Iceberg table by compacting small files
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • optimize_manifests

    • Optimize manifest files for an Iceberg table
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • expire_snapshots

    • Remove old snapshots from an Iceberg table
    • Parameters:
      • table: Table name (string, required)
      • retention_threshold: Age threshold (e.g., "7d") (string, optional)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)

Iceberg Metadata Inspection

  • show_table_properties

    • Show Iceberg table properties
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_table_history

    • Show Iceberg table history/changelog
    • Contains snapshot timing, lineage, and ancestry information
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_metadata_log_entries

    • Show Iceberg table metadata log entries
    • Contains metadata file locations and sequence information
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_snapshots

    • Show Iceberg table snapshots
    • Contains snapshot details including operations and manifest files
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_manifests

    • Show Iceberg table manifests for current or all snapshots
    • Contains manifest file details and data file statistics
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
      • all_snapshots: Include all snapshots (boolean, optional)
  • show_partitions

    • Show Iceberg table partitions
    • Contains partition statistics and file counts
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_files

    • Show Iceberg table data files in current snapshot
    • Contains detailed file metadata and column statistics
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
  • show_entries

    • Show Iceberg table manifest entries for current or all snapshots
    • Contains entry status and detailed file metrics
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)
      • all_snapshots: Include all snapshots (boolean, optional)
  • show_refs

    • Show Iceberg table references (branches and tags)
    • Contains reference configuration and snapshot mapping
    • Parameters:
      • table: Table name (string, required)
      • catalog: Catalog name (string, optional)
      • schema: Schema name (string, optional)

Query History

  • show_query_history
    • Get the history of executed queries
    • Parameters:
      • limit: Maximum number of queries to return (number, optional)

License

This project is licensed under the Apache 2.0 License. Please refer to the LICENSE file for the full terms.

Installation

TypingMind
Prerequisites:

Node.js 18+

{
  "mcpServers": {
    "trino": {
      "command": "uvx",
      "args": [
        "trino-mcp"
      ],
      "env": {
        "TRINO_HOST": "your-trino-host",
        "TRINO_PORT": "8080",
        "TRINO_USER": "trino"
      }
    }
  }
}

Use Trino (SQL Query Engine) MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once Trino (SQL Query Engine) is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add Trino (SQL Query Engine) as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the Trino (SQL Query Engine) MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "trino-sql-query-engine": {
      "command": "npx",
      "args": [
        "-y",
        "mcp-trino-python"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the Trino (SQL Query Engine) MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the Trino (SQL Query Engine) MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use Trino (SQL Query Engine) to help me with this task?
Trino (SQL Query Engine)
Sure. I read it.
Here is what I found using Trino (SQL Query Engine).

Frequently asked questions

What is the Trino (SQL Query Engine) MCP server used for?

Trino (SQL Query Engine) is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use Trino (SQL Query Engine) MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use Trino (SQL Query Engine) with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use Trino (SQL Query Engine) MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With Trino (SQL Query Engine) connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect Trino (SQL Query Engine) MCP to TypingMind?

Trino (SQL Query Engine) runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does Trino (SQL Query Engine) MCP provide in TypingMind?

Trino (SQL Query Engine) exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use Trino (SQL Query Engine) MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If Trino (SQL Query Engine) requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇