publish-artifacts-mcp
Enables publishing, updating, and sharing HTML artifacts with strict security isolation (origin separation, CSP, API keys) via MCP tools.
README
publish-artifacts-mcp
Publish self-contained HTML artifacts safely, controlled by API key, and manage them over MCP (stdio + Streamable HTTP). Minimal admin UI included.
The hard part here is not "serve HTML" — it's hosting untrusted HTML without letting it steal credentials or exfiltrate data. The design centers on origin isolation + strict CSP + scoped API keys.
Stack
TypeScript · Node 22 · Hono · @modelcontextprotocol/sdk
· SQLite (better-sqlite3, WAL) · zod. Deploy via Docker.
How it works
Two planes share one process and one SQLite file, but are routed by Host header:
| Plane | Origin (example) | Serves | Auth |
|---|---|---|---|
| Control | api.example.com |
REST API, admin UI (/admin), MCP-over-HTTP (/mcp) |
API key (Bearer) |
| Content | content.example.com |
published artifacts at /a/:slug |
public, no cookies |
They must be different origins — the server refuses to boot otherwise (set
ALLOW_SAME_ORIGIN=1 only for local dev). This guarantees untrusted artifact
HTML can never reach the API/admin surface.
Safety layers
- Origin isolation (above) + host-based routing.
- Strict CSP on every served artifact:
default-src 'none',connect-src 'none',form-action 'none',frame-ancestors 'none',base-uri 'none'— blocks network/form exfiltration and framing while still allowing the artifact's own inline script/style to render.relaxedmode (opt-in per artifact) permits https network access. - Hardening headers:
X-Content-Type-Options,Referrer-Policy,X-Frame-Options,Permissions-Policy,Cross-Origin-Resource-Policy. No cookies are ever set on the content origin. - Unguessable slugs (~132 bits), optional expiry, and rotate to invalidate a shared link.
- API keys: high-entropy, SHA-256-hashed at rest, prefix-indexed, revocable, and owner-scoped (a key sees/mutates only its own artifacts).
- Limits: max HTML size + per-key publish rate limiting. Optional
sanitizetier strips scripts via DOMPurify.
Accepted trade-off (raw-path model): all artifacts share one content origin, so they can read each other's
localStorage. That's why no credentials live on the content origin. Upgrading to per-artifact subdomains (<slug>.content-domain) later requires only routing + wildcard DNS changes.
Quick start (local dev)
npm install
cp .env.example .env # defaults use content.localhost for isolation
npm run build
# Bootstrap an API key (printed once):
npm run create-key -- "my laptop"
# Run the server:
npm start
# admin UI: http://localhost:8787/admin (paste the key when prompted)
content.localhost resolves to 127.0.0.1 on most systems. If yours differs, add
127.0.0.1 content.localhost to /etc/hosts, or set ALLOW_SAME_ORIGIN=1 for
dev only.
MCP tools
publish_artifact, update_artifact, delete_artifact, get_artifact,
list_artifacts, get_share_link. All owner-scoped by the calling key.
stdio (Claude Code / Desktop) — .mcp.json
{
"mcpServers": {
"artifacts": {
"command": "node",
"args": ["/abs/path/dist/mcp/stdio.js"],
"env": {
"ARTIFACTS_API_KEY": "ak_...",
"CONTENT_BASE_URL": "https://content.example.com",
"CONTROL_BASE_URL": "https://api.example.com",
"DB_PATH": "/data/artifacts.db"
}
}
}
}
Remote (Streamable HTTP)
POST https://api.example.com/mcp with header Authorization: Bearer ak_....
Deploy (Docker)
Point two hostnames you control at the container (reverse proxy / DNS), set them
as CONTROL_BASE_URL / CONTENT_BASE_URL in docker-compose.yml, then:
docker compose up -d --build
docker compose exec artifacts node dist/cli/createKey.js "prod key"
SQLite persists in the artifacts-data volume (/data).
Tests
npm test # unit + MCP in-memory + HTTP host-isolation integration
The only
npm auditfindings are in the dev-onlyvitest/vite/esbuildchain (not shipped to production). Left unpinned to avoid a breaking vitest v4 bump; revisit when upgrading the test tooling.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。