Skip to main content

A Model Context Protocol (MCP) connector for Trino, enabling seamless integration between MCP-compliant services and Trino query engine

Project description

MCP Trino Server

Python 3.11+ 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.11 or higher
  3. Docker (optional, for containerized deployment)

Installation

Running Trino Locally

The easiest way to get started is to use the included Docker Compose configuration to run Trino locally:

docker-compose up -d

This will start a Trino server on localhost:8080. You can now proceed with configuring the MCP server.

Usage with VS Code

For quick installation, you can add the following configuration to your VS Code settings. You can do this by pressing Ctrl + Shift + P and typing Preferences: Open User Settings (JSON).

Optionally, you can add it to a file called .vscode/mcp.json in your workspace. This will allow you to share the configuration with others.

Note that the mcp key is not needed in the .vscode/mcp.json file.

{
  "mcp": {
    "servers": {
      "trino": {
        "command": "docker",
        "args": ["run", "--rm", "ghcr.io/alaturqua/mcp-trino-python:latest"],
        "env": {
          "TRINO_HOST": "${input:trino_host}",
          "TRINO_PORT": "${input:trino_port}",
          "TRINO_USER": "${input:trino_user}"
        }
      }
    }
  }
}

Usage with Claude Desktop

Add the following configuration to your Claude Desktop settings:

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

Configuration

Environment Variables

Variable Description Default
TRINO_HOST Trino server hostname localhost
TRINO_PORT Trino server port 8080
TRINO_USER Trino username trino
TRINO_CATALOG Default catalog None
TRINO_SCHEMA Default schema None
TRINO_HTTP_SCHEME HTTP scheme (http/https) http
TRINO_AUTH Authentication method None

Resources

The server provides the following MCP resources:

Catalog and Schema Navigation

  • catalog://main (list_catalogs)

    • Lists all available Trino catalogs
    • No parameters required
  • schema://{catalog} (list_schemas)

    • Lists all schemas in the specified catalog
    • Parameters:
      • catalog: Catalog name (string, required)
  • table://{catalog}/{schema} (list_tables)

    • Lists all tables in the specified schema
    • Parameters:
      • catalog: Catalog name (string, required)
      • schema: Schema name (string, required)

Tools

Query and Exploration Tools

  • 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)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_trino_python-0.2.0.tar.gz (11.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_trino_python-0.2.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file mcp_trino_python-0.2.0.tar.gz.

File metadata

  • Download URL: mcp_trino_python-0.2.0.tar.gz
  • Upload date:
  • Size: 11.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for mcp_trino_python-0.2.0.tar.gz
Algorithm Hash digest
SHA256 2f2d3f7a1d07f7cf90c08af65f84cff5b687e62d5f039f0f46e44c78c87ba8a5
MD5 98274812c6b909f0c0380cb8890872ac
BLAKE2b-256 2a2d92377ec3727a961963f72e922dcfb5e0e4da475481e3598bd61ae1fb7435

See more details on using hashes here.

File details

Details for the file mcp_trino_python-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for mcp_trino_python-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8bc38f5ff77c56cd6cf0128be0274fec8625f4b1d7b13b1956ea2ca47bdb51e7
MD5 b3d1341b7b61360b6807400dbd109cc9
BLAKE2b-256 2e25e5e6c6cc7c20a34c4dc95c7e7bf4072ae2a9c0e27840256b7b1daad8e610

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page