test_connection
Verify database connectivity and retrieve basic server details for Microsoft SQL Server connections.
Instructions
Test the database connection and return basic server information
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| connectionString | No | SQL Server connection string (uses default if not provided) | |
| connectionName | No | Named connection to use (e.g., 'production', 'staging') |
Implementation Reference
- src/utils/database.ts:40-46 (handler)The `testConnection` function serves as the core handler for testing a database connection. It executes a simple 'SELECT 1' query using the provided ConnectionPool. If the query fails, it throws a descriptive error. This matches the expected logic for a 'test_connection' tool implementation.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}`); } }