Documentation
How it works

How Open Artifact works

Open Artifact is a Rust server. AI clients call its MCP tools to create apps. People open those apps in a browser and use actions to save changes.

Your AI client ── MCP ──> Rust server ──> artifact files + SQLite
                              │
Your browser <── app + state ──┘
     │
     └── action(name, input) ──> validate, run, save, return state

The MCP tools

The authenticated /mcp endpoint uses Streamable HTTP with JSON responses. It supports protocol versions 2025-03-26, 2025-06-18, and 2025-11-25. It does not provide GET/SSE subscriptions.

ToolWhat it does
list_artifact_typesDescribes app and presentation types, plus configured storage limits
create_artifactCreates an app or presentation and returns its UUID, version, and URL
update_artifactUpdates App source, CSS, title, component files, or presentation slides
register_actionAdds or replaces a state-changing backend action
upload_assetSaves image, video, or audio bytes locally
get_artifactReads source, state, revision, and version history
list_artifactsLists this owner’s apps and presentations, pinned first
pin_artifactPins or unpins an artifact in the library
list_componentsLists bundled defaults or an artifact’s own files
get_componentReads actual component source, including older versions
update_componentsPublishes component and optional App/CSS edits atomically
create_shareCreates a named invitation with a unique access code
revoke_shareDisables an invitation and its sessions
get_building_skillReturns the guide and examples for agents

The same tool operations are available at POST /api/tools/TOOL_NAME with a bearer token and JSON body. The server advertises OAuth discovery metadata and supports authorization-code login with PKCE and rotating refresh tokens. Clients register exact callback URLs; the server does not fetch remote client metadata. There is also a dependency-free stdio adapter in scripts/mcp-stdio.mjs.

An artifact is a small React app

The App source is JSX or TSX with a default React export. Each new artifact gets editable copies of 56 shadcn components and two helpers. The server bundles React, React DOM, Tailwind, Lucide, and supporting packages locally. There are no runtime npm installs or CDN imports.

import {useState} from 'react';
import {useArtifact} from '@artifact/sdk';
import {Button} from '@/components/ui/button';
 
export default function App() {
  const {state, action, can_edit} = useArtifact();
  const [busy, setBusy] = useState(false);
  const [error, setError] = useState('');
 
  async function increment() {
    setBusy(true);
    setError('');
    try { await action('increment', {by: 1}); }
    catch (e) { setError(e.message); }
    finally { setBusy(false); }
  }
 
  return <main>
    <Button disabled={!can_edit || busy} onClick={increment}>
      Count: {state.count}
    </Button>
    {error && <p role="alert">{error}</p>}
  </main>;
}

This example needs an initial count and a registered increment action, shown below.

useQueryParam controls tabs and page-like views without changing the artifact path. useAsset loads an uploaded asset through the authenticated host. Component paths are virtual files inside an artifact; editing one cannot edit the defaults or another artifact.

Built-in presentations

create_artifact with kind: "presentation" accepts a title and structured slides. Slides have text, bullets, columns, notes, or an uploaded image. The server compiles a fixed presentation UI with navigation, query routing, keyboard controls, overview, and fullscreen. Agents cannot replace its source or controls; they update the slides. Notes are visible to everyone with access.

The general app type remains a custom React app with editable components and backend actions. Presentation authoring example.

One endpoint for saved changes

Every frontend mutation goes through POST /api/artifacts/UUID/actions. The SDK sends an action name, input, expected code version, expected state revision, and a request UUID.

An action is a synchronous JavaScript function body with state, input, and the server-authenticated actor in scope:

state.count += input.by;
state.lastEditedBy = actor.name;
return state;

Inputs are validated with JSON Schema. Actions run in a fresh QuickJS runtime without filesystem, network, process, environment, SQL, or module-loader access. They are limited to 100 ms of execution, a 16 MB heap, and a 256 KB stack. Failures leave state unchanged.

Actions can use console.debug, log, info, warn, and error. Each execution collects up to 50 entries of 800 characters. Successful responses return those logs; exceptions return bounded logs and a JavaScript stack. Diagnostics do not grant any additional storage or network access.

The viewer combines action diagnostics with recent browser logs and catches render errors, uncaught exceptions, and unhandled promise rejections. Its Copy fix prompt button remains outside the sandbox. The session buffer keeps at most 80 entries, only accepts messages from that artifact's frame, and clears on reload. It does not collect server-wide logs or another viewer's console.

SQLite commits state, revision, the actor audit event, and a retry receipt together. A stale version or revision returns 409. Identical retries return the saved result while it remains in the latest 64 receipts; older retries fail the stale revision check. The last 1,000 audit events are retained.

Code versions and saved data are different

A code version captures App source, components, CSS, actions, and the asset manifest. State is live and has its own increasing revision. Editing the UI preserves state. Historical previews use live state and disable actions.

When a state shape changes, the agent needs an explicit migration action. Viewers poll for updates every three seconds; a new code version asks them to reload.

Storage and access

/data/
  catalog.sqlite
  artifacts/
    UUID/
      artifact.sqlite
      assets/ASSET_UUID

The catalog stores the artifact index, shares, and hashed sessions. Each artifact has separate state and asset storage. The server is the only storage authority.

Frontends run inside an opaque-origin sandboxed iframe. They cannot read the host’s cookies, browser storage, or other artifacts. A restricted message bridge handles only that artifact’s actions, assets, and query navigation. Browser policy blocks external requests and nested frames.

Library thumbnails use the same sandbox with a separate read-only bridge. They render the artifact's UI and saved state, but cannot run actions or change the host's URL. Only that artifact's images can load, within preview size limits. Previews unload when scrolled away.

An approved MCP client or optional owner API token can create and modify any artifact. Share codes are bearer credentials with owner-assigned names, not verified identities. Read-only shares cannot run actions; editable shares can run any registered action unless the action checks a finer rule. All viewers can read the complete state.

This is a single-owner server with limited share recipients. QuickJS and SQLite run in the Rust process; this is not a separate OS container per artifact. Frontend JavaScript has no CPU quota. Keep dependencies patched, and do not treat it as hostile public multi-tenant code hosting.

Find the code

PathResponsibility
src/main.rsHTTP routes and browser response policies
src/auth.rs, src/config.rsAuthentication and CLI, environment, and JSON configuration
src/mcp.rs, src/service.rsMCP protocol, tool schemas, orchestration, and compilation
src/store.rsSQLite storage, versions, state, and shares
src/presentation.rs, web/presentation.*Slide validation and server-owned presentation controls
src/sandbox.rsAction validation and bounded QuickJS execution
src/components.rs, ui/Embedded editable component catalog and theme
scripts/compile.mjsClosed import resolution, esbuild, and Tailwind compilation
web/Server-owned viewer, iframe bootstrap, and React SDK
skills/build-artifact/Authoring guide embedded in the MCP server
evals/Browser, protocol, isolation, and offline-container evals
website/This independent Next.js/Nextra static site

The UI catalog is an MIT-licensed shadcn source snapshot. ui/manifest.json records its provenance and upstream hashes; ui/LICENSE.md retains the license. A maintainer can refresh it with scripts/vendor-ui.mjs, then review adaptations and evals. The script is excluded from the runtime image.