mcp-kit
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
{tremen.dev} / mcp-kit — Production-Grade Stateless MCP Reference Server
B2B Operations & CRM Connector over PostgreSQL
Built by{tremen.dev}as an open-source reference architecture for secure, auditable, cost-optimized internal AI agents.
Most MCP demos break the moment they leave stdio on a laptop. This repository demonstrates what companies actually pay to put into production: a stateless Streamable HTTP MCP server (2026-07-28 gateway headers, zero session state), OAuth 2.1 / JWT audience enforcement (blocking token passthrough), explicit human confirmation on write actions, kill switches & rate limiting, EU AI Act Art. 12 structured audit logging, and compact tool schemas that cut LLM token bills by ~89%.
Architecture
flowchart LR
Client["Claude / AI Agent"] -->|"POST /mcp (Bearer JWT + Mcp-Protocol-Version)"| Gateway["Express Gateway & AuthZ (jose JWT + aud check)"]
Gateway -->|"Mcp-Method / Mcp-Name"| Transport["Stateless StreamableHTTPServerTransport"]
Transport --> Policy["Policy Layer: KillSwitch + RateLimiter + Scope + WriteConsent"]
Policy -->|"Parameterized Queries Only (No Raw SQL)"| Repo["CrmRepository (PostgreSQL / Memory)"]
Policy -->|"100% NDJSON Trail"| Audit["EU AI Act Art. 12 AuditLogger"]Key Production Guarantees
Stateless Streamable HTTP (
2026-07-28): No Redis or sticky sessions required (sessionIdGenerator: undefined). ExposesMcp-Protocol-Version,Mcp-Method, andMcp-Nameheaders so API gateways can route, rate-limit, and audit without parsing JSON-RPC bodies.Zero Token Passthrough: Rejects any JWT whose
audclaim does not matchJWT_AUDIENCE(403 denied_audience) and enforces per-tool OAuth scopes (read:crm,write:billing).Read-Generous / Write-Strict Policy: 5 parameterized read tools vs. 1 strictly guarded write tool (
issue_credit_memo) that requiresconfirm_write=true, an explicit humanconfirmation_token, a single-action EUR cap, and anidempotency_key.Kill Switches & Loop Protection: Instant disablement per tool (
KILL_SWITCH_TOOLS) or per user (KILL_SWITCH_USERS), plus sliding-window rate limiting per(user_id, tool).100% Audit Coverage: Every allowed, denied, and errored call emits sanitized JSON logs (
timestamp,request_id,user_id,agent_id,protocol_version,mcp_method,tool,args_sanitized,decision,status,error_code,latency_ms).
Related MCP server: Safe DB Gateway
Narrow Tool Surface (6 Business Tools, 0 Raw SQL)
Tool | Type | Required Scope | Purpose |
| Read |
| Account profile, primary contact, open tickets, overdue EUR, recent orders |
| Read |
| Filtered account search ( |
| Read |
| Unresolved support tickets ordered by priority and |
| Read |
| Order fulfillment status, tracking code, and line items |
| Read |
| Invoices and net outstanding/overdue balances |
| Write |
| Controlled credit memo with explicit confirmation token, EUR cap, and idempotency |
Quickstart (60 Seconds, Zero External Dependencies)
git clone https://github.com/tremen-dev/mcp-kit.git
cd mcp-kit
npm install
npm test
npm run devGenerate demo JWTs (READ_ONLY_TOKEN, WRITE_TOKEN, WRONG_AUDIENCE_TOKEN):
npm run mint-tokensRun the live token-cost benchmark (mcp-kit 6 compact schemas + Prompt Caching + 70/30 Sonnet/Haiku routing vs. a bloated 40-tool CRUD server):
npm run benchmarkMeasured output (Nov 2026 Anthropic API rates, 10 users × 15 queries/day = 3,300 queries/month):
Configuration | Tools | Schema Tokens / Turn | Projected Monthly Spend |
Naive 40-tool CRUD (Sonnet 5.5, no cache) | 40 | ~19,751 | $487.10 / mo |
| 6 | ~1,589 | $41.63 / mo (-91.5% · $5,345.59/yr saved) |
Full PostgreSQL Deployment (Docker Compose)
docker compose up --buildThis provisions PostgreSQL 16 seeded with 100% synthetic B2B data (db/init.sql) and runs the MCP server in STORAGE_MODE=postgres on http://localhost:3080/mcp.
Endpoints & Live Verification
POST /mcp— Stateless JSON-RPC MCP endpoint (tools/list,tools/call)GET /health— Health & active storage modeGET /metrics/summary— Live tool calls, average latency, error rate, and audit coverage (100%)
Production Runbook (Summary)
Secret rotation: Rotate
JWT_SECRET(or swap to JWKS public key verification insrc/security/auth.ts) without restarting stateful sessions because the server is stateless.Incident response: Add a misbehaving tool or user to
KILL_SWITCH_TOOLS/KILL_SWITCH_USERSto immediately block execution while keeping other tools live.Client API billing: Always connect the client's agent runtime to the client's own LLM API account with spend caps enabled.
Need a custom, production-ready MCP connector for your internal CRM, ERP, or PostgreSQL database? Reach out via tremen.dev/mcp (hola@tremen.dev).
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Connect AI to store orders, products and inventory with scoped access and human approvals.
Read-only access to a company's ERP for Claude, ChatGPT and Gemini, with OAuth and an audit trail.
Deterministic safety, correctness & cost gate that vets Postgres SQL before your AI agent runs it.
Related MCP Servers
- FlicenseNot gradedqualityCmaintenanceEnables AI agents to investigate incidents by safely querying PostgreSQL, triaging GitHub issues, retrieving ERP order data, and sending Slack alerts, with AST-validated SQL and human-in-the-loop safeguards.-
- AlicenseAqualityBmaintenanceEnables AI agents to query PostgreSQL databases securely with read-only defaults, PII masking, rate limiting, and human-approved, expiring mutation tokens.91Apache 2.0
- AlicenseAqualityBmaintenanceEnables AI agents to safely explore PostgreSQL schemas, run guarded read-only queries, inspect plans and performance, and perform approved writes across PostgreSQL 9.6–19 with human approval for production changes.50MIT
- AlicenseAqualityCmaintenanceEnables AI agents to explore PostgreSQL schemas, run read-only SQL, inspect query plans and live database diagnostics, and optionally perform governed inserts, updates, and admin operations. Ships with layered access modes, schema allowlists, row caps, secret redaction, and human-approved destructive actions so changes stay safe by default.12MIT