Skip to main content
Glama
ww11-max

CSMAR MCP Server

by ww11-max

csmar_list_fields

Retrieve all field names from a specified table in CSMAR financial databases, enabling analysis of table structure.

Instructions

列出指定表中的所有字段

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes表名称

Implementation Reference

  • src/index.js:464-487 (registration)
    Registration of the 'csmar_list_fields' tool with the MCP server. Defines the tool name, description, input schema (table_name), and the async handler that calls initPythonClient() and client.call('list_fields', ...).
    // 5. 列出字段
    server.registerTool(
        'csmar_list_fields',
        {
            description: '列出指定表中的所有字段',
            inputSchema: {
                table_name: z.string().describe('表名称'),
            },
        },
        async ({ table_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_fields', { table_name });
                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_list_fields'. It ensures login, initializes the Python client, calls the 'list_fields' action with the table_name parameter, and returns the result as text content.
    async ({ table_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_fields', { table_name });
            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_list_fields' tool. Defines 'table_name' as a required string parameter using Zod validation.
    {
        description: '列出指定表中的所有字段',
        inputSchema: {
            table_name: z.string().describe('表名称'),
        },
    },
  • Python-side handler: CSMARClient.get_list_fields() method. Calls csmar.getListFields(table_name) from the CSMAR SDK, wraps the result in a dict with success status and field list.
    def get_list_fields(self, table_name: str) -> Dict[str, Any]:
        try:
            csmar = self._ensure_csmar()
            fields = csmar.getListFields(table_name)
            if fields is None:
                return {"success": False, "error": "字段列表为空", "table": table_name, "fields": [], "count": 0}
            field_list = list(fields) if hasattr(fields, '__iter__') else [str(fields)]
            return {"success": True, "table": table_name, "fields": field_list, "count": len(field_list)}
        except Exception as e:
            return {"success": False, "error": f"获取字段列表失败: {str(e)}"}
  • Command dispatcher: handle_command() routes the 'list_fields' action to client.get_list_fields(params.get('table_name', '')).
    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())}
Behavior2/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 beyond the obvious listing operation. It lacks information on authentication, side effects, or constraints.

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

Conciseness5/5

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

The description is a single sentence with no wasted words, effectively conveying the tool's purpose.

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 tool with one parameter and no output schema, the description is adequate but lacks context on output format, pagination, or error handling, which could be helpful.

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 description coverage is 100%, and the parameter 'table_name' is already described in the schema. The description adds no additional meaning beyond what the schema provides, aligning with the baseline of 3.

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

Purpose5/5

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

The description clearly states the tool lists all fields in a specified table, with a specific verb ('list') and resource ('fields'). It distinguishes from sibling tools like csmar_list_tables and csmar_list_databases.

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. The description only states what it does, without providing context for usage or exclusions.

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