Skip to main content
Glama
renjismzy

Smart Code Reviewer

by renjismzy

generate_documentation

Generate detailed documentation and comments for code to improve readability and maintainability. Supports multiple programming languages and documentation formats.

Instructions

为代码生成详细的文档和注释

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes要生成文档的代码
languageYes编程语言
docTypeYes文档类型

Implementation Reference

  • MCP tool handler for 'generate_documentation': validates arguments using Zod, calls generateDocumentation helper, and formats response as MCP content.
    private async handleGenerateDocumentation(args: any) {
      const schema = z.object({
        code: z.string(),
        language: z.string(),
        docType: z.enum(['inline', 'markdown', 'jsdoc']).default('markdown')
      });
    
      const { code, language, docType } = schema.parse(args);
      const result = await generateDocumentation(code, language, docType);
    
      return {
        content: [
          {
            type: 'text',
            text: result
          }
        ]
      };
    }
  • Input schema for the generate_documentation tool, defining parameters: code (string), language (string), docType (enum: inline/markdown/jsdoc).
    inputSchema: {
      type: 'object',
      properties: {
        code: {
          type: 'string',
          description: '要生成文档的代码'
        },
        language: {
          type: 'string',
          description: '编程语言'
        },
        docType: {
          type: 'string',
          enum: ['inline', 'markdown', 'jsdoc'],
          description: '文档类型'
        }
      },
      required: ['code', 'language', 'docType']
    }
  • src/index.ts:66-88 (registration)
    Tool registration in ListTools response: defines name, description, and references inputSchema for generate_documentation.
    {
      name: 'generate_documentation',
      description: '为代码生成详细的文档和注释',
      inputSchema: {
        type: 'object',
        properties: {
          code: {
            type: 'string',
            description: '要生成文档的代码'
          },
          language: {
            type: 'string',
            description: '编程语言'
          },
          docType: {
            type: 'string',
            enum: ['inline', 'markdown', 'jsdoc'],
            description: '文档类型'
          }
        },
        required: ['code', 'language', 'docType']
      }
    },
  • Core helper function implementing documentation generation: dispatches to inline comments, JSDoc, or Markdown based on docType.
    export async function generateDocumentation(
      code: string,
      language: string,
      docType: 'inline' | 'markdown' | 'jsdoc' = 'markdown'
    ): Promise<string> {
      switch (docType) {
        case 'inline':
          return generateInlineComments(code, language);
        case 'jsdoc':
          return generateJSDoc(code, language);
        case 'markdown':
        default:
          return generateMarkdownDoc(code, language);
      }
    }
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. It states the action ('生成' - generate) but doesn't disclose any behavioral traits like whether this is a read-only operation, if it requires specific permissions, what the output format might be, or any rate limits. For a tool with no annotation coverage, this is a significant gap in transparency.

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 and front-loaded: '为代码生成详细的文档和注释' (generate detailed documentation and comments for code). It's a single, clear sentence with no wasted words, making it easy to understand at a glance. Every word earns its place by directly stating the tool's purpose.

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 of a documentation generation tool with 3 required parameters and no output schema, the description is incomplete. It doesn't explain what the tool returns (e.g., formatted documentation text), any behavioral aspects like error handling, or how it interacts with sibling tools. With no annotations and no output schema, the description should provide more context 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 description adds no meaning beyond what the input schema provides. The schema has 100% description coverage, with clear parameter descriptions (e.g., '要生成文档的代码' - code to generate documentation for, '编程语言' - programming language, '文档类型' - documentation type with enum values). Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate with additional semantic context.

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 the tool's purpose: '为代码生成详细的文档和注释' (generate detailed documentation and comments for code). It specifies the verb '生成' (generate) and the resource '文档和注释' (documentation and comments). However, it doesn't explicitly differentiate from sibling tools like 'analyze_code_quality' or 'suggest_refactoring', which might also involve code analysis but for different purposes.

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. It doesn't mention any context, prerequisites, or exclusions, such as when to choose 'generate_documentation' over 'suggest_refactoring' for code improvement tasks. Without such guidance, users might struggle to select the appropriate tool among siblings.

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/renjismzy/mcp-code'

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