Skip to main content
Glama

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'] } },

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