mcp-trino-python 0.3.0__tar.gz → 0.4.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.3.0
3
+ Version: 0.4.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
@@ -125,18 +125,18 @@ The server provides the following MCP resources:
125
125
 
126
126
  ### Catalog and Schema Navigation
127
127
 
128
- - **catalog://main** (`show_catalogs`)
128
+ - **catalog://main** (`list_catalogs`)
129
129
 
130
130
  - Lists all available Trino catalogs
131
131
  - No parameters required
132
132
 
133
- - **schema://{catalog}** (`show_schemas`)
133
+ - **schema://{catalog}** (`list_schemas`)
134
134
 
135
135
  - Lists all schemas in the specified catalog
136
136
  - Parameters:
137
137
  - `catalog`: Catalog name (string, required)
138
138
 
139
- - **table://{catalog}/{schema}** (`show_tables`)
139
+ - **table://{catalog}/{schema}** (`list_tables`)
140
140
  - Lists all tables in the specified schema
141
141
  - Parameters:
142
142
  - `catalog`: Catalog name (string, required)
@@ -146,6 +146,32 @@ The server provides the following MCP resources:
146
146
 
147
147
  ### Query and Exploration Tools
148
148
 
149
+ - **show_catalogs**
150
+
151
+ - List all available catalogs
152
+ - No parameters required
153
+
154
+ - **show_schemas**
155
+
156
+ - List all schemas in a catalog
157
+ - Parameters:
158
+ - `catalog`: Catalog name (string, required)
159
+
160
+ - **show_tables**
161
+
162
+ - List all tables in a schema
163
+ - Parameters:
164
+ - `catalog`: Catalog name (string, required)
165
+ - `schema`: Schema name (string, required)
166
+
167
+ - **describe_table**
168
+
169
+ - Show detailed table structure and column information
170
+ - Parameters:
171
+ - `table`: Table name (string, required)
172
+ - `catalog`: Catalog name (string, optional)
173
+ - `schema`: Schema name (string, optional)
174
+
149
175
  - **execute_query**
150
176
 
151
177
  - Execute a SQL query and return formatted results
@@ -104,18 +104,18 @@ The server provides the following MCP resources:
104
104
 
105
105
  ### Catalog and Schema Navigation
106
106
 
107
- - **catalog://main** (`show_catalogs`)
107
+ - **catalog://main** (`list_catalogs`)
108
108
 
109
109
  - Lists all available Trino catalogs
110
110
  - No parameters required
111
111
 
112
- - **schema://{catalog}** (`show_schemas`)
112
+ - **schema://{catalog}** (`list_schemas`)
113
113
 
114
114
  - Lists all schemas in the specified catalog
115
115
  - Parameters:
116
116
  - `catalog`: Catalog name (string, required)
117
117
 
118
- - **table://{catalog}/{schema}** (`show_tables`)
118
+ - **table://{catalog}/{schema}** (`list_tables`)
119
119
  - Lists all tables in the specified schema
120
120
  - Parameters:
121
121
  - `catalog`: Catalog name (string, required)
@@ -125,6 +125,32 @@ The server provides the following MCP resources:
125
125
 
126
126
  ### Query and Exploration Tools
127
127
 
128
+ - **show_catalogs**
129
+
130
+ - List all available catalogs
131
+ - No parameters required
132
+
133
+ - **show_schemas**
134
+
135
+ - List all schemas in a catalog
136
+ - Parameters:
137
+ - `catalog`: Catalog name (string, required)
138
+
139
+ - **show_tables**
140
+
141
+ - List all tables in a schema
142
+ - Parameters:
143
+ - `catalog`: Catalog name (string, required)
144
+ - `schema`: Schema name (string, required)
145
+
146
+ - **describe_table**
147
+
148
+ - Show detailed table structure and column information
149
+ - Parameters:
150
+ - `table`: Table name (string, required)
151
+ - `catalog`: Catalog name (string, optional)
152
+ - `schema`: Schema name (string, optional)
153
+
128
154
  - **execute_query**
129
155
 
