csmar_health_check
Verifies the health and connectivity of CSMAR services before executing database queries, ensuring reliable access to financial data.
Instructions
检查 CSMAR 服务健康状态
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": "csmar_health_check"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:360-392 (registration)Registers the 'csmar_health_check' MCP tool with no input schema. The handler calls checkAvailability() and checkLoginStatus() and returns a JSON result with python_client, csmar_sdk, logged_in, username, api_base, and version fields.
// 1. 健康检查工具 server.registerTool( 'csmar_health_check', { description: '检查 CSMAR 服务健康状态', inputSchema: {}, }, async () => { try { const availability = await checkAvailability(); const loginStatus = await checkLoginStatus(); return { content: [{ type: 'text', text: JSON.stringify({ python_client: availability.csmar_available ? '可用' : '不可用', csmar_sdk: availability.csmar_available ? '已安装' : '未安装', logged_in: loginStatus.logged_in, username: loginStatus.username, api_base: CONFIG.apiBase, version: CONFIG.version }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `健康检查失败: ${error.message}` }], isError: true }; } } ); - src/index.js:367-392 (handler)The anonymous async handler function that executes the health check logic. It calls checkAvailability() and checkLoginStatus() helper functions and formats the health status response.
async () => { try { const availability = await checkAvailability(); const loginStatus = await checkLoginStatus(); return { content: [{ type: 'text', text: JSON.stringify({ python_client: availability.csmar_available ? '可用' : '不可用', csmar_sdk: availability.csmar_available ? '已安装' : '未安装', logged_in: loginStatus.logged_in, username: loginStatus.username, api_base: CONFIG.apiBase, version: CONFIG.version }, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `健康检查失败: ${error.message}` }], isError: true }; } } ); - src/index.js:309-316 (helper)Helper function that initializes the Python client and sends a 'check_availability' command to the Python process to check if CSMAR SDK is available.
async function checkAvailability() { try { const client = await initPythonClient(); return await client.call('check_availability'); } catch (error) { return { success: false, csmar_available: false, error: error.message }; } } - src/index.js:319-328 (helper)Helper function that wraps checkAvailability() to extract login status fields (logged_in, username) from the availability check result.
async function checkLoginStatus() { const result = await checkAvailability(); return { success: result.success, csmar_available: result.csmar_available, logged_in: result.client_logged_in, username: result.username, message: result.message || '检查登录状态成功' }; } - src/python_client.py:329-335 (helper)The Python-side handler for the 'check_availability' action. Returns the SDK availability flag, client login status, username, and any SDK import error.
"check_availability": lambda: { "success": True, "csmar_available": CSMAR_AVAILABLE, "client_logged_in": client.logged_in, "username": client.username, "sdk_error": _sdk_error if not CSMAR_AVAILABLE else None },