# ChargeForms AI and MCP

ChargeForms exposes an opt-in Model Context Protocol endpoint for AI clients.
The site owner keeps control of the model: ChargeForms does not require a
ChargeForms-hosted AI account and does not send data anywhere until the owner
connects an AI client and enables MCP.

## Enable the server

1. Open **ChargeForms → Global Settings → MCP for AI Agents**.
2. Enable the MCP server.
3. Create a WordPress Application Password for a user with
   `chargeforms_manage_forms`.
4. Configure the MCP client with the endpoint shown on that settings screen.
5. Use HTTP Basic Authentication with the WordPress username and Application
   Password.

The endpoint is:

`/wp-json/chargeforms/v1/mcp`

MCP is disabled by default. A client without the required capability receives
no form, entry, payment or integration data.

## AI form-building workflow

AI clients should use this sequence when creating or changing a form:

1. Generate a field blueprint locally in the client.
2. Call `validate_form_blueprint` with the proposed field tree.
3. Repair every returned diagnostic before continuing.
4. Call `create_form` or `update_form_fields`.
5. Show the structured preview to the user.
6. Repeat the exact write call with the returned `confirm_token` only after the
   user approves the change.

Write operations are rejected again at execution time if the blueprint becomes
invalid, contains duplicate IDs, references an unavailable field type or uses
a Pro-only field without an active Pro license.

## Available tool groups

Read tools include form context, forms, submissions, form statistics,
integrations, payment totals and activity logs. Write tools include creating a
form, replacing a form's fields, updating submission status, bulk status
changes, deleting a submission and adding an internal note.

The `get_submission` tool can expose submitted values to an authorized AI
client. Site owners should only connect clients they trust and should avoid
sharing sensitive forms with an AI service unless that service's privacy and
retention policies are acceptable.

## Safety model

- MCP is explicit opt-in.
- WordPress capability checks apply to every request.
- Write tools require preview and confirmation.
- Confirmation tokens are bound to the exact user, tool and arguments and
  expire after five minutes.
- Blueprint validation runs before preview and again before the write.
- The normal form submission path does not depend on AI availability.

