feat: add MCP bridge for AI agent integration

Localhost HTTP listener (dynamic port) allows MCP Server and other AI agents
to open tables directly in DBX UI via Tauri events.
This commit is contained in:
t8y2
2026-05-03 14:35:48 +08:00
parent da70b8f2c1
commit aa59c26fa2
5 changed files with 137 additions and 0 deletions
+17
View File
@@ -833,6 +833,23 @@ onMounted(() => {
setupFileDrop().catch(() => {});
checkUpdates({ silent: true });
getVersion().then((v) => { appVersion.value = v; }).catch(() => {});
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;
const config = connectionStore.getConfig(connection_id);
if (!config) return;
connectionStore.activeConnectionId = connection_id;
await connectionStore.ensureConnected(connection_id);
if (config.db_type === "redis") {
queryStore.createTab(connection_id, database || "0", `db${database || "0"}`, "redis");
} else if (config.db_type === "mongodb") {
queryStore.createTab(connection_id, database, table, "mongo");
} else {
openLineageTarget({ connectionId: connection_id, database, schema, tableName: table });
}
});
}).catch(() => {});
}
});