connection_status
Display connection status for databases. Show user, engine, and expiration time for each active connection.
Instructions
Show whether you're connected and, for each available database connection, which user and engine it uses and when it expires.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/mcp/tools.ts:167-205 (handler)The 'connection_status' tool handler function. Calls deps.creds.status() to get the current ConnectionStatus array, then formats a human-readable string showing each connection's name, engine, username, and expiry time (or 'expired' status). Returns the joined lines as toolText.
// ─── connection_status ─────────────────────────────────────────────── function connectionStatus(deps: Deps): ToolDef { return { name: 'connection_status', description: "Show whether you're connected and, for each available database connection, " + 'which user and engine it uses and when it expires.', inputSchema: { type: 'object', additionalProperties: { not: {} }, }, async handler() { const status = deps.creds.status(); if (!status.connected) { return toolText('Not connected. Run any database tool to authenticate.'); } if (status.connections.length === 0) { return toolText('Connected, but the OAuth backend returned no database connections.'); } const parts: string[] = []; for (const c of status.connections) { let line = `${c.name} (${c.engine}) — user ${c.username}`; if (c.expires_at) { const remaining = new Date(c.expires_at).getTime() - Date.now(); if (remaining <= 0) { line += '; expired, next query will reauthenticate'; } else { const h = Math.floor(remaining / 3600_000); const m = Math.floor((remaining % 3600_000) / 60_000); line += `; expires in ${h}h ${m}m`; } } parts.push(line); } return toolText(parts.join('\n')); }, }; } - src/mcp/tools.ts:169-178 (schema)The input schema for connection_status: an object with no properties (additionalProperties: { not: {} }) meaning it takes no arguments.
function connectionStatus(deps: Deps): ToolDef { return { name: 'connection_status', description: "Show whether you're connected and, for each available database connection, " + 'which user and engine it uses and when it expires.', inputSchema: { type: 'object', additionalProperties: { not: {} }, }, - src/mcp/tools.ts:23-31 (registration)The connectionStatus function is called in buildTools() at line 25, registering the 'connection_status' tool in the list of all five MCP tools.
export function buildTools(deps: Deps): ToolDef[] { return [ connectionStatus(deps), disconnect(deps), listConnections(deps), listSchema(deps), queryDatabase(deps), ]; } - src/creds/cache.ts:23-29 (helper)The ConnectionStatus interface used by the handler, defining fields: name, engine, username, databases, and optional expires_at.
export interface ConnectionStatus { name: string; engine: string; username: string; databases: string[]; expires_at?: string; } - src/creds/cache.ts:136-147 (helper)The CredsCache.status() method that returns the Status object (connected boolean + array of ConnectionStatus). It maps the internal token's connections to the public ConnectionStatus type.
status(): Status { if (this.token === null) return { connected: false, connections: [] }; const conns: ConnectionStatus[] = this.token.connections.map((c) => ({ name: c.name, engine: c.engine, username: c.username, databases: c.databases, expires_at: c.expiresAt.getTime() === 0 ? undefined : c.expiresAt.toISOString(), })); return { connected: true, connections: conns }; }