Skip to content

Commit fbef5ed

Browse files
committed
feat: indicate which dsn connector is active
1 parent 7c3d99c commit fbef5ed

File tree

2 files changed

+24
-3
lines changed

2 files changed

+24
-3
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dbhub",
3-
"version": "0.0.8",
3+
"version": "0.1.0",
44
"description": "Universal Database MCP Server",
55
"main": "dist/index.js",
66
"type": "module",

src/tools/list-connectors.ts

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,46 @@
11
import { ConnectorManager } from '../connectors/manager.js';
22
import { ConnectorRegistry } from '../connectors/interface.js';
33
import { createToolSuccessResponse } from '../utils/response-formatter.js';
4+
import { isDemoMode } from '../config/env.js';
45

56
/**
67
* list_connectors tool handler
78
* Lists all available database connectors and their sample DSNs
9+
* Indicates which connector is active based on current DSN
810
*/
911
export async function listConnectorsToolHandler(_args: {}, _extra: any) {
1012
const connectors = ConnectorManager.getAvailableConnectors();
1113
const samples = ConnectorRegistry.getAllSampleDSNs();
1214

15+
// Get active connector if possible
16+
let activeConnectorId: string | null = null;
17+
try {
18+
// Check if we have an active connection using static method
19+
const activeConnector = ConnectorManager.getCurrentConnector();
20+
activeConnectorId = activeConnector.id;
21+
} catch (error) {
22+
// No active connector yet or not connected
23+
}
24+
25+
// If we're in demo mode, SQLite should be active
26+
const isDemo = isDemoMode();
27+
if (isDemo && !activeConnectorId) {
28+
activeConnectorId = 'sqlite';
29+
}
30+
1331
// Convert to a more structured format
1432
const sampleObjects = Object.entries(samples).map(([id, dsn]) => ({
1533
id,
16-
dsn
34+
dsn,
35+
active: id === activeConnectorId
1736
}));
1837

1938
// Prepare response data
2039
const responseData = {
2140
connectors: sampleObjects,
22-
count: sampleObjects.length
41+
count: sampleObjects.length,
42+
activeConnector: activeConnectorId,
43+
demoMode: isDemo
2344
};
2445

2546
// Use the utility to create a standardized response

0 commit comments

Comments
 (0)