130
156
  - Execute a SQL query and return formatted results
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "mcp-trino-python"
3
- version = "0.3.0"
3
+ version = "0.4.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" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: mcp-trino-python
3
- Version: 0.3.0
3
+ Version: 0.4.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
@@ -125,18 +125,18 @@ The server provides the following MCP resources:
125
125
 
126
126
  ### Catalog and Schema Navigation
127
127
 
128
- - **catalog://main** (`show_catalogs`)
128
+ - **catalog://main** (`list_catalogs`)
129
129
 
130
130
  - Lists all available Trino catalogs
131
131
  - No parameters required
132
132
 
133
- - **schema://{catalog}** (`show_schemas`)
133
+ - **schema://{catalog}** (`list_schemas`)
134
134
 
135
135
  - Lists all schemas in the specified catalog
136
136
  - Parameters:
137
137
  - `catalog`: Catalog name (string, required)
138
138
 
139
- - **table://{catalog}/{schema}** (`show_tables`)
139
+ - **table://{catalog}/{schema}** (`list_tables`)
140
140
  - Lists all tables in the specified schema
141
141
  - Parameters:
142
142
  - `catalog`: Catalog name (string, required)
@@ -146,6 +146,32 @@ The server provides the following MCP resources:
146
146
 
147
147
  ### Query and Exploration Tools
148
148
 
149
+ - **show_catalogs**
150
+
151
+ - List all available catalogs
152
+ - No parameters required
153
+
154
+ - **show_schemas**
155
+
156
+ - List all schemas in a catalog
157
+ - Parameters:
158
+ - `catalog`: Catalog name (string, required)
159
+
160
+ - **show_tables**
161
+
162
+ - List all tables in a schema
163
+ - Parameters:
164
+ - `catalog`: Catalog name (string, required)
165
+ - `schema`: Schema name (string, required)
166
+
167
+ - **describe_table**
168
+
169
+ - Show detailed table structure and column information
170
+ - Parameters:
171
+ - `table`: Table name (string, required)
172
+ - `catalog`: Catalog name (string, optional)
173
+ - `schema`: Schema name (string, optional)
174
+
149
175
  - **execute_query**
150
176
 
151
177
  - Execute a SQL query and return formatted results
