Skip to main content
Glama
onigeya
by onigeya

help

Retrieve detailed assistance for specific commands within the SiYuan Note MCP Server, enabling efficient management of notebook operations and document interactions.

Instructions

获取命令的帮助信息

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
typeYes命令类型

Implementation Reference

  • The core handler logic for the 'help' tool. Takes a command 'type', fetches help from registry, formats detailed text response including params, returns, examples.
    async ({ type }) => {
        try {
            const result = registry.getCommandHelp(type);
            if (result.isError) {
                return {
                    content: [
                        {
                            type: 'text' as const,
                            text: result.content[0].text
                        }
                    ],
                    isError: true
                };
            }
    
            const doc = result._meta;
            if (!doc) {
                return {
                    content: [
                        {
                            type: 'text' as const,
                            text: `命令 ${type} 没有帮助信息`
                        }
                    ],
                    isError: true
                };
            }
    
            // 构建帮助文本
            const helpText = [
                `命令: ${type}`,
                `描述: ${doc.description}`,
                '',
                '参数:',
                ...Object.entries(doc.params).map(([key, value]) => 
                    `  ${key}: ${value.type}${value.required ? ' (必需)' : ' (可选)'}\n    ${value.description}`
                ),
                '',
                '返回值:',
                `  类型: ${doc.returns.type}`,
                `  描述: ${doc.returns.description}`,
                '  属性:',
                ...Object.entries(doc.returns.properties).map(([key, desc]) => 
                    `    ${key}: ${String(desc)}`
                ),
                '',
                '示例:',
                ...doc.examples.map(example => [
                    `  ${example.description}:`,
                    '    参数:',
                    `      ${JSON.stringify(example.params, null, 2).replace(/\n/g, '\n      ')}`,
                    '    响应:',
                    `      ${JSON.stringify(example.response, null, 2).replace(/\n/g, '\n      ')}`
                ]).flat(),
                '',
                doc.apiLink ? `API文档: ${doc.apiLink}` : ''
            ].filter(Boolean).join('\n');
    
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: helpText
                    }
                ],
                _meta: {
                    documentation: doc
                },
                isError: false
            };
        } catch (error) {
            return {
                content: [
                    {
                        type: 'text' as const,
                        text: error instanceof Error ? error.message : '获取帮助失败'
                    }
                ],
                isError: true
            };
        }
    }
  • Input schema: 'type' as string (command type).
    {
        type: z.string().describe('命令类型')
    },
  • src/server.ts:54-54 (registration)
    Registers the 'help' tool by calling registerHelpTool on the MCP server instance.
    registerHelpTool(server);
  • src/tools/help.ts:6-96 (registration)
    Function that registers the 'help' tool on the server with name, description, schema, and handler.
    export function registerHelpTool(server: McpServer) {
        server.tool(
            'help',
            '获取命令的帮助信息',
            {
                type: z.string().describe('命令类型')
            },
            async ({ type }) => {
                try {
                    const result = registry.getCommandHelp(type);
                    if (result.isError) {
                        return {
                            content: [
                                {
                                    type: 'text' as const,
                                    text: result.content[0].text
                                }
                            ],
                            isError: true
                        };
                    }
    
                    const doc = result._meta;
                    if (!doc) {
                        return {
                            content: [
                                {
                                    type: 'text' as const,
                                    text: `命令 ${type} 没有帮助信息`
                                }
                            ],
                            isError: true
                        };
                    }
    
                    // 构建帮助文本
                    const helpText = [
                        `命令: ${type}`,
                        `描述: ${doc.description}`,
                        '',
                        '参数:',
                        ...Object.entries(doc.params).map(([key, value]) => 
                            `  ${key}: ${value.type}${value.required ? ' (必需)' : ' (可选)'}\n    ${value.description}`
                        ),
                        '',
                        '返回值:',
                        `  类型: ${doc.returns.type}`,
                        `  描述: ${doc.returns.description}`,
                        '  属性:',
                        ...Object.entries(doc.returns.properties).map(([key, desc]) => 
                            `    ${key}: ${String(desc)}`
                        ),
                        '',
                        '示例:',
                        ...doc.examples.map(example => [
                            `  ${example.description}:`,
                            '    参数:',
                            `      ${JSON.stringify(example.params, null, 2).replace(/\n/g, '\n      ')}`,
                            '    响应:',
                            `      ${JSON.stringify(example.response, null, 2).replace(/\n/g, '\n      ')}`
                        ]).flat(),
                        '',
                        doc.apiLink ? `API文档: ${doc.apiLink}` : ''
                    ].filter(Boolean).join('\n');
    
                    return {
                        content: [
                            {
                                type: 'text' as const,
                                text: helpText
                            }
                        ],
                        _meta: {
                            documentation: doc
                        },
                        isError: false
                    };
                } catch (error) {
                    return {
                        content: [
                            {
                                type: 'text' as const,
                                text: error instanceof Error ? error.message : '获取帮助失败'
                            }
                        ],
                        isError: true
                    };
                }
            }
        );
    } 
  • Registry method that retrieves and formats detailed documentation for a specific command, used by the 'help' tool.
    public getCommandHelp(commandName: string): McpResponse<CommandHandler['documentation']> {
        // 尝试直接查找完整命令名
        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
            };
        }
    
        // 获取参数说明
        const params: Record<string, {
            type: string;
            description: string;
            required: boolean;
        }> = {};
    
        try {
            if (command.params instanceof z.ZodObject) {
                const shape = command.params._def.shape();
                Object.entries(shape).forEach(([key, value]) => {
                    if (value instanceof z.ZodType) {
                        const isOptional = value instanceof z.ZodOptional;
                        params[key] = {
                            type: value._def.typeName || 'unknown',
                            description: value.description || '无说明',
                            required: !isOptional
                        };
                    }
                });
            }
        } catch {
            // 如果无法获取 shape,返回空对象
        }
    
        const help = command.documentation || {
            description: command.description,
            params,
            returns: {
                type: 'object',
                description: '命令执行结果',
                properties: {}
            },
            examples: []
        };
    
        // 格式化帮助信息
        const fullName = this.getFullCommandName(command.namespace, command.name);
        const paramsList = Object.entries(params).map(([name, info]) => 
            `  ${name}: ${info.type}${info.required ? ' (必填)' : ' (可选)'}\n    ${info.description}`
        ).join('\n');
    
        const returnInfo = help.returns;
        const propertiesList = Object.entries(returnInfo.properties).map(([name, desc]) => 
            `  ${name}: ${desc}`
        ).join('\n');
    
        const examplesList = help.examples.map(example => 
            `示例:${example.description}\n` +
            `  参数:${JSON.stringify(example.params, null, 2)}\n` +
            `  响应:${JSON.stringify(example.response, null, 2)}`
        ).join('\n\n');
    
        const helpText = [
            `命令: ${fullName}`,
            `描述: ${help.description}`,
            '',
            '参数:',
            paramsList || '  无参数',
            '',
            '返回值:',
            `  类型: ${returnInfo.type}`,
            `  描述: ${returnInfo.description}`,
            '  属性:',
            propertiesList || '    无属性',
            '',
            examplesList ? '示例:\n' + examplesList : '示例: 无示例',
            '',
            help.apiLink ? `API文档: ${help.apiLink}` : ''
        ].filter(Boolean).join('\n');
    
        return {
            content: [
                {
                    type: 'text',
                    text: helpText
                }
            ],
            _meta: help
        };
    }
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. The description only states what the tool does ('get help information') without adding context on behavioral traits such as whether it's read-only, if it requires specific permissions, what the output format might be, or any rate limits. It's minimal and doesn't compensate for the lack of annotations.

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?

