mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-30 00:19:35 +00:00
feat: MCP bridge enhancements — window focus, execute-query, markdown output
- Auto-focus DBX window when MCP opens a table or executes a query - Ensure connections are loaded before handling MCP events - Add /execute-query bridge route and dbx_execute_and_show tool - Format all tool responses as markdown tables (less tokens, more readable) - Extract shared bridgeRequest helper to reduce duplication
This commit is contained in:
+20
@@ -836,6 +836,10 @@ onMounted(() => {
|
||||
import("@tauri-apps/api/event").then(({ listen }) => {
|
||||
listen<{ connection_id: string; database: string; schema?: string; table: string }>("mcp-open-table", async (event) => {
|
||||
const { connection_id, database, schema, table } = event.payload;
|
||||
|
||||
if (!connectionStore.connections.length) {
|
||||
await connectionStore.initFromDisk();
|
||||
}
|
||||
const config = connectionStore.getConfig(connection_id);
|
||||
if (!config) return;
|
||||
connectionStore.activeConnectionId = connection_id;
|
||||
@@ -848,6 +852,22 @@ onMounted(() => {
|
||||
} else {
|
||||
openLineageTarget({ connectionId: connection_id, database, schema, tableName: table });
|
||||
}
|
||||
|
||||
getCurrentWindow().setFocus().catch(() => {});
|
||||
});
|
||||
listen<{ connection_id: string; database: string; sql: string }>("mcp-execute-query", async (event) => {
|
||||
const { connection_id, database, sql } = event.payload;
|
||||
if (!connectionStore.connections.length) {
|
||||
await connectionStore.initFromDisk();
|
||||
}
|
||||
const config = connectionStore.getConfig(connection_id);
|
||||
if (!config) return;
|
||||
connectionStore.activeConnectionId = connection_id;
|
||||
await connectionStore.ensureConnected(connection_id);
|
||||
const tabId = queryStore.createTab(connection_id, database, undefined, "query");
|
||||
queryStore.updateSql(tabId, sql);
|
||||
await queryStore.executeTabSql(tabId, sql);
|
||||
getCurrentWindow().setFocus().catch(() => {});
|
||||
});
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user