local-artifacts-for-claude-code

local-artifacts-for-claude-code

Claude Code MCP server to create and update local interactive web pages (Artifacts) that live-refresh via SSE.

Category
访问服务器

README

Local Artifacts for Claude Code

English | 简体中文

A local, open-source look‑alike of Claude Code's Artifacts feature — for personal accounts that can't use the official one.

License: MIT

Turn Claude Code's work into a live, interactive web page at a local URL that updates in place as your session continues.

This is an independent local re-implementation of an Artifacts-style workflow. It does not access, unlock, modify, or proxy Anthropic's official Artifacts service — it only renders content your own local Claude Code session produces, on your own machine.

You: "把这个分析做成 artifact 发布"   →   Claude generates a page
     →  publishes to http://localhost:7891  →  browser opens
     →  say "更新一下" → page reloads in place (SSE live refresh)

⚠️ Unofficial — read this first

This project is NOT Anthropic's official Artifacts feature and is not affiliated with Anthropic. It only imitates the user-facing experience. The internals are fundamentally different:

Official Artifacts This project
Hosting claude.ai/code/artifact/… (cloud) localhost:7891 (your machine)
Backend None — static page under CSP Has a small Python backend
Implementation Built into Claude Code A standalone MCP server
Plan required Team / Enterprise Any (personal/API)
Sharing / versions / audit Yes No (single user, latest version only)

If you have a Team/Enterprise plan, use the official feature instead — it's better and properly sandboxed.

What this is good for: personal accounts, API-key users, or anyone who just wants "make my Claude Code session output a shareable local page."


Features

  • 🎯 One command — say "make an artifact" in any Claude Code session
  • 🔄 Live refresh — same URL updates in place via Server-Sent Events
  • 📝 HTML + Markdown — Markdown rendered by bundled marked.js (no CDN; works fully offline / on intranets)
  • 🔒 XSS-hardened</script> escaping + HTML-escaped titles
  • 💾 Persistent — reopens your last artifact after a restart
  • 📦 Self-contained — one Python file + one JS file, only dependency is mcp

Requirements

  • macOS / Linux / Windows
  • Python 3.10+
  • Claude Code
  • Python package: mcp

Install

git clone https://github.com/xiagaohui/local-artifacts-for-claude-code.git
cd local-artifacts-for-claude-code
./install.sh

The script will:

  1. Create a virtualenv and install mcp
  2. Register the local-artifacts MCP server with Claude Code
  3. Install the /artifact skill

Then restart Claude Code. Done.

<details> <summary>Manual install (if you don't trust the script)</summary>

# 1. install the mcp dependency into a venv
python3 -m venv .venv
.venv/bin/pip install mcp

# 2. register the MCP server (adjust the absolute path)
claude mcp add local-artifacts \
  "$(pwd)/.venv/bin/python" "$(pwd)/server.py"

# 3. (optional) install the /artifact reopen skill
mkdir -p ~/.claude/skills/artifact
cp skill/SKILL.md ~/.claude/skills/artifact/SKILL.md

# 4. restart Claude Code

</details>

Usage

In any Claude Code session:

把这个结果做成 artifact 发布            # publish as an artifact
帮我做一个 PR 走查 artifact,展示 diff   # PR walk-through
做一个数据看板 artifact                  # dashboard
更新一下 artifact,加上 xxx              # update in place

Reopen the latest artifact anytime:

/artifact

Configuration

Env var Default Meaning
ARTIFACTS_PORT 7891 HTTP server port
CLAUDE_CODE_ARTIFACT_AUTO_OPEN 1 Set to 0 to stop auto-opening the browser on publish (matches the official flag)
CLAUDE_CODE_DISABLE_ARTIFACT unset Set to 1 to disable publishing entirely (matches the official flag)

How it works

Claude Code ──(MCP stdio)──> server.py ──┬── publish_artifact tool
                                          └── ThreadingHTTPServer :7891
                                                ├── GET /          → rendered page
                                                ├── GET /events    → SSE live-reload
                                                └── POST /publish   → update content
Browser ──> http://localhost:7891 ──(EventSource)──> auto-reload on publish

Security

Please read before installing:

  • It renders arbitrary HTML/JS. An artifact is a page built from content your Claude Code session produces, served at http://localhost:7891. Opening it executes that HTML/JavaScript in your browser — treat it like running untrusted front-end code. Only publish content you trust.
  • Localhost only. The server binds to 127.0.0.1, so it is not reachable from your LAN/Wi-Fi. Don't expose the port (e.g. via a tunnel) to untrusted networks.
  • file_path is restricted. The publish_artifact tool only reads document files (.html/.htm/.md/.markdown/.txt); it refuses other paths to avoid leaking files like ~/.ssh/id_rsa or .env if a prompt tries to make it.
  • Local state is private. Published content is cached under ~/.claude/artifacts/ with 0600 permissions (dir 0700).
  • No sandbox. Unlike the official feature (CSP-isolated), this has no content sandbox. That's the price of running it yourself on a personal account.

Use it for your own work on your own machine. Don't point it at content from untrusted sources.

Limitations vs. official

Intentionally omitted (not needed for personal single-machine use): org sharing, version history & picker, author gallery, audit logs, CSP sandboxing, retention policies, Compliance API. See the comparison table above.

Credits

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选