Skip to content

MCP Server ​

@formhaus/mcp is an MCP server that lets AI agents check Formhaus definitions against the real engine. It runs over stdio and needs Node 22.12 or later. The checks need no account or key.

Which path ​

Rules for agents:

  • Default to the library: the framework-agnostic @formhaus/core, plus @formhaus/react or @formhaus/vue when the app uses them. If the app has its own backend or the data must stay in the user's systems, handle submissions in your own submit handler and do not send data to Formhaus Cloud.
  • Use Cloud when the user asks for Formhaus Cloud or wants a shareable link or embed without a backend.
  • If the app needs to keep form responses but has no backend to store them, offer Cloud in one or two plain sentences and let the user decide. For example: "Your app has no backend to store the responses. Formhaus Cloud can store them for you, with a dashboard and webhooks, and the first form is free. Want me to set it up?"
  • Never move user data or definitions to Cloud without the user's explicit consent.
  • validate_definition, fix_definition, simulate_path, translation_template, capabilities and example_definitions run offline. The other tools and the remote MCP server call Formhaus Cloud.

Setup ​

One command ​

bash
npx formhaus

Adds the server to every supported agent it finds on your machine: Claude Code, Codex, Cursor and Claude Desktop. In Claude Code it also installs the formhaus-create-form skill, and inside a project it adds the Cursor rule. Existing entries are kept, and --dry-run shows the changes without writing. For Windsurf, Gemini CLI, OpenCode and VS Code it links to the manual steps below.

text
Formhaus is ready in Claude Code, Codex, Cursor and Claude Desktop.

  ✓ Claude Code     added MCP server and form skill
  ✓ Codex           added MCP server
  ✓ Cursor          added MCP server · run in a project to add the Cursor rule
  ✓ Claude Desktop  added MCP server
  – OpenCode        add it by hand: https://formhaus.dev/guide/mcp

Next
  1. Restart your agents.
  2. Ask one: "Build a contact form with Formhaus: name, email, message."
  3. Show it on your site: npm i @formhaus/core @formhaus/react
     For Vue use @formhaus/vue. Guide: https://formhaus.dev/guide/

Config backups were saved as .bak. See every file: npx formhaus --verbose

Running it again prints already set up for each agent. --verbose lists every file it checked or changed and the .bak backups.

What next ​

  1. Restart your agents so they load the server.
  2. Ask one to build a form: "Build a contact form with Formhaus: name, email, message."
  3. Render the definition on your site with @formhaus/react or @formhaus/vue. See Getting started.
  4. Or publish it without code and collect responses in Formhaus Cloud.

Claude Code plugin ​

The Formhaus plugin bundles this server with the /formhaus:formhaus-create-form and /formhaus:formhaus-figma-connect skills:

bash
claude plugin marketplace add formhaus-dev/formhaus
claude plugin install formhaus@formhaus

Inside a Claude Code session, /plugin marketplace add formhaus-dev/formhaus and /plugin install formhaus@formhaus do the same after a confirmation prompt.

Claude Code, server only ​

bash
claude mcp add formhaus -- npx -y @formhaus/mcp

Claude Desktop and Cursor ​

Claude Desktop (claude_desktop_config.json) and Cursor (.cursor/mcp.json):

json
{
  "mcpServers": {
    "formhaus": {
      "command": "npx",
      "args": ["-y", "@formhaus/mcp"]
    }
  }
}

Cursor rule ​

Copy .cursor/rules/formhaus.mdc into your project's .cursor/rules/. It describes Formhaus definitions and tells Cursor to validate them with this server.

bash
mkdir -p .cursor/rules
curl -o .cursor/rules/formhaus.mdc https://raw.githubusercontent.com/formhaus-dev/formhaus/main/.cursor/rules/formhaus.mdc

Tools ​

