Skip to main content
Glama

mcp-trino

by tuannvm
MIT License
73
  • Apple
  • Linux
SOLUTION.md3.64 kB
# Trino MCP Server in Go - Solution Summary ## Overview This project provides a complete reimplementation of the Trino MCP Server in Go using the Model Context Protocol (MCP) SDK from mark3labs/mcp-go. The solution enables AI models to interact with Trino's distributed SQL query engine through a standardized interface. ## Solution Components 1. **Trino Client Wrapper**: - Implements a robust client for connecting to Trino servers - Handles query execution, result parsing, and error handling - Provides convenience methods for common Trino operations 2. **MCP Server Integration**: - Implements the Model Context Protocol using the MCP Go SDK - Exposes Trino functionality through MCP tools - Provides both STDIO and HTTP transport options 3. **Docker Support**: - Containerized deployment with Docker and Docker Compose - Multi-container setup with Trino server and MCP server - Environment variable configuration 4. **API Endpoints**: - HTTP API for executing Trino queries - JSON-formatted responses for easy consumption ## Key Features Implemented 1. **Server Initialization**: - Go-based MCP server implementation - Configuration via environment variables - Graceful shutdown and error handling 2. **API Exposure**: - HTTP API endpoints for querying Trino - Support for both Docker container and standalone usage 3. **LLM Integration**: - STDIO transport for direct LLM interaction - MCP tools for natural language data exploration 4. **Transport Options**: - Reliable STDIO transport implementation - HTTP API for web-based access 5. **Query Capabilities**: - SQL query execution - Catalog, schema, and table exploration - Table schema retrieval ## Directory Structure ``` . ├── cmd/ │ └── server/ # Main server code ├── internal/ │ ├── config/ # Configuration handling │ ├── handlers/ # MCP tool handlers │ └── trino/ # Trino client implementation ├── examples/ # Example code ├── scripts/ # Build and run scripts ├── bin/ # Compiled binaries └── trino-conf/ # Trino configuration files ``` ## Getting Started 1. **Build the server**: ```bash ./scripts/build.sh ``` 2. **Run with STDIO transport** (for LLM integration): ```bash ./scripts/run.sh ``` 3. **Run with HTTP transport** (for API access): ```bash MCP_TRANSPORT=http MCP_PORT=8080 ./scripts/run.sh ``` 4. **Run with Docker Compose**: ```bash docker-compose up -d ``` ## Using with LLMs The MCP server provides the following tools for LLMs: 1. `execute_query` - Executes SQL queries against Trino 2. `list_catalogs` - Lists available catalogs 3. `list_schemas` - Lists schemas in a catalog 4. `list_tables` - Lists tables in a schema 5. `get_table_schema` - Retrieves a table's schema Example of an LLM using the MCP server: ``` LLM: What tables are available in the memory catalog? MCP Server: Let me check the schemas in the memory catalog. [Tools used: list_schemas(catalog="memory")] MCP Server: I found the following schemas: default, information_schema. MCP Server: Let me check the tables in the default schema. [Tools used: list_tables(catalog="memory", schema="default")] MCP Server: I found the following tables: example_table. ``` ## Future Enhancements 1. Add support for more complex query operations 2. Implement authentication and security features 3. Add caching for improved performance 4. Provide more data visualization options 5. Implement comprehensive test suite

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/tuannvm/mcp-trino'

If you have feedback or need assistance with the MCP directory API, please join our Discord server