Skip to main content
Glama
FlareSend MCP

FlareSend MCP

by sosmongare
README.md
# flaresend-mcp

Hosted remote MCP server and multi-client agent plugin for [FlareSend](https://flaresend.com) — WhatsApp messaging API.

| Piece | What it is |
|-------|------------|
| MCP server | Streamable HTTP at `/mcp` (Cloudflare Workers; Dockerfile for Fly.io) |
| Auth | Per-request `Authorization: Bearer <instance API key>` — forwarded to FlareSend, never stored or logged |
| Plugin | `plugins/flaresend/` with Cursor, Codex, and Claude plugin manifests (Bird-style) |

API docs (documented endpoints only): [flaresend-api-documentation](https://github.com/sosmongare/flaresend-api-documentation)

**Get an API key:** FlareSend dashboard → your connected instance → copy the instance API key. That key selects the sending WhatsApp number. Do **not** put `instance_id` in message bodies.

---

## Quick start (pick your client)

| Client | What to use |
|--------|-------------|
| **Cursor Marketplace** | Install FlareSend plugin → set `FLARESEND_API_KEY` |
| **Cursor (manual)** | Settings → MCP, or `~/.cursor/mcp.json` |
| **OpenAI Codex** | `~/.codex/config.toml` with `bearer_token_env_var` (or install `.codex-plugin`) |
| **GitHub Copilot** | VS Code MCP / Copilot CLI `~/.copilot/mcp-config.json` (`type: "http"`) |
| **Claude Code** | Plugin `.claude-plugin` / HTTP MCP with Bearer header |
| **Grok Bot / Agent SDK** | Streamable HTTP URL + Bearer header |
| **MCP Inspector** | Local test: `npm run dev` → Add Servers → Streamable HTTP |

**Production URL (after deploy):** `https://mcp.flaresend.com/mcp`  
**Local URL:** `http://127.0.0.1:8787/mcp`

All of these clients talk to the **same** hosted MCP. Only the config file shape differs. There is no stdio binary.

---

## 1. Cursor Marketplace (once published)

1. Install the **FlareSend** plugin from the Cursor Marketplace.
2. Plugins → **Configure** → set `FLARESEND_API_KEY` to your instance API key.
3. The plugin’s [`plugins/flaresend/mcp.json`](plugins/flaresend/mcp.json) points at `https://mcp.flaresend.com/mcp`.
4. Start a chat and ask something like “list my FlareSend instances” or “check if 2547… is on WhatsApp”.

See [SUBMITTING.md](./SUBMITTING.md) for the publish checklist.

---

## 2. Cursor — custom MCP connector

### Option A — Cursor Settings UI

1. Cursor → **Settings** → **MCP** (or Features → MCP).
2. **Add new global MCP server** (or project server).
3. Choose **URL** / remote HTTP (not a command/stdio server).
4. URL: `https://mcp.flaresend.com/mcp` (or `http://127.0.0.1:8787/mcp` while developing).
5. Add header:
   - Name: `Authorization`
   - Value: `Bearer YOUR_INSTANCE_API_KEY`
6. Save and ensure the server shows as connected.

### Option B — `mcp.json` file

Create or edit `~/.cursor/mcp.json` (or project `.cursor/mcp.json`):

**Hosted:**

```json
{
  "mcpServers": {
    "flaresend": {
      "url": "https://mcp.flaresend.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_INSTANCE_API_KEY"
      }
    }
  }
}
```

**Local wrangler:**

```json
{
  "mcpServers": {
    "flaresend": {
      "url": "http://127.0.0.1:8787/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_INSTANCE_API_KEY"
      }
    }
  }
}
```

Restart Cursor or reload MCP if the server does not appear.

---

## 3. OpenAI Codex

Codex reads MCP from TOML (not JSON). Prefer an env var for the secret — do not paste the key into `config.toml`.

Add to `~/.codex/config.toml` (or a trusted project’s `.codex/config.toml`):

```toml
[mcp_servers.flaresend]
url = "https://mcp.flaresend.com/mcp"
bearer_token_env_var = "FLARESEND_API_KEY"
```

Then export the key in your shell (or OS env):

```bash
export FLARESEND_API_KEY="your-instance-api-key"
```

Local server while developing:

```toml
[mcp_servers.flaresend]
url = "http://127.0.0.1:8787/mcp"
bearer_token_env_var = "FLARESEND_API_KEY"
```

Optional plugin shim for Codex-style installs: [`plugins/flaresend/.codex-plugin/plugin.json`](plugins/flaresend/.codex-plugin/plugin.json) + [`.mcp.json`](plugins/flaresend/.mcp.json).

CLI alternative (if your Codex build supports it):

```bash
codex mcp add flaresend --url https://mcp.flaresend.com/mcp
# then set bearer_token_env_var / FLARESEND_API_KEY as above
```

---

## 4. GitHub Copilot (VS Code + Copilot CLI)

### Copilot CLI

`~/.copilot/mcp-config.json` (or project `.mcp.json` / `.github/mcp.json`):

```json
{
  "mcpServers": {
    "flaresend": {
      "type": "http",
      "url": "https://mcp.flaresend.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_INSTANCE_API_KEY"
      },
      "tools": ["*"]
    }
  }
}
```

Or interactively:

```bash
copilot mcp add --transport http \
  --header "Authorization: Bearer YOUR_INSTANCE_API_KEY" \
  flaresend https://mcp.flaresend.com/mcp
```

### VS Code / Copilot Chat Agent mode

Add a remote HTTP MCP server (VS Code 1.101+). Editor-managed config often uses a top-level `servers` object:

```json
{
  "servers": {
    "flaresend": {
      "type": "http",
      "url": "https://mcp.flaresend.com/mcp",
      "headers": {
        "Authorization": "Bearer ${input:flaresend_api_key}"
      }
    }
  },
  "inputs": [
    {
      "type": "promptString",
      "id": "flaresend_api_key",
      "description": "FlareSend instance API key",
      "password": true
    }
  ]
}
```

Exact file location varies (`mcp.json` in the user profile or workspace). Prefer `${input:…}` or env substitution so the key is not committed.

---

## 5. Claude Code

Plugin manifest: [`plugins/flaresend/.claude-plugin/plugin.json`](plugins/flaresend/.claude-plugin/plugin.json).

Or add an HTTP MCP server with:

```json
{
  "mcpServers": {
    "flaresend": {
      "type": "http",
      "url": "https://mcp.flaresend.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_INSTANCE_API_KEY"
      }
    }
  }
}
```

Set `FLARESEND_API_KEY` in the environment if your Claude host expands `${FLARESEND_API_KEY}`.

---

## 6. Grok Bot / Agent SDK / other Streamable HTTP clients

Same idea: **URL + Authorization header**. No stdio binary.

```json
{
  "mcpServers": {
    "flaresend": {
      "type": "streamable-http",
      "url": "https://mcp.flaresend.com/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_INSTANCE_API_KEY"
      }
    }
  }
}
```

Some UIs omit `type` and only need `url` + `headers` — that is fine.

**Inbound WhatsApp → Grok Bot:** FlareSend webhooks cannot set custom headers. Use the optional relay in [`relay/`](./relay/) (see [DEPLOY.md](./DEPLOY.md)).

---

## 7. Test with MCP Inspector (recommended before deploy)

Do **not** open `http://127.0.0.1:8787/mcp` in a normal browser — you will get `401`. That URL is only for MCP clients.

### Terminals

```bash
# Terminal 1 — MCP server
cd flaresend-mcp
npm install
npm run dev
# Ready on http://127.0.0.1:8787

# Terminal 2 — Inspector UI
npx @modelcontextprotocol/inspector
```

### In the Inspector UI

1. Click **Add Servers**.
2. Transport: **Streamable HTTP** (not Standard I/O).
3. Name: `flaresend`
4. URL: `http://127.0.0.1:8787/mcp`
5. Auth / Custom Headers — enable:
   - Name: `Authorization`
   - Value: `Bearer YOUR_INSTANCE_API_KEY` (include `Bearer` and a space)
6. Save → turn the server **Connected**.
7. Open the **Tools** tab → pick a tool → fill fields (or **Edit as JSON**) → **Execute Tool**.

You should see `initialize` and `tools/list` as **OK** in Messages.

### Safe tools to try first

| Tool | Example input |
|------|----------------|
| `list_instances` | `{}` |
| `check_number` | `{ "number": "254712345678" }` |
| `get_instance_status` | `{ "instanceId": "<uuid from list_instances>" }` |

`send_message` example (only to opted-in numbers):

```json
{
  "recipients": ["254712345678"],
  "type": "text",
  "text": "Hello from FlareSend MCP"
}
```

### Local auth shortcut

If Inspector keeps dropping headers, create `.dev.vars` (gitignored):

```bash
cp .dev.vars.example .dev.vars
# set FLARESEND_API_KEY=...
```

Restart `npm run dev`. **Do not** set `FLARESEND_API_KEY` on the production Worker — production callers must send their own Bearer token.

---

## Tools

**Messaging / instances:** `send_message`, `check_number`, `schedule_message`, `list_scheduled_messages`, `update_scheduled_message`, `cancel_scheduled_message`, `list_instances`, `get_instance`, `get_instance_status`, `reconnect_instance`, `health`

**Groups (Pro+):** `create_group`, `list_groups`, `get_group`, `get_group_invite_link`, `send_group_message`, `manage_group_participants`

**Channels (Pro+):** `create_channel`, `get_channel`, `update_channel`, `resolve_channel_invite`, `send_channel_message`, `follow_channel`, `unfollow_channel`

Phone numbers: international digits only (no `+`). The server strips `+`, spaces, and dashes.

Media: `text` | `image` | `video` | `audio` | `document` via `url` or `fileBase64` + `fileName` + `mimeType`.

---

## Safety

- Message only opted-in recipients; honour STOP
- Always show a draft and get approval before sending
- New numbers: ramp up from ~20–30 messages/day
- Agent guidance: [`plugins/flaresend/skills/flaresend-whatsapp/SKILL.md`](plugins/flaresend/skills/flaresend-whatsapp/SKILL.md)

---

## Develop / deploy

```bash
npm test          # unit tests (mocked fetch)
npm run typecheck
npm run deploy    # Cloudflare Worker
```

Full deploy (custom domain, relay secrets, Fly.io): [DEPLOY.md](./DEPLOY.md)

| Script | Purpose |
|--------|---------|
| `npm run dev` | Local MCP Worker |
| `npm test` | Vitest |
| `npm run typecheck` | TypeScript |
| `npm run deploy` | Deploy MCP Worker |
| `npm run deploy:relay` | Deploy webhook relay |
| `npm run fly:build` | Docker image for Fly.io |

---

## License

MIT — see [LICENSE](./LICENSE).