api-glue-mcp
by nahianakhtar
README.md
# api-glue-mcp
[](LICENSE)
[](package.json)
[](package.json)
A guardrailed **TypeScript MCP v2 (`@modelcontextprotocol/server@2.4.0`) stdio server** and **deterministic webhook/API-glue CLI (`api-glue`)** engineered as a self-hosted replacement for brittle Zapier/Make webhook chains. Built on Node.js 22 native `node:sqlite` (`WAL` mode) and `zod@4.6.7`.
---
## Problem Solved
- **Idempotent Webhook Ingestion**: Stores processed `eventId` keys and SHA-256 payload digests in embedded SQLite WAL so duplicate webhook deliveries return `deduplicated` with zero duplicate side effects.
- **Deterministic Pre-Action Guardrails**: Verifies HMAC-SHA256 signatures (`crypto.timingSafeEqual`) with `±300s` replay protection, blocks SSRF (`http://`, loopback, RFC 1918, `169.254.169.254`, `::1`, embedded credentials) and unallowlisted hosts, and defaults to dry-run unless both `--allow-dispatch` and `apply=true` are set.
- **Resilient Retry, Backoff & Dead-Letter Queue**: Honors `Retry-After` headers on HTTP `429`/`503`, applies deterministic exponential backoff, opens a circuit breaker after consecutive failures, captures failures in SQLite `dlq_events`, and supports controlled DLQ replay.
- **Secret-Scrubbed Audit Trail**: Appends every verification, dry-run, denial, dispatch, and DLQ event to JSONL (`JsonlAuditLog`) while redacting API keys, Bearer tokens, and email addresses.
---
## Architecture & Tools
| Surface | Name | Role |
| :--- | :--- | :--- |
| **MCP Tool** | `verify_webhook_signature` | Constant-time HMAC-SHA256 + timestamp skew verification (`readOnlyHint: true`) |
| **MCP Tool** | `ingest_event` | Schema validation, SSRF/allowlist check, SQLite deduplication, dry-run/dispatch |
| **MCP Tool** | `list_dlq` | Inspect pending Dead-Letter Queue entries (`readOnlyHint: true`) |
| **MCP Tool** | `audit_tail` | Read last `N` redacted JSONL audit records (`readOnlyHint: true`) |
| **CLI** | `api-glue` | `verify`, `ingest`, `replay-dlq`, `audit-tail`, and `serve` (MCP stdio) |
---
## 30-Second Quickstart
```bash
pnpm install --frozen-lockfile
pnpm run typecheck
pnpm run build
pnpm test
```
### Sample CLI Usage
```bash
# 1. Dry-run preview (default safe mode: zero outbound HTTP calls)
node --no-warnings dist/cli.js ingest \
--db ./.api-glue/ledger.sqlite \
--payload ./event.json \
--target https://hooks.example.com/ingest \
--allow-host hooks.example.com
# 2. Start MCP v2 stdio server (clean JSON-RPC stdout; dry-run unless --allow-dispatch)
node --no-warnings dist/cli.js serve \
--db ./.api-glue/ledger.sqlite \
--allow-host hooks.example.com
```
---
## Verified Local Checks
| Command | Scope | Verified Result |
| :--- | :--- | :--- |
| `pnpm run typecheck` | TypeScript `7.0.2` strict check | `0` errors |
| `pnpm run build` | `dist/` ESM + `.d.ts` build | Exits `0` |
| `pnpm test` | Offline `node --test` (HMAC, SSRF, SQLite WAL, 429/DLQ, CLI, `InMemoryTransport`, stdio smoke) | `8 passed`, `0 failed` |
---
## License
Released under the [MIT License](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues