Skip to main content
Glama
vini-cius

SQL Server MCP Service

by vini-cius

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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, } } }
  • Zod schema definition for get_database_info input, which requires no parameters.
    export const getDatabaseInfoInput = z.object({}).strict()
  • TypeScript type inferred from the getDatabaseInfoInput schema.
    export type GetDatabaseInfoInput = z.infer<typeof getDatabaseInfoInput>
  • 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) )
  • 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), },
  • Re-export of the getDatabaseInfo handler from tools/index.ts for use in services.
    export { getDatabaseInfo } from './get-database-info'

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/vini-cius/mcp-sqlserver'

If you have feedback or need assistance with the MCP directory API, please join our Discord server