Browse and search developers
MCP server
Build and publish a form with MCP
A step-by-step MCP walkthrough: discover block types, create a draft form, add questions and an ending, validate, then publish.
On this page
This walkthrough builds a short workshop feedback form using real FormitAI MCP tools in the order an agent should call them. Each step shows the exact arguments object for the tools/call request. The argument names and limits match the input schemas in the MCP tool reference. The IDs in responses (FORM_ID, QUESTION_ID) are placeholders for the values your workspace returns.
Calling a tool
Every step is a JSON-RPC tools/call request to the MCP endpoint. Agent clients do this for you. To script it, use an MCP SDK:
curl -sS https://api.formitai.com/api/v1/mcp \
-H "Authorization: Bearer fmt_live_YOUR_KEY" \
-H "Content-Type: application/json" \
-H "Accept: application/json, text/event-stream" \
-d '{"jsonrpc":"2.0","id":1,"method":"tools/call","params":{"name":"list_block_types","arguments":{}}}'1. Discover block types
Call list_block_types with no arguments. Each entry has an id (the value you pass as type), its optionsPolicy (none, optional or required), minOptions, and paidFeature, which is set when the block needs a paid plan to publish.
{
"blockTypes": [
{ "id": "email", "label": "Email", "category": "input", "fieldType": "EMAIL",
"optionsPolicy": "none", "minOptions": 0, "paidFeature": null,
"requiredByDefault": true, "useWhen": "Email address" },
{ "id": "radio", "label": "Multiple Choice", "category": "choice", "fieldType": "RADIO_GROUP",
"optionsPolicy": "required", "minOptions": 2, "paidFeature": null,
"requiredByDefault": true, "useWhen": "Pick exactly one from a short visible list" }
]
}If you are unsure what a block accepts in settings, call get_block_schema with { "type": "star_rating" } to get its settings JSON schema and defaults.
2. Create the draft form
{
"name": "Workshop feedback",
"description": "Tell us how the session went."
}name is required (up to 120 characters) and description is optional (up to 500). The response is { "id": "FORM_ID", "name": "Workshop feedback" }. Keep id: every later call takes it as formId.
3. Add questions
Call create_question once per question. formId, type and title are required. required defaults to the block’s requiredByDefault. Questions are added to the end unless you pass position. Each call returns { "questionId": "QUESTION_ID", "blockType": "…" }.
{
"formId": "FORM_ID",
"type": "email",
"title": "What is your email address?",
"required": true
}{
"formId": "FORM_ID",
"type": "radio",
"title": "Which session did you attend?",
"required": true,
"options": [
{ "text": "Morning keynote", "value": "morning_keynote" },
{ "text": "Afternoon lab", "value": "afternoon_lab" },
{ "text": "Evening panel", "value": "evening_panel" }
]
}{
"formId": "FORM_ID",
"type": "star_rating",
"title": "How would you rate the workshop overall?",
"settings": { "min": 1, "max": 5, "step": 1 }
}{
"formId": "FORM_ID",
"type": "textarea",
"title": "What should we improve next time?",
"description": "Optional, but we read every answer.",
"required": false,
"settings": { "maxLength": 1000 }
}Option text can be up to 200 characters and value up to 100, with at most 100 options. Choice blocks with optionsPolicy: "required" need at least 2 options. If you leave options out, FormitAI adds placeholder options, so always send your own.
4. Add an ending
{
"formId": "FORM_ID",
"title": "Thanks for your feedback!",
"description": "We use every response to plan the next workshop."
}The response includes an endingId. You only need it if you add branching with set_question_logic, for example to send low ratings to a different ending. Call get_form_summary with { "formId": "FORM_ID" } to check question titles, types and order before publishing.
5. Validate before publishing
Call validate_publish with { "formId": "FORM_ID" }. It changes nothing and does not count toward the mutation limit. It reports whether the connected role has workspace.forms.publish and which paid features on the form the plan does not cover.
{
"formId": "FORM_ID",
"canPublish": true,
"permission": { "required": "workspace.forms.publish", "granted": true },
"plan": {
"currentTier": "free",
"requiredFeatures": [],
"blockedFeatures": [],
"suggestedPlan": null
}
}If canPublish is false, do not call publish_form. Either the role cannot publish (ask an Owner or Admin), or blockedFeatures lists paid features with their minPlan. Remove those blocks or upgrade.
6. Publish
{
"formId": "FORM_ID",
"versionLabel": "First release",
"confirm": true
}publish_form is destructive and is refused without confirm: true. A good agent asks the user before setting it. The response is { "formId": "FORM_ID", "published": true, "version": 1 }, and the version number goes up each time you publish. Publishing also sends a form.published webhook event if you subscribe to it. Finally, call get_share_link with { "formId": "FORM_ID" } to get the public URL to share.
Related
Can't find what you need?