Skip to main content
Glama
onigeya
by onigeya

executeCommand

Execute specific commands on the SiYuan Note MCP Server to manage notebooks, manipulate documents, and control content within the note system, enabling efficient data operations.

Instructions

执行指定的命令

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNo命令参数
typeYes命令类型

Implementation Reference

  • The handler function for the 'executeCommand' MCP tool. It delegates execution to the registry's executeCommand method and formats the response as MCP format.
    async ({ type, params = {} }) => {
        try {
            const result = await registry.executeCommand(type, params);
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: result.content[0].text
                    }
                ],
                _meta: {
                    result: result._meta || {}
                },
                isError: result.isError
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: error instanceof Error ? error.message : '命令执行失败'
                    }
                ],
                isError: true
            };
        }
  • Zod input schema for the executeCommand tool: 'type' (required string, command type), 'params' (optional record of any).
    {
        type: z.string().describe('命令类型'),
        params: z.record(z.any()).optional().describe('命令参数')
    },
  • Registration of the 'executeCommand' tool on the MCP server using server.tool(), including name, description, schema, and handler.
    server.tool(
        'executeCommand',
        '执行指定的命令',
        {
            type: z.string().describe('命令类型'),
            params: z.record(z.any()).optional().describe('命令参数')
        },
        async ({ type, params = {} }) => {
            try {
                const result = await registry.executeCommand(type, params);
                return {
                    content: [
                        {
                            type: 'text' as const,
                            text: result.content[0].text
                        }
                    ],
                    _meta: {
                        result: result._meta || {}
                    },
                    isError: result.isError
                };
            } catch (error) {
                return {
                    content: [
                        {
                            type: 'text' as const,
                            text: error instanceof Error ? error.message : '命令执行失败'
                        }
                    ],
                    isError: true
                };
            }
        }
    );
  • Core dispatch logic in CommandRegistry.executeCommand: resolves command name, parses/validates params, invokes handler, handles errors - called by the tool handler.
    public async executeCommand(commandName: string, params: unknown = {}): Promise<McpResponse> {
        // 尝试直接查找完整命令名
        let command = this.commands.get(commandName);
        
        if (!command) {
            // 如果找不到,尝试解析命名空间
            const [namespace, name] = this.parseFullCommandName(commandName);
            const fullName = this.getFullCommandName(namespace, name);
            command = this.commands.get(fullName);
        }
    
        if (!command) {
            return {
                content: [
                    {
                        type: 'text',
                        text: `命令 ${commandName} 不存在`
                    }
                ],
                isError: true
            };
        }
    
        try {
            const validatedParams = command.params.parse(params);
            return await command.handler(validatedParams);
        } catch (error) {
            if (error instanceof z.ZodError) {
                const issues = error.issues.map(issue => 
                    `  - ${issue.path.join('.')}: ${issue.message}`
                ).join('\n');
                
                return {
                    content: [
                        {
                            type: 'text',
                            text: `参数验证失败:\n${issues}`
                        }
                    ],
                    isError: true
                };
            }
    
            return {
                content: [
                    {
                        type: 'text',
                        text: `命令执行失败:${error instanceof Error ? error.message : String(error)}`
                    }
                ],
                isError: true
            };
        }
    }
  • src/server.ts:52-52 (registration)
    Invocation of registerCommandTool which registers the executeCommand tool on the server instance.
    registerCommandTool(server);
Behavior1/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. '执行指定的命令' (Execute the specified command) implies a potentially destructive or mutating operation, but provides zero information about permissions required, side effects, safety considerations, rate limits, or what happens upon execution. This leaves the agent completely in the dark about critical behavioral traits.

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 extremely concise - a single phrase in Chinese. While this represents severe under-specification rather than ideal conciseness, according to the scoring framework, conciseness is evaluated separately from completeness. The description contains zero wasted words and is front-loaded with its limited information.

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 a command execution tool with no annotations, no output schema, and a description that provides almost no useful information, this description is completely inadequate. The agent cannot understand what commands are available, what they do, what permissions are required, what happens upon execution, or how to interpret results. This represents a critical failure in contextual completeness for a potentially powerful/destructive tool.

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?

The schema description coverage is 100%, with both parameters ('type' and 'params') having descriptions in the schema. The tool description adds no additional meaning about parameters beyond what the schema already provides. According to scoring rules, when schema coverage is high (>80%), the baseline is 3 even with no parameter information in the description.

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?

The description '执行指定的命令' (Execute the specified command) is a tautology that essentially restates the tool name 'executeCommand' in Chinese. It provides no specific information about what kind of commands are executed, what resources are affected, or how this differs from sibling tools like 'queryCommands'. The purpose remains vague and indistinguishable from alternatives.

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

Usage Guidelines1/5

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

The description provides absolutely no guidance on when to use this tool versus alternatives like 'queryCommands' or 'help'. There is no mention of appropriate contexts, prerequisites, or exclusions. The agent receives no help in determining when this tool is the correct choice among available options.

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

Related 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/onigeya/siyuan-mcp-server'

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