code-shot
Renders source code as beautiful SVG or PNG images with syntax highlighting, line numbers, and diff support. Ideal for AI agents to present code visually to humans or for sharing snippets.
README
@thesimonharms/code-shot
MCP server that renders source code as beautiful images. Perfect for AI agents to show code visually to humans on mobile devices, or for sharing syntax-highlighted snippets.
Tools
render_code
Render source code as SVG or PNG with full syntax highlighting.
| Param | Type | Default | Description |
|---|---|---|---|
code |
string | required | Source code to render |
language |
string | auto-detect | Language (ts, rust, py, go, js, and 40+ more) |
theme |
string | github-dark |
Color theme (nord, dracula, catppuccin, one-dark-pro, etc.) |
title |
string | — | Window title bar text (e.g. filename) |
show_line_numbers |
boolean | true |
Line number gutter |
font_size |
number | 14 |
Font size in px |
output_format |
svg|png |
svg |
SVG is crisp & copyable; PNG is raster |
width |
number | auto | Code area width in characters |
padding |
number | 16 |
Padding in px |
render_diff
Render a git unified diff with color-coded additions/deletions and language-aware syntax highlighting.
| Param | Type | Default | Description |
|---|---|---|---|
diff |
string | required | Unified diff content (git diff output) |
highlight_language |
string | auto-detect | Language for highlighting within hunks. Auto-detected from diff --git header (e.g. file.ts → TypeScript). Set to "diff" for plain diff highlighting. |
| ... | — | — | Same options as render_code |
Diff lines are highlighted with:
@@hunk headers → blue background+additions → green background (#1b4520dark /#dafbe1light)-deletions → red background (#4f1818dark /#ffebe9light)
Syntax highlighting is applied per-hunk in the detected language — not just plain diff markup.
Themes
18 bundled themes:
| Dark | Light |
|---|---|
| github-dark | github-light |
| nord | one-light |
| one-dark-pro | material-theme-lighter |
| dracula | min-light |
| dracula-soft | solarized-light |
| catppuccin-mocha | catppuccin-latte |
| material-theme | vitesse-light |
| min-dark | — |
| solarized-dark | — |
| vitesse-dark | — |
Test Suite
46 tests across two runners:
npm test # Build → MCP integration tests (cobasaja) → Unit tests (node --test)
- 5 MCP integration tests (
tests/code-shot.test.ts) — tool discovery, rendering, error cases - 37 unit tests (
tests/*.node-test.ts) — renderSvg structure, diffToLines parsing, guessLanguage heuristics
Usage with Hermes
Add to ~/.hermes/config.yaml:
mcp_servers:
code-shot:
command: "npx"
args: ["-y", "@thesimonharms/code-shot"]
Or from local build:
mcp_servers:
code-shot:
command: "node"
args: ["/path/to/code-shot/dist/index.js"]
Configuration
Set defaults via ~/.code-shotrc (JSON):
{
"theme": "nord",
"show_line_numbers": true,
"font_size": 14,
"padding": 16
}
Also checked (in order): ~/.code-shotrc > ~/.code-shotrc.json > ~/.config/code-shot/config.json.
Tool call arguments override config file values.
Usage with Claude Code / Cursor
{
"mcpServers": {
"code-shot": {
"command": "node",
"args": ["/path/to/code-shot/dist/index.js"]
}
}
}
Development
npm install
npm run build # tsc
npm test # build + cobasaja + node --test
How it works
- Shiki tokenizes the code with full syntax highlighting (grammars for 40+ languages)
- SVG renderer builds a pixel-perfect SVG with monospace positioning, window chrome, line numbers, and diff markers
- Optional PNG via
@resvg/resvg-jsfor platforms that don't support SVG natively - Language auto-detection via shebang parsing and code heuristics (18 language patterns)
- Diff language detection from
diff --git a/file.ext b/file.extheaders
No browser, no DOM, no headless Chromium — pure math-based SVG generation.
License
MIT
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.