csmar_list_databases
Retrieve a list of CSMAR financial databases available to your account. Identify accessible datasets for financial research, including statements, trading data, and company information.
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_list_databases"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.js:417-437 (handler)The MCP tool registration for 'csmar_list_databases', which ensures login, calls the Python client's 'list_databases' action, and returns the result as formatted JSON.
server.registerTool( 'csmar_list_databases', { description: '列出用户有权访问的 CSMAR 数据库', inputSchema: {}, }, async () => { try { const loginResult = await ensureLogin(); if (!loginResult.success) { return { content: [{ type: 'text', text: JSON.stringify(loginResult, null, 2) }], isError: true }; } const client = await initPythonClient(); const result = await client.call('list_databases'); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `获取数据库列表错误: ${error.message}` }], isError: true }; } } ); - src/index.js:417-437 (registration)The 'csmar_list_databases' tool is registered via server.registerTool with an empty inputSchema and a handler that delegates to the Python backend.
server.registerTool( 'csmar_list_databases', { description: '列出用户有权访问的 CSMAR 数据库', inputSchema: {}, }, async () => { try { const loginResult = await ensureLogin(); if (!loginResult.success) { return { content: [{ type: 'text', text: JSON.stringify(loginResult, null, 2) }], isError: true }; } const client = await initPythonClient(); const result = await client.call('list_databases'); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `获取数据库列表错误: ${error.message}` }], isError: true }; } } ); - src/index.js:419-421 (schema)Input schema for the tool: an empty object (no parameters required), with a description '列出用户有权访问的 CSMAR 数据库'.
{ description: '列出用户有权访问的 CSMAR 数据库', inputSchema: {}, - src/python_client.py:232-242 (handler)The Python backend handler (get_list_dbs) that calls csmar.getListDbs() and returns the database list.
def get_list_dbs(self) -> Dict[str, Any]: try: csmar = self._ensure_csmar() databases = csmar.getListDbs() if databases is None: return {"success": False, "error": "数据库列表为空 (可能是权限不足或网络问题)", "databases": [], "count": 0} db_list = list(databases) if hasattr(databases, '__iter__') else [str(databases)] return {"success": True, "databases": db_list, "count": len(db_list)} except Exception as e: return {"success": False, "error": f"获取数据库列表失败: {str(e)}"} - src/python_client.py:309-343 (helper)The command dispatcher that maps the 'list_databases' action string to client.get_list_dbs() when received from the Node.js process.
def handle_command(command: Dict[str, Any], client: CSMARClient) -> Dict[str, Any]: action = command.get("action") params = command.get("params", {}) handlers = { "login": lambda: client.login( params.get("account", ""), params.get("pwd", ""), params.get("lang", "0") ), "list_databases": lambda: client.get_list_dbs(), "list_tables": lambda: client.get_list_tables(params.get("database_name", "")), "list_fields": lambda: client.get_list_fields(params.get("table_name", "")), "query_count": lambda: client.query_count( params.get("columns", []), params.get("condition", ""), params.get("table_name", ""), params.get("start_time"), params.get("end_time") ), "query": lambda: client.query( params.get("columns", []), params.get("condition", ""), params.get("table_name", ""), params.get("start_time"), params.get("end_time"), params.get("format", "json"), params.get("limit") ), "preview": lambda: client.preview(params.get("table_name", "")), "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 }, "reset": lambda: client.reset() or {"success": True, "message": "已重置"} } handler = handlers.get(action) if handler: return handler() return {"success": False, "error": f"未知动作: {action}", "supported_actions": list(handlers.keys())}