New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

code-explainer-mcp

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-explainer-mcp

MCP server that renders AI-generated code explanations as beautiful HTML pages

latest
npmnpm
Version
1.0.0
Version published
Weekly downloads
5
-61.54%
Maintainers
1
Weekly downloads
 
Created
Source

Code Explainer MCP

Give your AI agent a way to show its work.

An MCP tool that lets AI visualize the code changes it made — rendering git diffs as interactive HTML pages with inline annotations.

License

What is this?

When an AI agent makes code changes, it usually just tells you what it did in text. This MCP gives the agent a better way to communicate: a visual diff with annotations.

AI makes changes to your code
       ↓
AI calls show_diff_explanation
       ↓
Browser opens with diff + AI's annotations inline

The AI can highlight the important lines and explain what each change does — right next to the code.

Features

  • Visual diff - Side-by-side or unified view powered by diff2html
  • Inline annotations - AI explanations appear directly after relevant code lines
  • Action buttons - Follow-up prompts (e.g., "Add tests", "Refactor this")
  • Click to open - File names link to VS Code or Cursor
  • GitHub dark theme - Clean aesthetics

Installation

git clone <repo>
cd code-explainer-mcp
npm install
npm run build

Configuration

Claude Code

claude mcp add code-explainer node /path/to/code-explainer-mcp/dist/index.js

Or add to ~/.claude/mcp_settings.json:

{
  "mcpServers": {
    "code-explainer": {
      "command": "node",
      "args": ["/path/to/code-explainer-mcp/dist/index.js"]
    }
  }
}

Cursor

Add to Cursor MCP settings:

{
  "mcpServers": {
    "code-explainer": {
      "command": "node",
      "args": ["/path/to/code-explainer-mcp/dist/index.js"]
    }
  }
}

Tool: show_diff_explanation

Renders a git diff with annotations in the browser.

Parameters

ParameterTypeRequiredDescription
titlestringYesPage title
diffstringYesRaw git diff output (unified format)
summarystringNoHigh-level overview
annotationsarrayNoExplanations for specific changes
globalActionsarrayNoAction buttons in the header
editorstringNo"vscode", "cursor", or "auto"

Annotation Object

FieldTypeRequiredDescription
filestringYesFile path
linenumberNoLine number to attach annotation to
explanationstringYesYour explanation
actionsarrayNoArray of { label, prompt } for action buttons

Action Object

FieldTypeRequiredDescription
labelstringYesButton label
promptstringYesPrompt to pre-fill in Cursor chat

MCP Prompt

explain-changes

Instructions for explaining git diffs with visual output. The AI will get the diff, analyze the changes, and call the tool with appropriate annotations.

Example Usage

Ask your AI agent: "Explain the last commit"

The agent will:

  • Run git diff HEAD~1 HEAD
  • Analyze the changes
  • Call show_diff_explanation:
{
  "title": "Add JWT Authentication",
  "summary": "Added JWT auth middleware and applied to API routes.",
  "diff": "diff --git a/src/auth.ts b/src/auth.ts\n...",
  "annotations": [
    {
      "file": "src/auth.ts",
      "line": 5,
      "explanation": "Extracts Bearer token from Authorization header",
      "actions": [
        { "label": "Add tests", "prompt": "Write unit tests for this auth middleware" }
      ]
    }
  ],
  "globalActions": [
    { "label": "Security Review", "prompt": "Review this code for security vulnerabilities" }
  ],
  "editor": "cursor"
}
  • Browser opens with diff2html rendered diff + inline annotations

Development

npm run dev

Opens http://localhost:3456 with hot reload. Edit src/html-generator.ts to change styling, dev/server.mjs to change mock data.

License

MIT

Keywords

mcp

FAQs

Package last updated on 02 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts