get_database_info
Retrieve general database information such as schema details, table structures, and configuration settings from SQL Server databases.
Instructions
Gets general information from the database
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-database-info.ts:5-51 (handler)The main handler function getDatabaseInfo that executes SQL queries to retrieve database information including name, server version, edition, and product level. Returns formatted JSON or error.export async function getDatabaseInfo( db: DatabaseConnection ): Promise<CallToolResult> { try { const pool = db.getPool() const queries = [ 'SELECT DB_NAME() as DatabaseName', 'SELECT @@VERSION as ServerVersion', "SELECT SERVERPROPERTY('Edition') as Edition", "SELECT SERVERPROPERTY('ProductLevel') as ProductLevel", ] const results = await Promise.all( queries.map(async (query) => { const request = pool.request() return await request.query(query) }) ) const info = { database: results[0].recordset[0]?.DatabaseName, version: results[1].recordset[0]?.ServerVersion, edition: results[2].recordset[0]?.Edition, productLevel: results[3].recordset[0]?.ProductLevel, } return { content: [ { type: 'text', text: JSON.stringify(info, null, 2), }, ], } } catch (error) { return { content: [ { type: 'text', text: `Erro: ${error instanceof Error ? error.message : 'Erro desconhecido'}`, }, ], isError: true, } } }
- src/schemas.ts:28-28 (schema)Zod schema definition for get_database_info input, which requires no parameters.export const getDatabaseInfoInput = z.object({}).strict()
- src/schemas.ts:79-79 (schema)TypeScript type inferred from the getDatabaseInfoInput schema.export type GetDatabaseInfoInput = z.infer<typeof getDatabaseInfoInput>
- src/services/SqlServerMCPService.ts:69-71 (registration)Registration of the get_database_info handler in the SqlServerMCPService's handler map, which delegates to the getDatabaseInfo function.handlers.set('get_database_info', async (database) => getDatabaseInfo(database) )
- src/tools/index.ts:43-46 (registration)Tool registration in toolsList() function, defining name, description, and input schema for the MCP tool list.name: 'get_database_info', description: 'Gets general information from the database', inputSchema: zodToJsonSchema(getDatabaseInfoInput), },
- src/tools/index.ts:17-17 (registration)Re-export of the getDatabaseInfo handler from tools/index.ts for use in services.export { getDatabaseInfo } from './get-database-info'