mcp-trino-python 0.5.0__tar.gz → 0.6.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-trino-python
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: A Model Context Protocol (MCP) connector for Trino, enabling seamless integration between MCP-compliant services and Trino query engine
5
5
  License: Apache-2.0
6
6
  Keywords: trino,connector,mcp
@@ -13,6 +13,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
13
  Requires-Python: >=3.12
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
+ Requires-Dist: fastapi>=0.115.12
16
17
  Requires-Dist: loguru>=0.7.3
17
18
  Requires-Dist: mcp[cli]>=1.6.0
18
19
  Requires-Dist: python-dotenv>=1.1.0
@@ -1,12 +1,13 @@
1
1
  [project]
2
2
  name = "mcp-trino-python"
3
- version = "0.5.0"
3
+ version = "0.6.0"
4
4
  description = "A Model Context Protocol (MCP) connector for Trino, enabling seamless integration between MCP-compliant services and Trino query engine"
5
5
  readme = "README.md"
6
6
  license = { text = "Apache-2.0" }
7
7
  requires-python = ">=3.12"
8
8
  keywords = ["trino", "connector", "mcp"]
9
9
  dependencies = [
10
+ "fastapi>=0.115.12",
10
11
  "loguru>=0.7.3",
11
12
  "mcp[cli]>=1.6.0",
12
13
  "python-dotenv>=1.1.0",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-trino-python
3
- Version: 0.5.0
3
+ Version: 0.6.0
4
4
  Summary: A Model Context Protocol (MCP) connector for Trino, enabling seamless integration between MCP-compliant services and Trino query engine
5
5
  License: Apache-2.0
6
6
  Keywords: trino,connector,mcp
@@ -13,6 +13,7 @@ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
13
  Requires-Python: >=3.12
14
14
  Description-Content-Type: text/markdown
15
15
  License-File: LICENSE
16
+ Requires-Dist: fastapi>=0.115.12
16
17
  Requires-Dist: loguru>=0.7.3
17
18
  Requires-Dist: mcp[cli]>=1.6.0
18
19
  Requires-Dist: python-dotenv>=1.1.0
@@ -1,3 +1,4 @@
1
+ fastapi>=0.115.12
1
2
  loguru>=0.7.3
2
3
  mcp[cli]>=1.6.0
3
4
  python-dotenv>=1.1.0
@@ -4,9 +4,15 @@ This module provides a Model Context Protocol (MCP) server that exposes Trino
4
4
  functionality through resources and tools, with special support for Iceberg tables.
5
5
  """
6
6
 
7
+ import uvicorn
8
+ from mcp.server import Server
7
9
  from mcp.server.fastmcp import FastMCP
8
10
  from mcp.server.fastmcp.prompts import base
11
+ from mcp.server.sse import SseServerTransport
9
12
  from pydantic import Field
13
+ from starlette.applications import Starlette
14
+ from starlette.requests import Request
15
+ from starlette.routing import Mount, Route
10
16
 
11
17
  from config import load_config
12
18
  from trino_client import TrinoClient
@@ -533,8 +539,47 @@ def maintain_iceberg(table: str, catalog: str, schema_name: str) -> list[base.Me
533
539
  ]
534
540
 
535
541
 
542
+ def create_starlette_app(mcp_server: Server, *, debug: bool = False) -> Starlette:
543
+ """Create a Starlette application that can server the provied mcp server with SSE."""
544
+ sse = SseServerTransport("/messages/")
545
+
546
+ async def handle_sse(request: Request) -> None:
547
+ async with sse.connect_sse(
548
+ request.scope,
549
+ request.receive,
550
+ request._send, # noqa: SLF001
551
+ ) as (read_stream, write_stream):
552
+ await mcp_server.run(
553
+ read_stream,
554
+ write_stream,
555
+ mcp_server.create_initialization_options(),
556
+ )
557
+
558
+ return Starlette(
559
+ debug=debug,
560
+ routes=[
561
+ Route("/sse", endpoint=handle_sse),
562
+ Mount("/messages/", app=sse.handle_post_message),
563
+ ],
564
+ )
565
+
566
+
536
567
  if __name__ == "__main__":
568
+ import argparse
569
+
537
570
  from loguru import logger
538
571
 
539
572
  logger.info("Starting Trino MCP server...")
540
- mcp.run(transport="stdio")
573
+ # mcp.run()
574
+ mcp_server = mcp._mcp_server # noqa: SLF001
575
+
576
+ parser = argparse.ArgumentParser(description="Run MCP SSE-based server")
577
+ parser.add_argument("--host", default="0.0.0.0", help="Host to bind to")
578
+ parser.add_argument("--port", type=int, default=8000, help="Port to listen on")
579
+ args = parser.parse_args()
580
+
581
+ # Bind SSE request handling to MCP server
582
+ starlette_app = create_starlette_app(mcp_server, debug=True)
583
+ # Run the server with Uvicorn
584
+ uvicorn.run(starlette_app, host=args.host, port=args.port)
585
+ logger.info("Trino MCP server is running.")