loki

loki

Loki lets an AI agent run an entire website at runtime — content schema, content, code, routes, and design — through a single MCP endpoint.

Category
访问服务器

README

<picture> <source media="(prefers-color-scheme: dark)" srcset="assets/logo-dark.svg"> <img src="assets/logo.svg" alt="Loki" width="330"> </picture>

Loki lets an AI agent run an entire website at runtime — content schema, content, code, routes, and design — through a single MCP endpoint. No repo to clone, no build pipeline, no deploy step. The agent writes TSX, previews it at a real URL, and publishes by repointing a version. Rollback is instant. A failed publish never touches the live site.

Loki is a single Cloudflare Worker built on agent-cms (agent-first headless CMS: D1, GraphQL, MCP) and Dynamic Workers (the Worker Loader API, open beta). Site code lives in the database, compiles at write time, and executes in sandboxed V8 isolates loaded on demand.

Why

Agents are already good at building websites. What slows them down is the ceremony around the code: branches, pull requests, CI, deploys — a loop designed for humans coordinating with humans. agent-cms moved schema and content into the runtime loop; Loki moves the rest of the site there too. "Deploy" collapses into a database write, and the whole edit → preview → publish cycle happens inside one conversation.

The safety you lose by skipping CI is re-created where an agent can actually use it:

  • Publish-time validation — every GraphQL query in the site is validated against the live schema; a smoke render runs in a throwaway sandbox. Errors come back precise (routes/index.tsx#gql0: Cannot query field "subtitle" on type "BlogPostRecord". Did you mean "title"?) and the live site stays untouched.
  • Immutable versions — publishing snapshots the compiled site; rollback_site repoints a pointer.
  • A migration guard — Loki records which schema fields each published version queries (its footprint). Destructive schema operations that would break the live site are rejected with an error that teaches the expand → backfill → publish → contract order.

Architecture

flowchart LR
    A[Your agent] -- MCP --> M["/mcp (merged endpoint)"]
    subgraph W [Loki · one Cloudflare Worker]
        M -- site tools --> S[(D1: site files,\nversions, footprints)]
        M -- CMS tools, guarded --> C[agent-cms\nschema · content · GraphQL]
        S --> L[Worker Loader]
        L -- loopback GraphQL --> C
    end
    V[Visitors] --> L
  • Merged MCP endpoint. Loki exposes one /mcp: its own site tools plus every agent-cms tool, proxied in-process. Destructive schema calls pass through the migration guard first.
  • Site ring. Source files (TSX/TS/CSS) are stored in D1 and transpiled on write (sucrase). Publishing snapshots a compiled module map into a version row.
  • Serving. Public traffic loads the published version into a V8 isolate via LOADER.get("site:v<N>") — milliseconds on cold start, cached while warm. The isolate gets exactly two capabilities: a loopback GraphQL binding into the CMS and nothing else (globalOutbound: null).
  • Preview. preview_site mints a 30-minute token; the draft tree serves at the real domain behind an HttpOnly cookie, with draft content included in queries.

The authoring model

The agent writes Preact routes with file-based routing:

// routes/posts/[slug].tsx
import { gql, query, renderStructuredText } from "loki/runtime";

const POST = gql`
  query Post($slug: String!) {
    blogPost(filter: { slug: { eq: $slug } }) {
      title
      body { value }
    }
  }
`;

export async function loader({ env, params }) {
  const data = await query(env, POST, { slug: params.slug });
  return { post: data.blogPost };
}

export const head = (props) => ({ title: props.post?.title ?? "Post" });

export default function Post({ post }) {
  return (
    <article>
      <h1>{post.title}</h1>
      {renderStructuredText(post.body?.value)}
    </article>
  );
}

routes/index.tsx/, routes/posts/[slug].tsx/posts/:slug, styles.css → linked stylesheet. A main.ts default-exporting a fetch handler is the escape hatch from file routing. The full guide lives in the site_help tool — the endpoint documents itself.

Tools

On top of the full agent-cms toolset (models, fields, records, publishing, assets, search), Loki adds:

Tool What it does
site_write / site_read / site_list / site_delete Edit the draft tree; writes transpile immediately and reject on error
site_asset_import / site_asset_write Add design images and one-off files (favicon, OG image, hero, downloads) by URL or bytes; returns the exact URL to paste
site_diff Draft vs. published: added / changed / removed, code and assets
graphql_query Explore the content API (introspection included) before writing route queries
preview_site Token URL serving the draft at the real domain
publish_site Validate queries → extract footprint → smoke render → snapshot → go live
site_versions / rollback_site List immutable versions; repoint the live pointer
site_help The authoring guide, served by the endpoint itself

Beyond static pages, routes can export an action to handle form POSTs, write to allowlisted content models (env.RECORDS), and push to WebSocket channels (env.REALTIME) — and any component can become a hydrated Preact island (<Island client="visible">) for client-side interactivity, served with no bundler via native ES modules and import maps. A live realtime guestbook, forms, and design assets all run this way today.

Quickstart

You need a Cloudflare account on Workers Paid (for Worker Loader, open beta), pnpm, and wrangler logged in.

git clone https://github.com/jokull/loki && cd loki
pnpm install && pnpm vendor

wrangler d1 create loki-cms        # put the new database_id in wrangler.jsonc
wrangler d1 migrations apply loki-cms --remote
wrangler secret put WRITE_KEY      # any long random string
wrangler deploy

Connect your agent (Claude Code shown; any MCP client works):

claude mcp add loki https://loki.<your-subdomain>.workers.dev/mcp \
  --transport http --header "Authorization: Bearer <WRITE_KEY>"

Then ask for a website:

Read site_help. Create a blog with a few posts about anything, design it nicely, preview it, and publish.

In the first end-to-end test, an agent given nothing but the endpoint URL and the key did exactly that — schema, content, routes, stylesheet, dark mode — and shipped it, self-correcting from the validation errors along the way.

The migration guard

The part CI can't do for you. Each published version stores the set of GraphQL types and fields it queries. When the agent later tries delete_field on something the live site depends on:

Blocked by Loki migration guard: The published site (version v5) still queries
field "slug" (GraphQL BlogPostRecord.slug) on model "blog_post".
Follow the expand -> contract migration order:
  1. EXPAND: add the replacement field
  2. BACKFILL: migrate content
  3. UPDATE SITE CODE: publish a site version that no longer queries it
  4. CONTRACT: retry this operation

The same check covers the REST API (409). Non-breaking updates (labels, validators, hints) pass through untouched.

Status & roadmap

This is a working experiment, not a product. Rough edges are documented by the tools themselves.

Working today: schema + content + code + design at runtime, immutable versions with rollback, the migration guard, preview at a real URL, Preact islands (partial hydration, no bundler), form actions with scoped record writes, realtime channels (WebSocket-backed Durable Objects), and content-addressed static/design assets in R2 (version-pinned, served with ETag/304).

Planned:

  • Cloudflare Artifacts as the site-code store (git-compatible branches, diffs, and a git clone escape hatch) once it exits private beta — D1 is the store today
  • Code Mode on the merged endpoint (one code tool instead of forty)
  • Serve-time image transforms via the Cloudflare Images binding (resize/format from one stored original)
  • Rate limiting for public write routes; presigned direct-to-R2 for large human uploads
  • Durable Object Facets for per-feature state (agent-built apps with their own SQLite)

License

MIT © Jökull Sólberg

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选