sqlnow-mcp 0.1.0__tar.gz → 0.2.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.
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/PKG-INFO +1 -1
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/pyproject.toml +1 -1
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/server.py +54 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/ui/table.html +89 -88
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/LICENSE +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/README.md +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/__init__.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/cli.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/config.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/db.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/metadata.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/resource_limits.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/table_result.py +0 -0
- {sqlnow_mcp-0.1.0 → sqlnow_mcp-0.2.0}/sqlnow_mcp/ui.py +0 -0
|
@@ -109,6 +109,22 @@ def _table_tool_result(payload: dict[str, Any]) -> ToolResult:
|
|
|
109
109
|
)
|
|
110
110
|
|
|
111
111
|
|
|
112
|
+
def _query_editor_result(sql: str = "") -> ToolResult:
|
|
113
|
+
"""Open the table viewer in empty-editor mode (no rows, just the SQL editor)."""
|
|
114
|
+
payload: dict[str, Any] = {
|
|
115
|
+
"editor": True,
|
|
116
|
+
"sql": sql,
|
|
117
|
+
"columns": [],
|
|
118
|
+
"types": [],
|
|
119
|
+
"rows": [],
|
|
120
|
+
"complete": True,
|
|
121
|
+
}
|
|
122
|
+
return ToolResult(
|
|
123
|
+
content=[TextContent(type="text", text="Opened the SQL editor.")],
|
|
124
|
+
structured_content=payload,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
|
|
112
128
|
def build_local_server(session: DuckDBSession) -> FastMCP:
|
|
113
129
|
mcp = FastMCP("sqlnow-mcp", instructions=SERVER_INSTRUCTIONS)
|
|
114
130
|
register_table_ui(mcp)
|
|
@@ -314,6 +330,25 @@ def build_local_server(session: DuckDBSession) -> FastMCP:
|
|
|
314
330
|
page = _call(session, session.run_select_query, sql, limit=limit)
|
|
315
331
|
return _table_tool_result(page)
|
|
316
332
|
|
|
333
|
+
@mcp.tool(
|
|
334
|
+
app=TABLE_APP,
|
|
335
|
+
annotations=ToolAnnotations(
|
|
336
|
+
title="Open SQL query editor",
|
|
337
|
+
readOnlyHint=True,
|
|
338
|
+
destructiveHint=False,
|
|
339
|
+
),
|
|
340
|
+
)
|
|
341
|
+
def open_query_editor(sql: str = "") -> ToolResult:
|
|
342
|
+
"""Open the interactive SQL editor so the user can write a query against
|
|
343
|
+
sqlnow.
|
|
344
|
+
|
|
345
|
+
Use when the user wants to compose or edit SQL themselves (e.g. "let me
|
|
346
|
+
write a query against sqlnow") rather than asking for a specific result.
|
|
347
|
+
Opens an empty editor with autocomplete; optionally seed it with a
|
|
348
|
+
starting ``sql``. Nothing runs until the user presses Run.
|
|
349
|
+
"""
|
|
350
|
+
return _query_editor_result(sql)
|
|
351
|
+
|
|
317
352
|
@mcp.tool(app=FETCH_PAGE_APP)
|
|
318
353
|
def fetch_table_page(
|
|
319
354
|
query_id: str,
|
|
@@ -406,6 +441,25 @@ def build_publish_server(
|
|
|
406
441
|
page = _call(session, session.run_select_query, sql, limit=limit)
|
|
407
442
|
return _table_tool_result(page)
|
|
408
443
|
|
|
444
|
+
@mcp.tool(
|
|
445
|
+
app=TABLE_APP,
|
|
446
|
+
annotations=ToolAnnotations(
|
|
447
|
+
title="Open SQL query editor",
|
|
448
|
+
readOnlyHint=True,
|
|
449
|
+
destructiveHint=False,
|
|
450
|
+
),
|
|
451
|
+
)
|
|
452
|
+
def open_query_editor(sql: str = "") -> ToolResult:
|
|
453
|
+
"""Open the interactive SQL editor so the user can write a query against
|
|
454
|
+
sqlnow.
|
|
455
|
+
|
|
456
|
+
Use when the user wants to compose or edit SQL themselves (e.g. "let me
|
|
457
|
+
write a query against sqlnow") rather than asking for a specific result.
|
|
458
|
+
Opens an empty editor with autocomplete; optionally seed it with a
|
|
459
|
+
starting ``sql``. Nothing runs until the user presses Run.
|
|
460
|
+
"""
|
|
461
|
+
return _query_editor_result(sql)
|
|
462
|
+
|
|
409
463
|
@mcp.tool(app=FETCH_PAGE_APP)
|
|
410
464
|
def fetch_table_page(
|
|
411
465
|
query_id: str,
|