Skip to content

Using Weft with AI agents ​

sh
claude mcp add weft -- weft mcp

Run that in your project's folder and Claude Code can work on the project through Weft's own tools. weft mcp is an MCP server, and any MCP client can start it the same way.

With these tools the agent edits the way Weft's editor does, not by rewriting files as text. It sees what the checker sees, edits nodes by id, and looks at the result:

  • Read: the project's files and routes, a file's outline (every element, prop and declaration with its node id), the schema's primitives and their props, the theme's tokens, these docs and the spec, and what each module exports.
  • Ask: diagnostics with their fixes, hover, references and completions, from the same analysis as weft lsp.
  • Edit: batches of the edit API's operations, such as inserting an element, setting a prop, setting a text or adding a state field, or a replacement of exact text. Every batch is checked and comes back with the new source and any errors it introduced. undo takes a batch back, and rename renames a name everywhere.
  • See: a page or a component rendered headlessly as a screenshot, with a map from every element on it to its source node, so the agent can point at what it sees and edit that node.
  • Run: weft test, weft check.

If weft dev is running, the agent's edits go through it and swap into the open page with its state kept. If it isn't, the agent edits the files, and the first screenshot of a page starts a weft dev for it.

An example ​

In a copy of the todos example, Claude Code was asked to add a "Welcome back" heading to the sign-in form and to make "Sign in" read "Log in", using only the weft tools. It rendered /, outlined routes/page, read the theme's classes, and sent one batch: an insert before the name field and a set_literal on the button's text. The batch introduced no errors. The agent then rendered / again to check. The element it added, shown here in a page of its own:

routes/page.weft
weft
---
<Box class="flex flex-col gap-2">
  <Text testId="welcome" class="font-heading text-2xl font-bold tracking-tight text-foreground">Welcome back</Text>
</Box>

What it needs ​

  • weft on your PATH (Get started installs it).
  • Chromium for screenshots: chromium on PATH, or WEFT_CHROMIUM set to the browser's binary. Without it, every other tool works, and a component still renders to HTML with its element map.

Screenshots are saved under .weft/mcp/shots/ in the project. The server stops the weft dev and the browser it started when the client goes. The tools and their arguments are listed in the MCP server's reference.

Weft is in development. The reference is the spec as it stands today.