@@ -19,35 +19,83 @@ mcp = FastMCP("Trino Explorer", dependencies=["trino", "python-dotenv", "loguru"
19
19
  # Resources
20
20
  @mcp.resource(
21
21
  "catalog://main",
22
- name="show_catalogs",
22
+ name="list_catalogs",
23
23
  description="List all available Trino catalogs",
24
24
  )
25
- def show_catalogs() -> str:
25
+ def list_catalogs() -> str:
26
26
  """List all available Trino catalogs."""
27
- return client.show_catalogs()
27
+ return client.list_catalogs()
28
28
 
29
29
 
30
30
  @mcp.resource(
31
31
  "schema://{catalog}",
32
- name="show_schemas",
32
+ name="list_schemas",
33
33
  description="List all schemas in the specified catalog",
34
34
  )
35
- def show_schemas(catalog: str) -> str:
35
+ def list_schemas(catalog: str) -> str:
36
36
  """List all schemas in a catalog."""
37
- return client.show_schemas(catalog)
37
+ return client.list_schemas(catalog)
38
38
 
39
39
 
40
40
  @mcp.resource(
41
41
  "table://{catalog}/{schema}",
42
- name="show_tables",
42
+ name="list_tables",
43
43
  description="List all tables in the specified schema",
44
44
  )
45
- def show_tables(catalog: str, schema: str) -> str:
45
+ def list_tables(catalog: str, schema: str) -> str:
46
46
  """List all tables in a schema."""
47
- return client.show_tables(catalog, schema)
47
+ return client.list_tables(catalog, schema)
48
48
 
49
49
 
50
50
  # Tools
51
+ @mcp.tool(description="List all available catalogs")
52
+ def show_catalogs() -> str:
53
+ """List all available catalogs."""
54
+ return client.list_catalogs()
55
+
56
+
57
+ @mcp.tool(description="List all schemas in a catalog")
58
+ def show_schemas(catalog: str) -> str:
59
+ """List all schemas in a catalog.
60
+
61
+ Args:
62
+ catalog: The name of the catalog
63
+
64
+ Returns:
65
+ str: List of schemas in the specified catalog
66
+ """
67
+ return client.list_schemas(catalog)
68
+
69
+
70
+ @mcp.tool(description="List all tables in a schema")
71
+ def show_tables(catalog: str, schema: str) -> str:
72
+ """List all tables in a schema.
73
+
74
+ Args:
75
+ catalog: The name of the catalog
76
+ schema: The name of the schema
77
+
78
+ Returns:
79
+ str: List of tables in the specified schema
80
+ """
81
+ return client.list_tables(catalog, schema)
82
+
83
+
84
+ @mcp.tool(description="Describe a table")
85
+ def describe_table(table: str, catalog: str | None = None, schema: str | None = None) -> str:
86
+ """Describe a table.
87
+
88
+ Args:
89
+ table: The name of the table
90
+ catalog: Optional catalog name (defaults to configured catalog)
91
+ schema: Optional schema name (defaults to configured schema)
92
+
93
+ Returns:
94
+ str: Table description in JSON format
95
+ """
96
+ return client.describe_table(table, catalog, schema)
97
+
98
+
51
99
  @mcp.tool(description="Show the CREATE TABLE statement for a specific table")
52
100
  def show_create_table(table: str, catalog: str | None = None, schema: str | None = None) -> str:
53
101
  """Show the CREATE TABLE statement for a table.
@@ -96,7 +96,7 @@ class TrinoClient:
96
96
  query += f" LIMIT {limit}"
97
97
  return self.execute_query(query)
98
98
 
99
- def show_catalogs(self) -> str:
99
+ def list_catalogs(self) -> str:
100
100
  """List all available catalogs.
101
101
 
102
102
  Returns:
@@ -105,7 +105,7 @@ class TrinoClient:
105
105
  catalogs = [row["Catalog"] for row in json.loads(self.execute_query("SHOW CATALOGS"))]
106
106
  return "\n".join(catalogs)
107
107
 
108
- def show_schemas(self, catalog: str | None = None) -> str:
108
+ def list_schemas(self, catalog: str | None = None) -> str:
109
109
  """List all schemas in a catalog.
110
110
 
111
111
  Args:
@@ -125,7 +125,7 @@ class TrinoClient:
125
125
  schemas = [row["Schema"] for row in json.loads(self.execute_query(query))]
126
126
  return "\n".join(schemas)
127
127
 
128
- def show_tables(self, catalog: str | None = None, schema: str | None = None) -> str:
128
+ def list_tables(self, catalog: str | None = None, schema: str | None = None) -> str:
129
129
  """List all tables in a schema.
130
130
 
131
131
  Args:
@@ -147,6 +147,27 @@ class TrinoClient:
147
147
  tables = [row["Table"] for row in json.loads(self.execute_query(query))]
148
148
  return "\n".join(tables)
149
149
 
150
+ def describe_table(self, table: str, catalog: str | None = None, schema: str | None = None) -> str:
151
+ """Describe the structure of a table.
152
+
153
+ Args:
154
+ table (str): The name of the table.
155
+ catalog (Optional[str]): The catalog name. If None, uses configured default.
156
+ schema (Optional[str]): The schema name. If None, uses configured default.
157
+
158
+ Returns:
159
+ str: JSON-formatted string containing table description.
160
+
161
+ Raises:
162
+ CatalogSchemaError: If either catalog or schema is not specified and not configured.
163
+ """
164
+ catalog = catalog or self.config.catalog
165
+ schema = schema or self.config.schema
166
+ if not catalog or not schema:
167
+ raise CatalogSchemaError()
168
+ query = f"DESCRIBE {catalog}.{schema}.{table}"
169
+ return self.execute_query(query)
170
+
150
171
  def show_create_table(self, table: str, catalog: str | None = None, schema: str | None = None) -> str:
151
172
  """Show the CREATE TABLE statement for a table.
152
173