Skip to main content
Glama
KunihiroS

claude-code-mcp

explain_code

Understand code functionality quickly by providing a detailed explanation of the target code, with optional context for clarity.

Instructions

Provides detailed explanation of the given code.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesTarget code
contextNoAdditional context

Implementation Reference

  • Handler for executing the 'explain_code' tool: destructures args, truncates and base64-encodes code if needed, builds prompt, calls Claude CLI via runClaudeCommand, returns text response.
    case 'explain_code': {
      const { code, context } = args;
      try {
        logger.debug(`Processing explain_code request, code length: ${code.length}`);
        const encodedCode = encodeText(truncateIfNeeded(code));
        logger.debug(`Code encoded to base64, length: ${encodedCode.length}`);
        // ファイルを使用して大きな入力を渡す場合の代替方法
        const prompt = `You are super professional engineer. Please kindly provide a detailed explanation of the following Base64 encoded code:\n\n${encodedCode}\n\nAdditional context (if provided):\n${context || 'No additional context provided.'}`;
        logger.debug('Calling Claude CLI with prompt');
        const output = await runClaudeCommand(['--print'], prompt);
        logger.debug(`Received response from Claude, length: ${output.length}`);
        return { content: [{ type: 'text', text: output }] };
      } catch (err) {
        logger.error("Error in explain_code:", err);
        logger.debug(`explain_code error details: ${err instanceof Error ? err.stack : String(err)}`);
        throw err;
      }
    }
  • Input schema definition for the 'explain_code' tool, specifying required 'code' string and optional 'context'.
    inputSchema: {
      type: 'object',
      properties: {
        code: { type: 'string', description: 'Target code' },
        context: { type: 'string', description: 'Additional context', default: '' }
      },
      required: ['code']
    }
  • Registration of the 'explain_code' tool in the ListTools response, including name, description, and schema.
    {
      name: 'explain_code',
      description: 'Provides detailed explanation of the given code.',
      inputSchema: {
        type: 'object',
        properties: {
          code: { type: 'string', description: 'Target code' },
          context: { type: 'string', description: 'Additional context', default: '' }
        },
        required: ['code']
      }
    },
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. It mentions 'detailed explanation' but doesn't disclose behavioral traits like response format, depth of analysis, potential rate limits, or error conditions. This is inadequate for a tool with no annotation coverage.

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, efficient sentence with no wasted words. It's appropriately sized for a simple tool, though it could be more front-loaded with key details. Every sentence earns its place, but it's slightly under-specified.

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 no annotations and no output schema, the description is incomplete. It doesn't explain what the explanation includes (e.g., syntax, logic, dependencies) or the return format. For a code explanation tool with rich potential outputs, this lacks necessary context.

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%, so the schema already documents both parameters ('code' and 'context'). The description adds no meaning beyond what the schema provides, such as examples or usage tips. Baseline 3 is appropriate when schema does the heavy lifting.

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 states the tool 'provides detailed explanation of the given code,' which clearly indicates its function. However, it doesn't differentiate from siblings like 'review_code' or 'fix_code' that might also involve code analysis. The purpose is clear but lacks sibling distinction.

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 is provided on when to use this tool versus alternatives such as 'review_code' or 'fix_code.' The description implies usage for code explanation but offers no context on prerequisites, exclusions, or comparisons to sibling tools.

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

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