list_schemas
Retrieve all user-defined schemas from the configured Microsoft SQL Server database to explore its structure.
Instructions
List user-defined schemas in the configured database.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/db.ts:88-97 (handler)The actual implementation of list_schemas: queries sys.schemas, filtering out system schemas (prefix 'db_', 'sys', 'INFORMATION_SCHEMA', 'guest'), returning schema names ordered alphabetically.
async listSchemas() { const r = await (await this.getPool()).request().query(` SELECT name AS schema_name FROM sys.schemas WHERE name NOT LIKE 'db[_]%' AND name NOT IN ('sys', 'INFORMATION_SCHEMA', 'guest') ORDER BY name `); return r.recordset; } - src/index.ts:61-66 (registration)Registration of the 'list_schemas' tool on the MCP server with name, description, empty schema (no params), and handler that calls db.listSchemas() via runTool helper.
server.tool( 'list_schemas', 'List user-defined schemas in the configured database.', {}, async () => runTool(() => db.listSchemas()) ); - src/index.ts:47-59 (helper)The runTool helper wraps handler execution, converting the result to a text content response, and catching/formatting errors.
async function runTool(fn: () => Promise<unknown>): Promise<ToolResult> { try { const value = await fn(); const text = typeof value === 'string' ? value : JSON.stringify(value, null, 2); return { content: [{ type: 'text', text }] }; } catch (err) { return { content: [{ type: 'text', text: formatDbError(err) }], isError: true, }; } }