|
1 | 1 | # Trino MCP Server in Go
|
2 | 2 |
|
| 3 | +A high-performance Model Context Protocol (MCP) server for Trino implemented in Go. This project enables AI assistants to seamlessly interact with Trino's distributed SQL query engine through standardized MCP tools. |
| 4 | + |
3 | 5 | [](https://github.com/tuannvm/mcp-trino/actions/workflows/build.yml)
|
4 | 6 | [](https://github.com/tuannvm/mcp-trino/blob/main/go.mod)
|
5 | 7 | [](https://github.com/tuannvm/mcp-trino/actions/workflows/build.yml)
|
|
10 | 12 | [](https://github.com/tuannvm/mcp-trino/releases/latest)
|
11 | 13 | [](https://opensource.org/licenses/MIT)
|
12 | 14 |
|
13 |
| -Model Context Protocol (MCP) server for Trino, reimplemented in Go. |
| 15 | +## Downloads |
| 16 | + |
| 17 | +You can download pre-built binaries for your platform: |
| 18 | + |
| 19 | +| Platform | Architecture | Download Link | |
| 20 | +|----------|--------------|---------------| |
| 21 | +| macOS | x86_64 (Intel) | [Download](https://github.com/tuannvm/mcp-trino/releases/latest/download/mcp-trino-darwin-amd64) | |
| 22 | +| macOS | ARM64 (Apple Silicon) | [Download](https://github.com/tuannvm/mcp-trino/releases/latest/download/mcp-trino-darwin-arm64) | |
| 23 | +| Linux | x86_64 | [Download](https://github.com/tuannvm/mcp-trino/releases/latest/download/mcp-trino-linux-amd64) | |
| 24 | +| Linux | ARM64 | [Download](https://github.com/tuannvm/mcp-trino/releases/latest/download/mcp-trino-linux-arm64) | |
| 25 | +| Windows | x86_64 | [Download](https://github.com/tuannvm/mcp-trino/releases/latest/download/mcp-trino-windows-amd64.exe) | |
| 26 | + |
| 27 | +Or see all available downloads on the [GitHub Releases](https://github.com/tuannvm/mcp-trino/releases) page. |
14 | 28 |
|
15 | 29 | ## Overview
|
16 | 30 |
|
@@ -199,11 +213,210 @@ Once enabled, click the hammer icon below the input box in ChatWise to access Tr
|
199 | 213 |
|
200 | 214 | The server provides the following MCP tools:
|
201 | 215 |
|
202 |
| -1. `execute_query` - Execute a SQL query against Trino |
203 |
| -2. `list_catalogs` - List all catalogs available in the Trino server |
204 |
| -3. `list_schemas` - List all schemas in a catalog |
205 |
| -4. `list_tables` - List all tables in a schema |
206 |
| -5. `get_table_schema` - Get the schema of a table |
| 216 | +### execute_query |
| 217 | + |
| 218 | +Execute a SQL query against Trino with full SQL support for complex analytical queries. |
| 219 | + |
| 220 | +**Sample Prompt:** |
| 221 | +> "How many customers do we have per region? Can you show them in descending order?" |
| 222 | +
|
| 223 | +**Example:** |
| 224 | +```json |
| 225 | +{ |
| 226 | + "query": "SELECT region, COUNT(*) as customer_count FROM tpch.tiny.customer GROUP BY region ORDER BY customer_count DESC" |
| 227 | +} |
| 228 | +``` |
| 229 | + |
| 230 | +**Response:** |
| 231 | +```json |
| 232 | +{ |
| 233 | + "columns": ["region", "customer_count"], |
| 234 | + "data": [ |
| 235 | + ["AFRICA", 5], |
| 236 | + ["AMERICA", 5], |
| 237 | + ["ASIA", 5], |
| 238 | + ["EUROPE", 5], |
| 239 | + ["MIDDLE EAST", 5] |
| 240 | + ] |
| 241 | +} |
| 242 | +``` |
| 243 | + |
| 244 | +### list_catalogs |
| 245 | + |
| 246 | +List all catalogs available in the Trino server, providing a comprehensive view of your data ecosystem. |
| 247 | + |
| 248 | +**Sample Prompt:** |
| 249 | +> "What databases do we have access to in our Trino environment?" |
| 250 | +
|
| 251 | +**Example:** |
| 252 | +```json |
| 253 | +{} |
| 254 | +``` |
| 255 | + |
| 256 | +**Response:** |
| 257 | +```json |
| 258 | +{ |
| 259 | + "catalogs": ["tpch", "memory", "system", "jmx"] |
| 260 | +} |
| 261 | +``` |
| 262 | + |
| 263 | +### list_schemas |
| 264 | + |
| 265 | +List all schemas in a catalog, helping you navigate through the data hierarchy efficiently. |
| 266 | + |
| 267 | +**Sample Prompt:** |
| 268 | +> "What schemas or datasets are available in the tpch catalog?" |
| 269 | +
|
| 270 | +**Example:** |
| 271 | +```json |
| 272 | +{ |
| 273 | + "catalog": "tpch" |
| 274 | +} |
| 275 | +``` |
| 276 | + |
| 277 | +**Response:** |
| 278 | +```json |
| 279 | +{ |
| 280 | + "schemas": ["information_schema", "sf1", "sf100", "sf1000", "tiny"] |
| 281 | +} |
| 282 | +``` |
| 283 | + |
| 284 | +### list_tables |
| 285 | + |
| 286 | +List all tables in a schema, giving you visibility into available datasets. |
| 287 | + |
| 288 | +**Sample Prompt:** |
| 289 | +> "What tables are available in the tpch tiny schema? I need to know what data we can query." |
| 290 | +
|
| 291 | +**Example:** |
| 292 | +```json |
| 293 | +{ |
| 294 | + "catalog": "tpch", |
| 295 | + "schema": "tiny" |
| 296 | +} |
| 297 | +``` |
| 298 | + |
| 299 | +**Response:** |
| 300 | +```json |
| 301 | +{ |
| 302 | + "tables": ["customer", "lineitem", "nation", "orders", "part", "partsupp", "region", "supplier"] |
| 303 | +} |
| 304 | +``` |
| 305 | + |
| 306 | +### get_table_schema |
| 307 | + |
| 308 | +Get the schema of a table, understanding the structure of your data for better query planning. |
| 309 | + |
| 310 | +**Sample Prompt:** |
| 311 | +> "What columns are in the customer table? I need to know the data types and structure before writing my query." |
| 312 | +
|
| 313 | +**Example:** |
| 314 | +```json |
| 315 | +{ |
| 316 | + "catalog": "tpch", |
| 317 | + "schema": "tiny", |
| 318 | + "table": "customer" |
| 319 | +} |
| 320 | +``` |
| 321 | + |
| 322 | +**Response:** |
| 323 | +```json |
| 324 | +{ |
| 325 | + "columns": [ |
| 326 | + { |
| 327 | + "name": "custkey", |
| 328 | + "type": "bigint", |
| 329 | + "nullable": false |
| 330 | + }, |
| 331 | + { |
| 332 | + "name": "name", |
| 333 | + "type": "varchar", |
| 334 | + "nullable": false |
| 335 | + }, |
| 336 | + { |
| 337 | + "name": "address", |
| 338 | + "type": "varchar", |
| 339 | + "nullable": false |
| 340 | + }, |
| 341 | + { |
| 342 | + "name": "nationkey", |
| 343 | + "type": "bigint", |
| 344 | + "nullable": false |
| 345 | + }, |
| 346 | + { |
| 347 | + "name": "phone", |
| 348 | + "type": "varchar", |
| 349 | + "nullable": false |
| 350 | + }, |
| 351 | + { |
| 352 | + "name": "acctbal", |
| 353 | + "type": "double", |
| 354 | + "nullable": false |
| 355 | + }, |
| 356 | + { |
| 357 | + "name": "mktsegment", |
| 358 | + "type": "varchar", |
| 359 | + "nullable": false |
| 360 | + }, |
| 361 | + { |
| 362 | + "name": "comment", |
| 363 | + "type": "varchar", |
| 364 | + "nullable": false |
| 365 | + } |
| 366 | + ] |
| 367 | +} |
| 368 | +``` |
| 369 | + |
| 370 | +This information is invaluable for understanding the column names, data types, and nullability constraints before writing queries against the table. |
| 371 | + |
| 372 | +## End-to-End Example |
| 373 | + |
| 374 | +Here's a complete interaction example showing how an AI assistant might use these tools to answer a business question: |
| 375 | + |
| 376 | +**User Query:** "Can you help me analyze our biggest customers? I want to know the top 5 customers with the highest account balances." |
| 377 | + |
| 378 | +**AI Assistant's workflow:** |
| 379 | +1. First, discover available catalogs |
| 380 | + ``` |
| 381 | + > Using list_catalogs tool |
| 382 | + > Discovers tpch catalog |
| 383 | + ``` |
| 384 | + |
| 385 | +2. Then, find available schemas |
| 386 | + ``` |
| 387 | + > Using list_schemas tool with catalog "tpch" |
| 388 | + > Discovers "tiny" schema |
| 389 | + ``` |
| 390 | + |
| 391 | +3. Explore available tables |
| 392 | + ``` |
| 393 | + > Using list_tables tool with catalog "tpch" and schema "tiny" |
| 394 | + > Finds "customer" table |
| 395 | + ``` |
| 396 | + |
| 397 | +4. Check the customer table schema |
| 398 | + ``` |
| 399 | + > Using get_table_schema tool |
| 400 | + > Discovers "custkey", "name", "acctbal" and other columns |
| 401 | + ``` |
| 402 | + |
| 403 | +5. Finally, execute the query |
| 404 | + ``` |
| 405 | + > Using execute_query tool with: |
| 406 | + > "SELECT custkey, name, acctbal FROM tpch.tiny.customer ORDER BY acctbal DESC LIMIT 5" |
| 407 | + ``` |
| 408 | + |
| 409 | +6. Returns the results to the user: |
| 410 | + ``` |
| 411 | + The top 5 customers with highest account balances are: |
| 412 | + 1. Customer #65 (Customer#000000065): $9,222.78 |
| 413 | + 2. Customer #13 (Customer#000000013): $8,270.47 |
| 414 | + 3. Customer #89 (Customer#000000089): $7,990.56 |
| 415 | + 4. Customer #11 (Customer#000000011): $7,912.91 |
| 416 | + 5. Customer #82 (Customer#000000082): $7,629.41 |
| 417 | + ``` |
| 418 | + |
| 419 | +This seamless workflow demonstrates how the MCP tools enable AI assistants to explore and query data in a conversational manner. |
207 | 420 |
|
208 | 421 | ## Configuration
|
209 | 422 |
|
@@ -270,9 +483,13 @@ go test ./...
|
270 | 483 | make lint
|
271 | 484 | ```
|
272 | 485 |
|
| 486 | +## Contributing |
| 487 | + |
| 488 | +Contributions are welcome! Please feel free to submit a Pull Request. |
| 489 | + |
273 | 490 | ## License
|
274 | 491 |
|
275 |
| -MIT |
| 492 | +This project is licensed under the MIT License - see the LICENSE file for details. |
276 | 493 |
|
277 | 494 | ## CI/CD and Releases
|
278 | 495 |
|
|
0 commit comments