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:
t8y2
2026-05-03 14:50:44 +08:00
parent 68a8b382b2
commit 53df4e56cb
3 changed files with 121 additions and 48 deletions
+20
View File
@@ -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(() => {});
}