Skip to main content
Glama
ww11-max

CSMAR MCP Server

by ww11-max

csmar_query

Query financial databases from CSMAR covering 240+ datasets including financial statements, stock trading, and company info. Specify table, fields, conditions, and date range for targeted data retrieval.

Instructions

通用 CSMAR 数据查询

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes表名称
columnsNo要查询的字段列表
conditionNo查询条件 (SQL WHERE 子句)
start_timeNo开始时间 (YYYY-MM-DD)
end_timeNo结束时间 (YYYY-MM-DD)
limitNo返回记录数限制
formatNo返回格式

Implementation Reference

  • src/index.js:489-518 (registration)
    Registration of the 'csmar_query' tool as an MCP tool. It defines the input schema (table_name, columns, condition, start_time, end_time, limit, format) and the handler that calls the Python client's 'query' action.
    // 6. 通用查询
    server.registerTool(
        'csmar_query',
        {
            description: '通用 CSMAR 数据查询',
            inputSchema: {
                table_name: z.string().describe('表名称'),
                columns: z.array(z.string()).optional().describe('要查询的字段列表'),
                condition: z.string().optional().describe('查询条件 (SQL WHERE 子句)'),
                start_time: z.string().optional().describe('开始时间 (YYYY-MM-DD)'),
                end_time: z.string().optional().describe('结束时间 (YYYY-MM-DD)'),
                limit: z.number().optional().describe('返回记录数限制'),
                format: z.enum(['json', 'dataframe']).optional().describe('返回格式'),
            },
        },
        async ({ table_name, columns = [], condition = '', start_time, end_time, limit, format = 'json' }) => {
            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('query', { table_name, columns, condition, start_time, end_time, limit, format });
                return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
            } catch (error) {
                return { content: [{ type: 'text', text: `查询错误: ${error.message}` }], isError: true };
            }
        }
    );
  • The handler function for 'csmar_query'. It ensures login, then calls the persistent Python client's 'query' action with the provided parameters (table_name, columns, condition, start_time, end_time, limit, format) and returns the result as JSON.
        async ({ table_name, columns = [], condition = '', start_time, end_time, limit, format = 'json' }) => {
            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('query', { table_name, columns, condition, start_time, end_time, limit, format });
                return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
            } catch (error) {
                return { content: [{ type: 'text', text: `查询错误: ${error.message}` }], isError: true };
            }
        }
    );
  • Input schema for 'csmar_query' using Zod validation: table_name (string, required), columns (array of strings, optional), condition (string, optional), start_time (string, optional), end_time (string, optional), limit (number, optional), format (enum 'json' or 'dataframe', optional).
        description: '通用 CSMAR 数据查询',
        inputSchema: {
            table_name: z.string().describe('表名称'),
            columns: z.array(z.string()).optional().describe('要查询的字段列表'),
            condition: z.string().optional().describe('查询条件 (SQL WHERE 子句)'),
            start_time: z.string().optional().describe('开始时间 (YYYY-MM-DD)'),
            end_time: z.string().optional().describe('结束时间 (YYYY-MM-DD)'),
            limit: z.number().optional().describe('返回记录数限制'),
            format: z.enum(['json', 'dataframe']).optional().describe('返回格式'),
        },
    },
  • The Python-side 'query' method on CSMARClient that actually executes the CSMAR SDK query. It calls csmar.query() or csmar.query_df() based on format, applies limit, and returns the data.
    def query(self, columns: list, condition: str, table_name: str,
             start_time: Optional[str] = None, end_time: Optional[str] = None,
             format: str = "json", limit: Optional[int] = None) -> Dict[str, Any]:
        try:
            csmar = self._ensure_csmar()
            if format == "dataframe":
                data = csmar.query_df(columns, condition, table_name, start_time, end_time)
                result = data.to_dict('records') if hasattr(data, 'to_dict') else data
            else:
                data = csmar.query(columns, condition, table_name, start_time, end_time)
                result = data
    
            if result is None:
                return {"success": True, "table": table_name, "data": [], "count": 0, "message": "查询结果为空"}
    
            if limit and isinstance(result, list):
                result = result[:limit]
    
            return {"success": True, "table": table_name, "data": result,
                    "count": len(result) if isinstance(result, list) else 1}
        except Exception as e:
            return {"success": False, "error": f"查询数据失败: {str(e)}"}
  • The command dispatch in python_client.py that maps the 'query' action string to the CSMARClient.query() method, passing through all parameters from the Node.js side.
    "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")
    ),
Behavior1/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, and the description does not disclose any behavioral traits (e.g., read-only, authorization needs, rate limits). The term 'query' implies read-only, but it is not explicitly stated, leaving the agent without safety or usage context.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single short sentence, but it is under-specified and lacks structure. It fails to convey essential information, making it more of a placeholder than a concise description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness1/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of 7 parameters, multiple sibling tools, and no output schema or annotations, the description is completely inadequate. It does not explain what CSMAR is, how queries are executed, or any constraints, severely limiting an agent's ability to use the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters2/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, but the description adds no additional meaning beyond the parameter names and types. It does not explain how the parameters interact, provide examples, or clarify the purpose of SQL WHERE clauses or return formats.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose2/5

Does the description clearly state what the tool does and how it differs from similar tools?

Description is '通用 CSMAR 数据查询' which translates to 'General CSMAR data query'. It is vague and does not specify what specific data or operations are covered, nor does it differentiate from sibling tools like csmar_preview or csmar_query_count.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is provided on when to use this tool versus alternatives (e.g., csmar_preview, csmar_query_count). The description lacks any context about prerequisites or use cases.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/ww11-max/CSMAR-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server