Test Connection
test_connectionVerify database connectivity and retrieve basic server details for Microsoft SQL Server connections.
Instructions
Test the database connection and return basic server information
Tool call template
This tool declares no required parameters. Add optional parameters from the input schema as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {},
"name": "test_connection"
}
}Input 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}`); } }