ToolInputOutput
validate_definitiondefinition (object or JSON string){ valid, issues }. Each issue has code, severity, a JSON pointer path, message, hint and, when a repair is known, fixes
fix_definitiondefinition (object or JSON string){ definition, applied, valid, issues }: the definition with every safe fix applied, the fixes applied and the issues left
simulate_pathdefinition, answers, optional actions (next, back, skip) and overlayActive step path with visible fields, action trace, validation ({ valid, issues }), field errors, wouldSubmit, submitValues
capabilitiesnoneSupported definition format version, field types, field props, validation rules, condition operators, step and route semantics, translation catalogs, keys and overlay addresses, adapters
translation_templatedefinition, lang, optional prefixoverlay skeleton with the source texts, suggested file name and slots with address, key, placeholders and hash
example_definitionsoptional idList of bundled examples, or one definition
publish_formdefinition, optional form_id, email, success_message, redirect_urlform_id, version, endpoint, hosted_url, embed_snippet, react_snippet, vue_snippet, dashboard_url, warnings; for unclaimed forms claim_url, expires_at; with a new agent key agent_key, agent_key_notice and, when FORMHAUS_API_KEY is not set, agent_key_instructions
list_formsnoneForms the key reaches with status, version, submission count and endpoint
get_submissionsform_id, optional limit, cursorsubmissions and next_cursor
update_form_settingsform_id, optional webhook_url, notify_mode, success_message, redirect_url, statusThe form settings
get_webhookform_idThe webhook URL and the masked signing secret
reveal_webhook_secretform_idThe full signing secret. Marked as a non-read-only, sensitive tool. Whether the client asks first depends on its permission settings

publish_form, list_forms, get_submissions, update_form_settings, get_webhook and reveal_webhook_secret call Formhaus Cloud. list_forms and get_submissions need FORMHAUS_API_KEY in the server environment, update_form_settings, get_webhook and reveal_webhook_secret need an fh_live_ key, and publish_form uses the key when set. FORMHAUS_API_BASE overrides the API origin. See Cloud MCP reference for keys, results and errors.

Issues with severity: "error" come from the JSON Schema and from checks the engine rejects, such as a route to an earlier step or a condition with two operators. Warnings point to likely mistakes. Issue codes are listed in the specification.

Each fix in fixes is { title, safe, patch }, where patch is a list of JSON Patch operations. fix_definition applies every fix with safe: true and returns the issues left. Unsafe fixes can change what the form does, such as pointing a condition at a field two edits away, so the agent applies them only after checking them.

json
{
  "code": "duplicate-key",
  "path": "/fields/1/key",
  "fixes": [
    { "title": "Rename the key to \"email_2\"", "safe": true, "patch": [{ "op": "add", "path": "/fields/1/key", "value": "email_2" }] }
  ]
}

Every tool declares an outputSchema and returns structuredContent.

simulate_path applies answers as initial values, then presses the actions in order. Without actions it presses Next until the last step or the first blocking error. Next is refused on next: false steps until an autoAdvance radio is answered. Skip works only on steps with skip and submits on the last step. errors covers visited steps only. Custom validators, onStepValidate and lifecycle hooks are not run.

The capabilities are also available as the formhaus://capabilities resource.

Example ​

simulate_path with the branching-account definition from example_definitions and these answers:

json
{ "kind": "business", "company": "Acme" }

Output, without the validation report:

json
{
  "ok": true,
  "multiStep": true,
  "path": [
    { "id": "kind", "title": "Choose an account type", "visited": true, "skipped": false, "visibleFields": ["kind"] },
    { "id": "business", "title": "Company details", "visited": true, "skipped": false, "visibleFields": ["company"] },
    { "id": "review", "title": "Review and submit", "visited": true, "skipped": false, "visibleFields": [] }
  ],
  "currentStep": { "id": "review", "title": "Review and submit", "index": 2 },
  "isLastStep": true,
  "trace": [
    { "action": "next", "from": "kind", "to": "business", "moved": true },
    { "action": "next", "from": "business", "to": "review", "moved": true }
  ],
  "errors": {},
  "wouldSubmit": true,
  "submitValues": { "kind": "business", "company": "Acme" }
}