Skip to main content
Glama
ww11-max

CSMAR MCP Server

by ww11-max

csmar_query_count

Count records in a CSMAR database table that satisfy specified conditions including columns, time range, and custom query criteria.

Instructions

查询满足条件的记录数量

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes表名称
columnsNo字段列表
conditionNo查询条件
start_timeNo开始时间
end_timeNo结束时间

Implementation Reference

  • Input schema definition for csmar_query_count tool, describing the required table_name and optional columns, condition, start_time, end_time parameters.
    description: '查询满足条件的记录数量',
    inputSchema: {
        table_name: z.string().describe('表名称'),
        columns: z.array(z.string()).optional().describe('字段列表'),
        condition: z.string().optional().describe('查询条件'),
        start_time: z.string().optional().describe('开始时间'),
        end_time: z.string().optional().describe('结束时间'),
    },
  • src/index.js:546-572 (registration)
    Registration of the 'csmar_query_count' tool with the MCP server, including description, input schema, and handler.
    server.registerTool(
        'csmar_query_count',
        {
            description: '查询满足条件的记录数量',
            inputSchema: {
                table_name: z.string().describe('表名称'),
                columns: z.array(z.string()).optional().describe('字段列表'),
                condition: z.string().optional().describe('查询条件'),
                start_time: z.string().optional().describe('开始时间'),
                end_time: z.string().optional().describe('结束时间'),
            },
        },
        async ({ table_name, columns = [], condition = '', start_time, end_time }) => {
            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_count', { table_name, columns, condition, start_time, end_time });
                return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
            } catch (error) {
                return { content: [{ type: 'text', text: `查询数量错误: ${error.message}` }], isError: true };
            }
        }
    );
  • Handler function for csmar_query_count that ensures login, initializes the Python client, and calls 'query_count' action on the Python client.
    async ({ table_name, columns = [], condition = '', start_time, end_time }) => {
        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_count', { table_name, columns, condition, start_time, end_time });
            return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
        } catch (error) {
            return { content: [{ type: 'text', text: `查询数量错误: ${error.message}` }], isError: true };
        }
    }
  • Python helper method 'query_count' on CSMARClient that calls the CSMAR SDK's queryCount method and returns the result.
    def query_count(self, columns: list, condition: str, table_name: str,
                   start_time: Optional[str] = None, end_time: Optional[str] = None) -> Dict[str, Any]:
        try:
            csmar = self._ensure_csmar()
            count = csmar.queryCount(columns, condition, table_name, start_time, end_time)
            return {"success": True, "table": table_name, "count": int(count) if count else 0}
        except Exception as e:
            return {"success": False, "error": f"查询数量失败: {str(e)}"}
    
    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
  • Command dispatch registration mapping the 'query_count' action string to the Python client's query_count method.
    "query_count": lambda: client.query_count(
        params.get("columns", []), params.get("condition", ""), params.get("table_name", ""),
        params.get("start_time"), params.get("end_time")
    ),
Behavior2/5

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

No annotations provided; the description does not disclose behavioral traits such as whether it is read-only, any limitations, or performance implications. The agent is left with no information beyond the basic function.

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

Conciseness4/5

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

A single sentence that is clear and front-loaded. No extraneous information, though additional details could be added without harming conciseness.

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

Completeness3/5

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

For a simple count query, the description combined with the schema is minimally adequate. However, missing usage guidelines and behavioral context make it incomplete for an AI agent to use correctly without extra knowledge.

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

Parameters3/5

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

Schema coverage is 100% with Chinese descriptions for all parameters. The description adds no extra meaning beyond the schema, so baseline 3 is appropriate.

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

Purpose4/5

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

The description clearly states it queries the count of records, distinguishing it from sibling csmar_query which likely returns actual records. However, it does not explicitly differentiate between the two.

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 on when to use this tool versus alternatives like csmar_query or csmar_preview. The description implies counting, but does not advise on context.

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