The description is a single sentence ('获取命令的帮助信息'), which is appropriately sized and front-loaded. It's concise with no wasted words, though it could be more informative. The structure is clear but minimal, earning a high score for efficiency.

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

Completeness2/5

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

Given the complexity (a help tool with one parameter) and lack of annotations or output schema, the description is incomplete. It doesn't explain what 'help information' includes, how it relates to sibling tools, or what the tool returns. For a tool with no structured output and minimal behavioral context, it should provide more guidance to be fully 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?

The input schema has 100% description coverage, with the parameter 'type' described as '命令类型' (command type). The description adds no meaning beyond this, as it doesn't explain what 'type' entails or provide examples. With high schema coverage, the baseline is 3, and the description doesn't enhance or detract from the schema's information.

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

Purpose3/5

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

The description '获取命令的帮助信息' translates to 'Get help information for commands,' which states a purpose but is vague. It specifies a verb ('获取' - get) and resource ('帮助信息' - help information), but doesn't clarify what 'commands' refer to or how this differs from siblings like 'executeCommand' or 'queryCommands.' It's not tautological, but lacks specificity for sibling differentiation.

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?

The description provides no guidance on when to use this tool versus alternatives. There are sibling tools like 'executeCommand' and 'queryCommands,' but the description doesn't mention them or suggest contexts for usage (e.g., when you need help vs. executing a command). It's a basic statement of function with no exclusions or alternatives implied.

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