|
| 1 | +--- |
| 2 | +description: Connect external MCP-capable agents directly to the Formbox Builder MCP endpoint. |
| 3 | +--- |
| 4 | + |
| 5 | +# MCP |
| 6 | + |
| 7 | +Formbox exposes an MCP endpoint so external agents can work with Formbox Builder directly. To connect an agent, use the `/sdc/mcp` endpoint and send a bearer token in the `Authorization` header. |
| 8 | + |
| 9 | +## Endpoint |
| 10 | + |
| 11 | +Formbox exposes one MCP endpoint: |
| 12 | + |
| 13 | +```text |
| 14 | +<formbox-base-url>/sdc/mcp |
| 15 | +``` |
| 16 | + |
| 17 | +## Authentication |
| 18 | + |
| 19 | +The authentication prerequisites are the same as for other Formbox MCP integrations: create a client, allow the required operations with an `AccessPolicy`, then request a bearer token. |
| 20 | + |
| 21 | +### 1. Create a client |
| 22 | + |
| 23 | +```http |
| 24 | +POST /Client |
| 25 | +content-type: application/json |
| 26 | +
|
| 27 | +{ |
| 28 | + "resourceType": "Client", |
| 29 | + "id": "formbox-mcp-client", |
| 30 | + "secret": "verysecret", |
| 31 | + "grant_types": ["client_credentials"] |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +### 2. Create an AccessPolicy |
| 36 | + |
| 37 | +This policy allows only the Formbox MCP operations used by this endpoint. |
| 38 | + |
| 39 | +```http |
| 40 | +POST /AccessPolicy |
| 41 | +content-type: application/json |
| 42 | +
|
| 43 | +{ |
| 44 | + "resourceType": "AccessPolicy", |
| 45 | + "id": "formbox-mcp-access", |
| 46 | + "engine": "matcho", |
| 47 | + "matcho": { |
| 48 | + "client": { |
| 49 | + "id": "formbox-mcp-client" |
| 50 | + }, |
| 51 | + "operation": { |
| 52 | + "$one-of": [ |
| 53 | + { "resourceType": "Operation", "id": "sdc-mcp" }, |
| 54 | + { "resourceType": "Operation", "id": "sdc-mcp-stream" }, |
| 55 | + { "resourceType": "Operation", "id": "sdc-mcp-delete" } |
| 56 | + ] |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +### 3. Get a token |
| 63 | + |
| 64 | +```http |
| 65 | +POST /auth/token |
| 66 | +content-type: application/json |
| 67 | +accept: application/json |
| 68 | +
|
| 69 | +{ |
| 70 | + "client_id": "formbox-mcp-client", |
| 71 | + "client_secret": "verysecret", |
| 72 | + "grant_type": "client_credentials" |
| 73 | +} |
| 74 | +``` |
| 75 | + |
| 76 | +Save the `access_token` from the response. You will use it as a bearer token when connecting your agent. |
| 77 | + |
| 78 | +## Connect an agent |
| 79 | + |
| 80 | +Add the Formbox MCP server to your agent configuration and send the bearer token in the `Authorization` header. |
| 81 | + |
| 82 | +{% tabs %} |
| 83 | +{% tab title="Codex" %} |
| 84 | +Add this to `~/.codex/config.toml`: |
| 85 | + |
| 86 | +```toml |
| 87 | +[mcp_servers.formbox] |
| 88 | +url = "<formbox-base-url>/sdc/mcp" |
| 89 | +http_headers = { Authorization = "Bearer <your-access-token>" } |
| 90 | +``` |
| 91 | +{% endtab %} |
| 92 | + |
| 93 | +{% tab title="Claude Code" %} |
| 94 | +Run: |
| 95 | + |
| 96 | +```sh |
| 97 | +claude mcp add --transport http --scope user \ |
| 98 | + --header "Authorization: Bearer <your-access-token>" \ |
| 99 | + formbox <formbox-base-url>/sdc/mcp |
| 100 | +``` |
| 101 | +{% endtab %} |
| 102 | + |
| 103 | +{% tab title="Cursor" %} |
| 104 | +Add this to `.cursor/mcp.json` in your project root, or `~/.cursor/mcp.json` for a global configuration: |
| 105 | + |
| 106 | +```json |
| 107 | +{ |
| 108 | + "mcpServers": { |
| 109 | + "formbox": { |
| 110 | + "url": "<formbox-base-url>/sdc/mcp", |
| 111 | + "headers": { |
| 112 | + "Authorization": "Bearer <your-access-token>" |
| 113 | + } |
| 114 | + } |
| 115 | + } |
| 116 | +} |
| 117 | +``` |
| 118 | +{% endtab %} |
| 119 | +{% endtabs %} |
| 120 | + |
| 121 | +Replace `<formbox-base-url>` with your Formbox base URL and `<your-access-token>` with the token returned by `/auth/token`. |
| 122 | + |
| 123 | +## Working with Formbox through MCP |
| 124 | + |
| 125 | +Once the MCP server is configured, the interaction usually looks like this: |
| 126 | + |
| 127 | +{% stepper %} |
| 128 | +{% step %} |
| 129 | +**User:** "Connect to Formbox and show me opened questionnaires."\ |
| 130 | +**Agent:** Lists the Builder tabs currently available for selection. |
| 131 | +{% endstep %} |
| 132 | + |
| 133 | +{% step %} |
| 134 | +**User:** "Use PHQ-9 draft."\ |
| 135 | +**Agent:** Requests access to that Builder tab and asks for approval in the browser. |
| 136 | +{% endstep %} |
| 137 | + |
| 138 | +{% step %} |
| 139 | +**User:** "Approved."\ |
| 140 | +**Agent:** Binds to the selected Builder tab and is ready to work with that questionnaire. |
| 141 | +{% endstep %} |
| 142 | + |
| 143 | +{% step %} |
| 144 | +**User:** "Add the remaining PHQ-9 questions, reuse the same answer options, and add a calculated total score at the end."\ |
| 145 | +**Agent:** Updates the questionnaire structure in the selected Builder tab. |
| 146 | +{% endstep %} |
| 147 | + |
| 148 | +{% step %} |
| 149 | +**User:** "Make all PHQ-9 questions required and verify the calculation."\ |
| 150 | +**Agent:** Applies the validation changes and checks that the calculation works. |
| 151 | +{% endstep %} |
| 152 | +{% endstepper %} |
| 153 | + |
| 154 | +After the session is selected, the agent works with the same live Builder tab you see in the browser, so you can watch the changes in real time and continue refining the questionnaire through the conversation. |
0 commit comments