test_connection
Validate Valkey/Redis connection credentials before adding them to BetterDB MCP. Test connectivity without persisting data to ensure proper configuration.
Instructions
Test a Valkey/Redis connection without persisting it. Use before add_connection to validate credentials.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Display name for the connection | |
| host | Yes | Hostname or IP address | |
| port | No | Port number | |
| username | No | ACL username (default: "default") | |
| password | No | Auth password |
Implementation Reference
- packages/mcp/src/index.ts:231-267 (handler)The implementation of the 'test_connection' MCP tool, which calls the backend '/connections/test' endpoint to validate connection parameters.
server.tool( 'test_connection', 'Test a Valkey/Redis connection without persisting it. Use before add_connection to validate credentials.', { name: z.string().describe('Display name for the connection'), host: z.string().describe('Hostname or IP address'), port: z.number().int().min(1).max(65535).default(6379).describe('Port number'), username: z.string().optional().describe('ACL username (default: "default")'), password: z.string().optional().describe('Auth password'), }, async (params) => { try { const data = await apiRequest('POST', '/connections/test', params) as { success: boolean; capabilities?: unknown; error?: string; }; if (isLicenseError(data)) { return { content: [{ type: 'text' as const, text: licenseErrorResult(data) }] }; } if (!data.success) { return { content: [{ type: 'text' as const, text: data.error ?? 'Connection test failed' }], isError: true, }; } return { content: [{ type: 'text' as const, text: data.capabilities ? JSON.stringify(data.capabilities, null, 2) : 'Connection successful' }], }; } catch (err) { return { content: [{ type: 'text' as const, text: err instanceof Error ? err.message : String(err) }], isError: true, }; } }, );