Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

docs: correct README's MCP posture and Swagger availability

Yudhi Armyndharisc887d1884604
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5bb52ffb9..3b5f529f7 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed
+- README no longer inverts the shipped MCP posture. It described `MCP_ENABLED=true` as exposing 51 tools including messaging, when the surface is read-only unless `MCP_READONLY=false` — a secure default the code chose deliberately — so an operator wired a client, saw no send or group tools, and had nothing in README pointing at the knob. It now states the 25 read-only tools mounted by default and names the opt-in for all 51. A gate derives both counts from the tool sources, so a tier change fails instead of making the prose wrong again.
+- README's Ports table no longer publishes Swagger unconditionally. The documented production command produces a deployment where `/api/docs` returns 404, and SECURITY.md separately tells operators to review `ENABLE_SWAGGER`, so the two published documents disagreed. The row now states the condition.
+
- `POST /api/infra/storage/import` now publishes its request body as a schema instead of `{"type":"string"}`. A description-only `@ApiBody` has nothing to infer the DTO from, so the contract told every generated client the body was a bare string while the handler took an object — the only one of the document's 83 JSON request bodies in that state, and `openapi:check` passed on it because the snapshot was self-consistent, just wrong. A gate now rejects any JSON request body published as a bare primitive.
- Baileys group metadata now uses the phone-dialect twins the payload already carries (`ownerPn`, `participants[].phoneNumber`). Reading only the LID left `owner` and `participants[].id` as `<lid>@lid`, made `number` the LID digits presented as a phone number, and reported `isAdmin: false` for groups the account actually administers — ids that then failed to join against the `@c.us` the same session's contacts and message webhooks emit for the same person. It was only correct once the lid→phone mapping had been learned; the twin is available immediately. Where WhatsApp withholds the twin, as it does for non-contacts, the previous behaviour stands.
diff --git a/README.md b/README.md
index cc0784c16..9635af7e0 100644
--- a/README.md
+++ b/README.md
@@ -262,11 +262,11 @@ docker compose --profile full up -d
## 🔌 Ports
-| Service | Port | Description |
-| --------------- | --------------- | ----------------------------------------------- |
-| API & Dashboard | `2785` | REST API + bundled web dashboard (same port) |
-| Swagger | `2785/api/docs` | Interactive API docs |
-| Dashboard (dev) | `2886` | Vite dev server with hot reload (`npm run dev`) |
+| Service | Port | Description |
+| --------------- | --------------- | ----------------------------------------------------------------------------------- |
+| API & Dashboard | `2785` | REST API + bundled web dashboard (same port) |
+| Swagger | `2785/api/docs` | Interactive API docs — off under `NODE_ENV=production` unless `ENABLE_SWAGGER=true` |
+| Dashboard (dev) | `2886` | Vite dev server with hot reload (`npm run dev`) |
---
@@ -327,7 +327,7 @@ curl -X POST http://localhost:2785/api/sessions/{sessionId}/webhooks \
OpenWA can expose a **curated set of tools over the [Model Context Protocol](https://modelcontextprotocol.io)** so AI agents (Claude, Cursor, …) can drive WhatsApp. It is **off by default** and **additive** — every REST route keeps working unchanged.
-Set `MCP_ENABLED=true` to mount a stateless Streamable-HTTP transport at **`POST /mcp`** on the existing server (same port, no extra process). It exposes 51 curated tools (sessions, messaging, contacts, basic group ops, webhook reads, labels, automation-rule reads) — a focused surface rather than the full API, so agents aren't overwhelmed and destructive operations stay off the agent path.
+Set `MCP_ENABLED=true` to mount a stateless Streamable-HTTP transport at **`POST /mcp`** on the existing server (same port, no extra process). It mounts **25 read-only tools** by default — session, message, contact, group, webhook, label and automation-rule _reads_ — because the surface is read-only unless you opt out. Add `MCP_READONLY=false` to mount all **51 tools**, adding the write tier (send, reply, group operations). Either way it is a focused surface rather than the full API, so agents aren't overwhelmed.
```bash
MCP_ENABLED=true npm run start:prod # or set MCP_ENABLED in your .env / compose
diff --git a/src/modules/mcp/docs-readme-mcp.spec.ts b/src/modules/mcp/docs-readme-mcp.spec.ts
new file mode 100644
index 000000000..6d9387efa
--- /dev/null
+++ b/src/modules/mcp/docs-readme-mcp.spec.ts
@@ -0,0 +1,63 @@
+import * as fs from 'fs';
+import * as path from 'path';
+import { resolveMcpReadOnly } from './mcp.server';
+
+/**
+ * README described the MCP surface as write-enabled by default and never mentioned the knob that
+ * enables it. `resolveMcpReadOnly` defaults to READ-ONLY unless `MCP_READONLY` is the literal
+ * string 'false' — the secure default a code comment says was deliberately chosen — so an operator
+ * following README wired a client, saw no send/reply/group tools, and had nothing in README to point
+ * them at. In the other direction it misstated the shipped security posture.
+ *
+ * The counts are derived from the tool sources here, so a tier change fails this instead of quietly
+ * making the prose wrong again.
+ */
+const repoRoot = path.join(__dirname, '..', '..', '..');
+const readme = fs.readFileSync(path.join(repoRoot, 'README.md'), 'utf8');
+
+function tierCounts(): { read: number; write: number } {
+ const dir = path.join(repoRoot, 'src', 'core', 'agent-tools', 'tools');
+ let read = 0;
+ let write = 0;
+ for (const file of fs.readdirSync(dir).filter(f => f.endsWith('.tools.ts'))) {
+ const src = fs.readFileSync(path.join(dir, file), 'utf8');
+ read += (src.match(/tier:\s*'read'/g) ?? []).length;
+ write += (src.match(/tier:\s*'write'/g) ?? []).length;
+ }
+ return { read, write };
+}
+
+describe('README describes the MCP surface the code actually mounts', () => {
+ // Guards the counts below: an extractor that matched nothing would make every assertion vacuous.
+ it('counts both tiers from the tool sources', () => {
+ const { read, write } = tierCounts();
+ expect(read).toBeGreaterThan(0);
+ expect(write).toBeGreaterThan(0);
+ });
+
+ it('mounts read-only unless MCP_READONLY is explicitly "false"', () => {
+ const prev = process.env.MCP_READONLY;
+ try {
+ delete process.env.MCP_READONLY;
+ expect(resolveMcpReadOnly()).toBe(true);
+ process.env.MCP_READONLY = 'true';
+ expect(resolveMcpReadOnly()).toBe(true);
+ process.env.MCP_READONLY = 'false';
+ expect(resolveMcpReadOnly()).toBe(false);
+ } finally {
+ if (prev === undefined) delete process.env.MCP_READONLY;
+ else process.env.MCP_READONLY = prev;
+ }
+ });
+
+ it('states the DEFAULT tool count, not just the total', () => {
+ const { read } = tierCounts();
+ expect(readme).toContain(`${read} read-only tools`);
+ });
+
+ it('names the knob that unlocks the write tier', () => {
+ const { read, write } = tierCounts();
+ expect(readme).toContain('MCP_READONLY=false');
+ expect(readme).toContain(`${read + write} tools`);
+ });
+});