csmar_list_tables
Retrieve all table names within any CSMAR financial database by specifying the database name. Quickly understand database structure for financial research.
Instructions
列出指定数据库中的所有表
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"database_name": "<database_name>"
},
"name": "csmar_list_tables"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| database_name | Yes | 数据库名称 |
Implementation Reference
- src/index.js:448-462 (handler)The MCP tool handler for 'csmar_list_tables'. It ensures login, then calls the Python client via client.call('list_tables', { database_name }) and returns the result as JSON text.
async ({ database_name }) => { 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_tables', { database_name }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `获取表列表错误: ${error.message}` }], isError: true }; } } ); - src/index.js:442-447 (schema)Input schema definition for the csmar_list_tables tool: requires a 'database_name' string parameter.
{ description: '列出指定数据库中的所有表', inputSchema: { database_name: z.string().describe('数据库名称'), }, }, - src/index.js:440-462 (registration)Registration of the tool 'csmar_list_tables' via server.registerTool with its description, inputSchema, and handler.
server.registerTool( 'csmar_list_tables', { description: '列出指定数据库中的所有表', inputSchema: { database_name: z.string().describe('数据库名称'), }, }, async ({ database_name }) => { 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_tables', { database_name }); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] }; } catch (error) { return { content: [{ type: 'text', text: `获取表列表错误: ${error.message}` }], isError: true }; } } ); - src/python_client.py:244-253 (handler)The Python-side handler (get_list_tables) that calls the CSMAR SDK's getListTables() for the given database_name and returns the table list.
def get_list_tables(self, database_name: str) -> Dict[str, Any]: try: csmar = self._ensure_csmar() tables = csmar.getListTables(database_name) if tables is None: return {"success": False, "error": f"表列表为空 (数据库: {database_name})", "tables": [], "count": 0} table_list = list(tables) if hasattr(tables, '__iter__') else [str(tables)] return {"success": True, "database": database_name, "tables": table_list, "count": len(table_list)} except Exception as e: return {"success": False, "error": f"获取表列表失败: {str(e)}"} - src/python_client.py:309-318 (helper)Command dispatcher that routes the 'list_tables' action to CSMARClient.get_list_tables() with the database_name parameter.
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", "")),