Skip to main content
Glama
README.md
# formwire

formwire is a small local bridge to Formpaste's hosted
MCP server, which wires up contact forms for a site:
create a form, get a copy-paste snippet for your
framework with the form's access key already filled in,
check how a form is configured, and read the
submissions that land in its inbox.

The bridge stores nothing itself. It serves the
upstream server's tool list locally, exactly as
captured from the live endpoint, and forwards each
tool call upstream, returning the result untouched.
Forms belong to the caller's own Formpaste account:
a form's destination address is the owner's own
notification address, set once when the form is
created, and the test-submission tool only stores a
marked test row on the caller's own form - it sends
no email.

## Tools

- `create_form` - create a form and get back its
  access key plus a wired snippet. Required: `name`
  (a human-readable label) and `destinationEmail`
  (where submissions are emailed; a new address must
  be verified in the dashboard before delivery starts).
  Optional: `framework` (`html`, `react`, `nextjs`,
  `astro`, `vue` or `svelte`; defaults to `html`)
  choosing the snippet's shape.
- `get_snippet` - a copy-paste form snippet for a
  framework. Required: `framework`. Optional: `formId`
  fills in a real access key; without it a placeholder
  is used.
- `list_submissions` - submissions for one of your
  forms, as counts plus per-submission metadata.
  Required: `formId`. Optional: `folder` (`inbox` or
  `spam`), `limit`, and `includeContent` to include
  full message bodies.
- `list_forms` - every form on your account, each
  with its id, name, access key and inbox/spam counts.
  Takes no arguments. Use it to discover form ids.
- `get_form` - read one form back to check its
  wiring: access key, destination and whether that
  destination is verified yet, allowed domains, and
  notification, autoresponder and webhook settings.
  Required: `formId`. The webhook signing secret is
  never returned.
- `send_test_submission` - store a test submission
  on your own form to prove it is live. Required:
  `formId`. Optional: `fields`, a flat string map of
  sample values; omit it for a default payload. Test
  rows appear in the inbox with a Test badge, send
  no email, and never count toward quota.

## Configuration

- `FORMPASTE_MCP_URL` (optional) - override the
  upstream endpoint. Defaults to
  `https://api.formpaste.com/mcp`.
  (The override hook is this rebuild's own labelled
  reconstruction.)
- `FORMPASTE_API_KEY` (optional) - when set, every
  upstream request carries an
  `Authorization: Bearer <key>` header with a token
  minted in the Formpaste dashboard. When it is not
  set, no auth header is sent. (This forwarding is
  also a labelled reconstruction; the original
  surface was captured keyless.)

### Forwarding mechanics

On the first tool call the client opens a streamable
HTTP session with the upstream: a JSON-RPC
`initialize` request (protocolVersion `2025-03-26`,
clientInfo name `formwire`), then a
`notifications/initialized` notification, then the
`tools/call` request carrying the caller's arguments
unchanged. When the upstream answers `initialize`
with an `Mcp-Session-Id` header, that value rides on
every later request of the session, which is reused
for the life of the process. Replies may arrive as
plain JSON or as server-sent events; both are read.

Successful upstream results pass through verbatim,
including any `isError` flag the upstream sets.
Failures - a JSON-RPC error, a non-2xx status, an
unreadable response, or a request that cannot be
completed - come back as an `isError` result whose
text starts with `formwire error:` (this rendering
is this rebuild's own labelled reconstruction).

## CLI

Each tool is also a subcommand taking one JSON
argument string (omit it for tools that take none):

```bash
npx @reneturcios/formwire create_form '{"name":"Contact form","destinationEmail":"owner@example.com"}'
npx @reneturcios/formwire get_snippet '{"framework":"react","formId":"frm_123"}'
npx @reneturcios/formwire list_forms
npx @reneturcios/formwire get_form '{"formId":"frm_123"}'
npx @reneturcios/formwire list_submissions '{"formId":"frm_123","folder":"inbox"}'
npx @reneturcios/formwire --version
```

Exit codes: `0` on success, `1` on an `isError`
result, `2` on a usage error.

## MCP server

```bash
npx -y @reneturcios/formwire mcp
```

MCP client config:

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

## Docker

```bash
docker run -i ghcr.io/cloudcorprecords/formwire
docker run --rm ghcr.io/cloudcorprecords/formwire --version
```

The container's default command is `mcp`, so the first
form is a stdio MCP server; any other arguments reach
the CLI normally.

## Development

```bash
npm install
npm run build
npm test
npm run dev
```

The test suite runs entirely against a stubbed
JSON-RPC upstream - no live network calls.

## License

MIT - see `LICENSE`.