Skip to main content
Glama
Wexmira MCP Server

Wexmira MCP Server

Official
by Wexmira
README.md
# Wexmira

Free, open-source survey builder that coding agents can drive. Design surveys (pages, welcome and end pages, quota-full pages, 25 question and block types incl. panels and repeating dynamic panels), add skip logic, branching and quotas, send invitations through **your own** mail server (Gmail or any SMTP), collect answers and export them to **CSV, Excel and SPSS .sav**. Data lives in **SQLite** (default, one file) or **PostgreSQL, MySQL, MariaDB, SQL Server or CockroachDB**. Everything works through **MCP**, from Claude Code, Google Antigravity, OpenAI Codex CLI or any MCP client, and through a **web UI** that calls the very same operations.

> Status (1 Dec 2026): **v0.1.0-rc.1, first release candidate, plus the admin dashboard and survey versioning.** Survey format and engine, web UI (Creator, logic and quotas, theme, translations, preview, versions, responses, Dashboard, users and roles), an **admin dashboard** (settings for everything, database with backup/restore and engine switching, email queue, API keys and MCP tokens, audit log, system health), **drafts and published versions** (publish v1, v2, v3 with notes, compare, switch the live version back, restore into the draft, unpublish), email (own mail server, queue, unsubscribes), answer collection, exports (CSV, Excel, SPSS .sav), PDF generation, 6 database engines and an MCP server with 103 tools over stdio or HTTP. Still to come: accessibility audit, file uploads, fillable PDFs. See [docs/PLAN.md](docs/PLAN.md) and [docs/PROGRESS.md](docs/PROGRESS.md).

## Quick start

Needs **Node 22.12 or newer** (Node 24 LTS is fine; 22.9 to 22.11 also work, the web build only prints a Vite warning) and git. Chrome or Edge is used for PDFs and the browser tests, if installed.

```sh
git clone https://github.com/Wexmira/wexmira && cd wexmira
npm install
npm start                # one command: builds everything, starts the web UI + API on http://localhost:8787
```

Open http://localhost:8787: the first visit creates the **admin** account. Data goes to the SQLite file `./wexmira.db` unless you choose another database (below).

```sh
npm test                 # builds and runs all tests (incl. a real stdio MCP session)
npm run test:ui          # browser tests of the web UI (uses your installed Chrome or Edge)
npm run mcp              # the MCP server on stdio (normally your agent starts it, see below)
```

### Settings (`.env`)

Copy `.env.example` to `.env`; `npm start`, `npm run dev:api` and `npm run mcp` read it. The most used settings:

