xkcdai
An MCP server that finds relevant xkcd comics during conversation by semantically matching the context to comic titles, alt text, and transcripts.
README
xkcdai
An MCP server that surfaces the right xkcd comic during a conversation, if one is relevant.
Live connector:
https://xkcdai.onrender.com/mcp— add it in claude.ai → Settings → Connectors. See Use the deployed MCP server.
It builds a semantic index over every xkcd comic (title + mouseover text +
transcript) using on-device embeddings, then exposes a single find_xkcd tool.
A Claude conversation can call it whenever the topic feels xkcd-shaped; a
relevance threshold means weak matches return nothing, so it stays quiet instead
of forcing a tenuous reference.
The fetched transcripts, explanations, and the embeddings are currently committed in this repo, under data/.
How it works
xkcd JSON API ─┐
├─► comics.json + explain.json ─► embeddings.npy ─► find_xkcd ─► Claude
explainxkcd ──┘ (cache) (bge-small) (cosine) (mentions it
(transcripts + if it fits)
explanations)
- Data: title + mouseover alt from the official API, plus the community transcript and explanation from explainxkcd.com. The explainxkcd context is essential: the official API dropped transcripts around comic ~1675, so without it the most-shared modern comics (e.g. #2347 Dependency) are unmatchable — their joke text lives only inside the image.
- Embeddings:
fastembed(ONNX) withBAAI/bge-small-en-v1.5— local, free, offline after first download, no PyTorch. Swap the model insrc/xkcdai/embed.py(e.g.BAAI/bge-base-en-v1.5for marginally better ranking at ~3× the size). - Search: a normalized numpy matrix + dot product. No vector DB needed for a few thousand comics.
- Restraint: because xkcd has a comic for almost everything, a similarity
cutoff alone can't judge relevance.
min_score(default0.62) is just a coarse floor; the real "should I bring this up?" decision is made by the calling model, guided by the score bands documented on thefind_xkcdtool.
Use the deployed MCP server (as custom connector)
The server is deployed at https://xkcdai.onrender.com on Render. Add it as a Claude custom connector to use it in the Claude web and mobile apps (note: the Free plan only allows one custom connector). Anyone can add the same URL in their own account.
In claude.ai (web — do this once; it then syncs to the mobile app):
- Settings → Connectors → Add custom connector.
- Paste the connector URL, including the
/mcppath:https://xkcdai.onrender.com/mcp - Leave OAuth blank (this server needs no auth) and click Add.
- The connector's
find_xkcdtool is now available in chats, on desktop and phone. For Claude to suggest comics on its own, also add the instruction from Make Claude suggest comics proactively to your Profile preferences.
Notes
- The server is public and unauthenticated — fine here (read-only comic search, no secrets). Don't reuse this pattern for anything sensitive without OAuth.
- A free Render instance sleeps when idle, so the first request after a nap is slow (cold start + model load), then snappy.
- Hosted from this repo via the Dockerfile and render.yaml;
pushes to
mainauto-redeploy.
Local setup
python -m venv .venv
# Windows (PowerShell): .venv\Scripts\Activate.ps1
# macOS/Linux: source .venv/bin/activate
pip install -e .
# 1. Fetch every comic's metadata.
xkcdai build
# 2. Fetch transcripts + explanations from explainxkcd (~2 min).
xkcdai enrich
# 3. Build the embedding index (downloads the model once; ~5-8 min to embed).
xkcdai build
Re-running later only fetches what's new.
Test it from the command line:
xkcdai search "my code finally compiled after an hour"
xkcdai search "arguing about the correct date format"
xkcdai search "spent more time automating it than doing it by hand"
Use locally as an MCP server
The server runs over stdio. Point your MCP host at it.
Claude Desktop (claude_desktop_config.json):
{
"mcpServers": {
"xkcdai": {
"command": "C:\\your\\path\\to\\xkcdai\\.venv\\Scripts\\xkcdai-server.exe",
"env": { "XKCDAI_DATA_DIR": "C:\\your\\path\\to\\xkcdai\\data" }
}
}
}
Claude Code (-s user makes it available in every project, not just this folder):
claude mcp add xkcdai -s user -e XKCDAI_DATA_DIR=C:\your\path\to\xkcdai\data -- C:\your\path\to\xkcdai\.venv\Scripts\xkcdai-server.exe
Always set XKCDAI_DATA_DIR, since the host launches the server from an arbitrary
working directory.
MCP only gives Claude the ability to call
find_xkcd— it won't volunteer comics on its own. See Make Claude suggest comics proactively.
Make Claude suggest comics proactively
Connecting the server only gives Claude the ability to call find_xkcd; it
won't reach for it unprompted. To make Claude volunteer comics, paste the
instruction below wherever that Claude reads persistent instructions:
- Claude Code — your global
~/.claude/CLAUDE.md(applies everywhere) or a per-repoCLAUDE.md; restart the session to load changes. - Claude.ai / Claude Desktop — Settings → Profile → "What personal preferences should Claude consider in responses?" (every plan, including free; syncs to the mobile app). Each person who uses the connector adds it in their own account.
When a conversation naturally lands on a topic xkcd is known for — programming,
science, math, statistics, engineering, the absurdity of standards, relationships,
everyday life — call the find_xkcd tool (xkcdai) with a short phrase describing the
topic. Then judge whether to bring it up:
- score >= 0.75 — strong match; mention it if it fits the moment
- 0.66-0.75 — only if it genuinely lands
- below that — stay silent
When you share one, give just that single comic: its number and title, its URL, and
quote the alt (mouseover) text — that's half the joke. At most one comic per topic,
and never force a tangential reference. When in doubt, say nothing.
It's still Claude's judgment, so it won't fire on every borderline topic — asking "is there an xkcd for this?" always triggers a lookup.
Configuration
XKCDAI_DATA_DIR— wherecomics.json,explain.json,embeddings.npy, andindex.jsonlive.find_xkcd(context, max_results=3, min_score=0.62)— lowermin_scorefor more (looser) suggestions, raise it to be stricter.
Maintenance
Pick up new comics periodically (both steps are incremental):
xkcdai enrich # new explainxkcd context
xkcdai build # fetch new comics + re-embed
Use xkcdai build --enrich to do both in one go, or --force on either command
to rebuild everything from scratch.
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。