test_connection
Verify database connectivity and retrieve basic server details for MSSQL MCP Server. Input a connection string or named connection to ensure proper database access.
Instructions
Test the database connection and return basic server information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionName | No | Named connection to use (e.g., 'production', 'staging') | |
| connectionString | No | SQL Server connection string (uses default if not provided) |
Implementation Reference
- src/utils/database.ts:40-46 (helper)Helper function that tests the provided database connection pool by executing a simple 'SELECT 1' query. Throws an error if the test fails. This is likely the core logic for a 'test_connection' tool.export async function testConnection(pool: ConnectionPool): Promise<void> { try { await pool.request().query('SELECT 1'); } catch (error) { throw new Error(`Failed to connect to database: ${(error as Error).message}`); } }