| Variable | Meaning |
|---|---|
| `PORT` | Web UI + API port (8787) |
| `WEXMIRA_DB_URL` | Database (default `sqlite:./wexmira.db`), see [Databases](#databases) |
| `WEXMIRA_SECRET` | 16+ character key that encrypts stored mail passwords; email stays off without it. Use the same value for the API and the MCP server |
| `WEXMIRA_BASE_URL` | Public URL put in survey and unsubscribe links (default `http://localhost:<PORT>`) |
| `WEXMIRA_API_KEY` | Key for scripts calling the API (admin). Keys with a smaller role: Admin › API keys & MCP |

Everything else (instance name and branding, time zone, email limits, password rules, session length, upload and export folders, theme of new surveys, languages, date format) is set in the web app under **Admin**, stored in the database. A setting can also be fixed by an environment variable (`WEXMIRA_BASE_URL`, `WEXMIRA_EXPORT_DIR`, `WEXMIRA_UPLOAD_DIR`, or `WEXMIRA_SETTING_<GROUP>_<NAME>`, e.g. `WEXMIRA_SETTING_SECURITY_SESSION_HOURS=12`); the admin page then shows it read-only. Secret settings are write-only.

### Connect your agent (MCP)

Build once (`npm install && npm run build`; `npm start` also builds), then point your agent at `packages/mcp/dist/index.js`. Use the **same database and secret** as the web UI so both see the same surveys. Replace `/path/to/wexmira` with the absolute path of your clone (on Windows `C:/Users/you/wexmira` works).

**Claude Code**

```sh
claude mcp add wexmira -s user \
  -e WEXMIRA_DB=/path/to/wexmira/wexmira.db \
  -e WEXMIRA_SECRET=change-me-to-a-long-random-string \
  -e WEXMIRA_BASE_URL=http://localhost:8787 \
  -- node --experimental-sqlite --no-warnings /path/to/wexmira/packages/mcp/dist/index.js
```

**Google Antigravity**: Agent panel → "…" → MCP Servers → Manage MCP Servers → View raw config, and add:

```json
{
  "mcpServers": {
    "wexmira": {
      "command": "node",
      "args": ["--experimental-sqlite", "--no-warnings", "/path/to/wexmira/packages/mcp/dist/index.js"],
      "env": {
        "WEXMIRA_DB": "/path/to/wexmira/wexmira.db",
        "WEXMIRA_SECRET": "change-me-to-a-long-random-string",
        "WEXMIRA_BASE_URL": "http://localhost:8787"
      }
    }
  }
}
```

**OpenAI Codex CLI (GPT)**: add to `~/.codex/config.toml`:

```toml
[mcp_servers.wexmira]
command = "node"
args = ["--experimental-sqlite", "--no-warnings", "/path/to/wexmira/packages/mcp/dist/index.js"]

[mcp_servers.wexmira.env]
WEXMIRA_DB = "/path/to/wexmira/wexmira.db"
WEXMIRA_SECRET = "change-me-to-a-long-random-string"
WEXMIRA_BASE_URL = "http://localhost:8787"
```

For a database server, set `WEXMIRA_DB_URL` instead of `WEXMIRA_DB`.

**Over the network (MCP over HTTP):** when Wexmira runs on a server, create an **MCP token** in **Admin › API keys & MCP** (pick a role: viewer, editor or admin; the agent only sees the tools that role may use) and connect to `<base URL>/mcp`:

```sh
claude mcp add --transport http wexmira https://surveys.example.com/mcp --header "Authorization: Bearer wxm_..."
```

Other clients take `{"type": "http", "url": "https://surveys.example.com/mcp", "headers": {"Authorization": "Bearer wxm_..."}}`. The token is shown once; revoke it there any time.

More options (export folder, ready-made config files): [examples/mcp](examples/mcp/README.md). All tools: [docs/MCP-TOOLS.md](docs/MCP-TOOLS.md). Then ask the agent, for example: *"Create a CX survey with an NPS question, send detractors to a page asking what went wrong, add a quota of 200 buyers, simulate a detractor, then publish it."*

### Email setup

1. Set `WEXMIRA_SECRET` in `.env` (and in the MCP config) and restart `npm start`.
2. As admin, open **Email → Accounts → Add account** (or the MCP tool `add_mail_account`) and pick a provider: Gmail or Google Workspace (app password with 2-Step Verification, or OAuth2), Outlook / Microsoft 365, Amazon SES, SendGrid, Mailgun, Postmark, Resend, Brevo, Zoho, or **any SMTP server** (host, port, login). **Test login** checks it.
3. Import contacts (**Email → Contacts**), create a campaign for a published survey and send it. Mail goes through a queue with rate limits and retries; every invitation has a personal link and one-click unsubscribe (RFC 8058); unsubscribes are kept on the suppression list.

To try it without a real mailbox: `npm run mail:sink` starts a local test SMTP server on port 2525 that prints what it receives.

### Drafts and versions

Editing always changes the survey's **draft** (every edit is saved at once; **Save draft** marks a checkpoint with a note). Respondents keep getting the **live published version** until you **Publish**, which freezes the draft as a new immutable version (v1, v2, v3 ...) with a note, the date and who published it. The survey page shows "unpublished changes" when the draft differs from the live version. The **Versions** tab lists every version with its responses, **compares** any two (or a version and the draft: pages, questions, endings, quotas, settings, theme, field by field), **previews** any version, **makes an older version live again** (roll back), **restores** a version into the draft to edit it, and **unpublishes** the survey; every step is recorded in its history. Responses stay linked to the version they answered and can be filtered and exported by version. MCP: `save_draft`, `publish_survey`, `list_versions`, `get_version`, `compare_versions`, `restore_version` (target `live` or `draft`), `unpublish_survey`; REST: `/api/surveys/:id/versions`, `/compare`, `/draft`, `/publish`, `/versions/:v/restore`, `/unpublish`.

### Admin dashboard

**Admin** (admin role) has: an **overview** (surveys, responses per day, emails, contacts, users, most answered surveys, recent activity, system state); **General** (name, base URL, default language and time zone, brand colour, logo, support email); **Database** (engine, migrations, rows per table, test a connection to SQLite, PostgreSQL, MySQL, MariaDB, SQL Server or CockroachDB, copy all data to it to switch engines, JSON backup download and restore, see [docs/DATABASES.md](docs/DATABASES.md)); **Email** (the queue with filters, retry, cancel, failed list and "pause all sending", mail accounts with SMTP/Gmail settings and a test email, retries, default limits and sender, hard-bounce handling, one-click unsubscribe headers, a bounce webhook); **Users & roles**; **API keys & MCP tokens** (create with a role and expiry, shown once, last used, revoke); **Security** (password length and letters+digits, session lifetime, sign-in lock); **Storage & uploads**; **Exports**; **Themes** (look of new surveys); **Localisation** (languages, date format); the **audit log** (filters, details); **system health** (versions, uptime, database and migrations, queue sizes, memory, disk). The same is available to agents as `get_settings` / `update_settings` (no secrets), `admin_overview`, `system_health`, `list_audit_log`, `test_database_connection`, and as `/api/admin/*`.

### Roles

| Role | Can |
|---|---|
| viewer | see surveys, logic, quotas, preview, versions, responses, results; download exports |
| editor | everything a viewer can, plus design, save drafts, publish, switch or restore versions, unpublish, open/close, archive, duplicate, delete responses, email campaigns |
| admin | everything, plus the Admin dashboard (settings, database, tokens, audit log), users, mail accounts and deleting surveys |

The UI has no survey logic of its own: every action is a call to `/api/tools/<name>`, which runs the **MCP server's tool handlers** (same input checks, same edit operations, same results), and the preview runs the shared engine in the browser. So anything done in the UI can be done by an agent over MCP and the other way round; both use revision checks, so an agent's edit and a UI edit never overwrite each other silently. For UI development: `npm run dev:api` and `npm run dev:web` (Vite on :5173).

## Databases

| Engine | Tested version | `WEXMIRA_DB_URL` |
|---|---|---|
| SQLite (default) | 3.46 | `sqlite:./wexmira.db` (or set `WEXMIRA_DB` to a file path) |
| PostgreSQL | 16 | `postgres://user:pass@host:5432/wexmira` |
| MySQL | 8.4 | `mysql://user:pass@host:3306/wexmira` |
| MariaDB | 11.4 | `mariadb://user:pass@host:3306/wexmira` |
| SQL Server | 2022 | `mssql://user:pass@host:1433/wexmira?trustServerCertificate=true` |
| CockroachDB | 24.3 | `cockroachdb://user@host:26257/wexmira` |

Tables are created and migrated automatically. `npm run db:check` tests a connection; **Admin › Database** (or `npm run db:copy -- <url>`) copies everything to another engine and makes JSON backups; `npm run test:engines` runs the storage and MCP tests on every engine in throwaway Docker containers. Not supported: Oracle, MongoDB, D1/libSQL (yet). Details: [docs/DATABASES.md](docs/DATABASES.md).

## Screenshots

### Admin dashboard and versions (1 Dec 2026)

Real captures from the browser tests (`apps/web/tests/admin.test.mjs`, `versions.test.mjs`) and from the local instance with the Brightcart sample survey.

| | |
|---|---|
| ![Admin overview](docs/screenshots/web-admin-overview.png) Admin overview: key numbers, completes per day, top surveys, activity, system. | ![General settings](docs/screenshots/web-admin-general.png) General settings: name and brand colour apply at once; a value fixed by an environment variable is read-only. |
| ![Database](docs/screenshots/web-admin-database.png) Database: engine and migrations, connection test, copy to another database, backup and restore. | ![Email](docs/screenshots/web-admin-email.png) Email: the queue (filters, retry, cancel, pause all sending), accounts, limits, bounces. |
| ![Tokens](docs/screenshots/web-admin-tokens.png) An MCP token, shown once, with the Claude Code command and the config for other clients. | ![Audit log](docs/screenshots/web-admin-audit.png) Audit log with filters and details. |
| ![Versions](docs/screenshots/web-versions.png) Versions: the draft, every published version with responses, make live, preview, restore, history. | ![Compare](docs/screenshots/web-versions-compare.png) Compare live vs draft, field by field. |
| ![Health](docs/screenshots/web-admin-health.png) System health. | ![Brightcart versions](docs/screenshots/sample-brightcart-versions.png) The Brightcart sample survey's version history on the local instance. |

### Web UI (1 Dec 2026)

Real captures, made by the browser test (`npm run screenshots`) on a fresh SQLite database with the example CX survey and 40 test respondents.

| | |
|---|---|
| ![First run](docs/screenshots/web-1-setup.png) First run: create the admin account. | ![Surveys](docs/screenshots/web-2-surveys.png) Surveys: filter by status, search, duplicate, archive, delete. |
| ![Design](docs/screenshots/web-3-design.png) Design: welcome page, pages, questions and options; click any text to edit it. | ![Logic and quotas](docs/screenshots/web-4-logic.png) Logic & quotas: routing rules in plain words, display conditions, quota progress (limits editable). |
| ![Preview](docs/screenshots/web-5-preview.png) Preview: the survey runs with the engine (branching, required answers, quotas, endings), with the path, variables and kept answers beside it. | ![Responses](docs/screenshots/web-6-responses.png) Responses: status, date and text filters, paging, one response in detail, CSV / Excel / SPSS export. |
| ![Results](docs/screenshots/web-7-results.png) Results: counts, completion rate, quotas, a chart per question, NPS. | ![Users](docs/screenshots/web-8-users.png) Users: add people, change roles, reset passwords, disable or delete. |

### MCP server, API and tests (30 Nov 2026)

| | |
|---|---|
| ![MCP session](docs/screenshots/mcp-session.png) An MCP client designs a survey, adds a branching rule, simulates a path and publishes it; the server stores it in PostgreSQL. | ![Tests on every engine](docs/screenshots/tests-engines.png) Storage suite and end-to-end MCP test on PostgreSQL, MySQL, MariaDB, SQL Server and CockroachDB. |
| ![Connection check](docs/screenshots/db-check.png) `db-check` on all six engines. | ![npm test](docs/screenshots/tests-sqlite.png) `npm test` on SQLite (30 Nov capture, 58 tests then; 131 now), 1 skipped: the server-engine suite, which needs Docker. |
| ![Survey definition](docs/screenshots/survey-definition.png) A survey definition: welcome page, screener with screen-out, NPS branching, quota and endings. | ![Unsubscribe page](docs/screenshots/api-unsubscribe.png) The API's one-click unsubscribe page (from an invitation token). ![Public survey JSON](docs/screenshots/api-public-survey.png) The public survey endpoint the runner will use. |

The terminal pictures are the commands' real output, rendered unchanged into a terminal frame (long runs are cut where marked).

## Layout

| Path | What it is |
|---|---|
| `packages/schema` | Survey format v1 (Zod → `survey.schema.json`), validator, engine (branching, piping, quotas, expressions, quiz, timers), edit operations, SurveyJS importer, example `examples/cx-nps.json` |
| `packages/db` | Store on Kysely for SQLite, PostgreSQL, MySQL, MariaDB, SQL Server, CockroachDB (drafts, versions and their history, responses, quotas, contacts, suppressions, mail accounts, campaigns, email queue, settings, API/MCP tokens, audit log); backup, restore and copy between engines |
| `packages/mail` | Provider presets, invitation templates, queue worker with rate limits, retries and RFC 8058 one-click unsubscribe |
| `packages/exports` | One codebook → CSV, XLSX, SPSS .sav; Dashboard analytics |
| `packages/pdf` | Paper questionnaire, response and results-report PDFs (printed with the installed Chrome/Edge) |
| `packages/mcp` | MCP server, 103 tools ([docs/MCP-TOOLS.md](docs/MCP-TOOLS.md)), on stdio and (in the API server) over HTTP at `/mcp` |
| `apps/api` | HTTP API: public survey + responses, unsubscribe pages, exports, sign-in and users, versions, `/api/admin/*`, `/api/tools/<name>` (the MCP tool handlers), `/mcp`, serves the web app |
| `apps/web` | Web UI (React 19 + Vite): surveys, design, logic and quotas, preview, versions, responses, results, users, admin dashboard; browser tests in `apps/web/tests` |
| `docker/test-dbs.compose.yml` | Throwaway database servers for `npm run test:engines` |

## Scripts

`npm start` · `npm run build` · `npm run build:web` · `npm test` · `npm run test:ui` · `npm run screenshots` · `npm run dev:web` · `npm run test:engines` · `npm run db:check` · `npm run db:copy` · `npm run validate -- file.json` · `npm run schema:json` · `npm run docs:tools` · `npm run sample:exports`

## Licence

Apache-2.0. Our own implementation; see [docs/CLEAN-ROOM.md](docs/CLEAN-ROOM.md).