Maple
A unified MCP server providing observability, safety control, and behavior evolution for high-agency AI agents through tracing, replaying, and auditing. It features real-time firewall guardrails and ML-driven anomaly detection to monitor, block, or fork agent actions based on risk.
README
Maple
Unified MCP server for agent observability, safety control, and behavior evolution.
Maple is the "Sentry + Git" layer for high-agency agents:
- Observe every step
- Replay/fork risky branches
- Audit and intervene with guardrails
- Learn from anonymized traces to evolve safer skills
Built with mcp-use + Apps SDK widgets.
What Is Implemented
1) Observability + Control
observe_session: capture and render timeline widgetreplay_fork: branch from any step and simulate forwardaudit_risk: rule + anomaly risk dashboardguard_action: allow/block/pending with quarantine supportingest_session_event: stream external bridge events into active trace
2) ML Anomaly Detection (Simple Embeddings)
ml_anomaly_report: embedding-based behavior outlier detection- Lightweight hash embeddings + cosine similarity baseline
- Supports community baseline from anonymized shared traces
3) Network Effects
share_trace_anon: anonymize and publish trace patterns to shared poolsuggest_evolved_skills: generate evolved skill suggestions from shared traces- Behavior signatures + shared dataset create compound data advantage
4) YC App Layer (Moat / Traction / Revenue)
yc_app_brief: live YC-ready narrative generated from product metrics- Emphasizes:
- Moat: trace + fork + risk label data flywheel
- Traction: OpenClaw integration and safety intervention activity
- Revenue: freemium ladder (Free, Pro $9, Team $29, Enterprise $99)
MCP Tools
observe_sessionreplay_forkaudit_riskml_anomaly_reportguard_actioningest_session_eventshare_trace_anonsuggest_evolved_skillsyc_app_brieflist_tracesexport_trace
API Endpoints
GET /healthGET /judge(judge standalone page)GET /api/tracesGET /api/traces/:traceIdGET /api/community/statsGET /api/community/tracesGET /api/yc/brief?focus=full|moat|traction|revenueGET /api/firewall/statePOST /api/firewall/chatPOST /api/firewall/decision(strict pre-execution allow/block gate)
Key Project Files
index.ts: tool + route orchestrationsrc/core/risk-engine.ts: rule engine + embedding anomaly integrationsrc/ml/embeddings.ts: simple embedding implementationsrc/ml/anomaly-detector.ts: cosine-sim anomaly detectionsrc/network/anonymizer.ts: anonymized trace transformationsrc/network/shared-trace-store.ts: community pool + skill suggestionssrc/strategy/yc-narrative.ts: moat/traction/revenue narrative builderresources/trace-timeline/widget.tsxresources/replay-simulator/widget.tsxresources/risk-dashboard/widget.tsx
Quick Start
npm install
npm run dev
Inspector: http://localhost:3000/inspector
Hardcoded Demo Stack (OpenClaw + Maple)
This repo now includes a one-command hardcoded demo setup:
- OpenClaw gateway on
ws://127.0.0.1:19001 - OpenClaw bridge adapter on
http://127.0.0.1:8787 - Maple API key generated at startup (or provided via env)
- Bridge token generated at startup (or provided via env)
OPENCLAW_VERSION=<pin-a-version> npm run demo:install-openclaw
npm run demo:up
Then open:
- Judge GUI:
http://localhost:3000/judge - Inspector:
http://localhost:3000/inspector
Guided Demo Mode (No Manual JSON)
The Judge GUI now has Guided Demo Controls so you can run the full flow without Inspector copy/paste:
- Enter API key and click
Connect - Click
Run Full Flow
Or step through:
1) Start2) Audit3) Block4) Fork
Judge page now includes Firewall Chat in Control view:
- Ask natural-language questions ("status update", "why blocked?", "what should we do next?")
- Chat replies are generated from live firewall context (
/api/firewall/state)
This uses internal demo APIs:
POST /api/demo/startPOST /api/demo/auditPOST /api/demo/blockPOST /api/demo/forkPOST /api/demo/full
demo:up also auto-opens both pages on macOS (set DEMO_OPEN_BROWSER=0 to disable).
Single-Trace Agent Action Logging (Hackathon)
For a reliable judge demo, run one stable trace and append every action to it.
MAPLE_API_KEY=local-demo-key npm run trace:demo
What this does:
- Starts (or reuses) one trace for a stable
sessionId - Logs all agent actions through
POST /api/openclaw/eventsusing the sametraceId - Includes
type,actor,prompt/message,command,url,toolName, and uniqueeventId - Runs a preflight firewall preview and logs Maple's block/allow message into the same trace
Open http://localhost:3000/judge, then select the printed trace ID to see #0, #1, #2....
If you want to integrate this into your own runtime, use:
scripts/maple-trace-logger.mjslogAction(...)for generic eventslogWebGet(...),logMarketplaceSearch(...),logMarketplaceToolCall(...)wrappers
Example:
import { createMapleTraceLogger } from "./scripts/maple-trace-logger.mjs";
const logger = createMapleTraceLogger({
baseUrl: "http://localhost:3000",
apiKey: process.env.MAPLE_API_KEY,
sessionId: "maple-live",
});
await logger.startRun({ reuseLatest: true });
await logger.logAction({
type: "tool_call",
actor: "agent",
toolName: "web_get",
prompt: "Fetch provider docs",
url: "https://docs.mcp.so/providers",
});
Hackathon Gateway Mode (9 Curated MCP Tools)
Canonical startup (local + Railway) for single-source hackathon routing:
npm start
Equivalent local alias:
npm run hackathon:up
This starts a local downstream MCP app (toolhub) and route-locks Maple so all downstream calls go through it.
Marketplace mode is canonically disabled in this build; execution only routes through cleared downstream apps.
Included tools (diverse coverage):
web_search(general web search)web_fetch(browser-style page fetch/extraction)wikipedia_summary(encyclopedia knowledge)github_repo_info(code/repo intelligence)weather_forecast(real-time practical data)slack_post_message(messaging integration via Slack)hn_search(live tech/news discovery on Hacker News)arxiv_search(academic/research paper search)openlibrary_search(books and publication lookup)
Slack config for slack_post_message:
- Incoming webhook mode: set
SLACK_WEBHOOK_URL - Bot mode: set
SLACK_BOT_TOKENand optionallySLACK_DEFAULT_CHANNEL
Verify wiring end-to-end:
npm run hackathon:verify
Stop services:
npm run hackathon:down
Implementation files:
scripts/hackathon-toolhub.mjs(downstream MCP server with 9 tools)scripts/hackathon-up.sh(starts toolhub + Maple in deterministic route-lock mode)scripts/hackathon-verify.sh(smoke tests for routed tool calls through Maple)scripts/hackathon-down.sh(stops Maple + toolhub)
Stop local demo processes:
npm run demo:down
Environment
MCP_URL=http://localhost:3000
OPENCLAW_BRIDGE_URL=http://localhost:8787
OPENCLAW_BRIDGE_TOKEN=your_token
MAPLE_API_KEY=your_long_random_key
MAPLE_LOCK_BRIDGE_TARGET=true
observe_session falls back to mock only when source=auto.
For source=openclaw, bridge failures are returned as errors (no silent mock downgrade).
API Key Auth
- Auth methods:
x-api-key: <key>orAuthorization: Bearer <key> - Protected surfaces: MCP endpoints (
/mcp,/sse) and internal APIs (/api/*) - Auth is fail-closed by default. Set
MAPLE_API_KEYorMAPLE_API_KEYS. - Optional local-only bypass:
MAPLE_ALLOW_NO_AUTH=true(not recommended). GET /healthremains public for deployment health checks
Bridge Lockdown (Maple-First Routing)
- Set
MAPLE_LOCK_BRIDGE_TARGET=trueto deny per-requestbridgeUrl/tokenoverrides. - Bridge override is denied by default.
- Optional local-only override:
MAPLE_ALLOW_BRIDGE_OVERRIDE=true. - In production, bridge override lock is enabled automatically.
- In production,
OPENCLAW_BRIDGE_URLandOPENCLAW_BRIDGE_TOKENmust be explicitly set. - This forces all OpenClaw bridge traffic through configured
OPENCLAW_BRIDGE_URL+OPENCLAW_BRIDGE_TOKEN. - Override attempts return
403 Bridge override denied.
Pre-Execution Firewall Decision API
POST /api/firewall/decisionevaluates a candidate action before execution.enforce=true(default): persist decision into trace and quarantine on deny.enforce=false: preview mode (no trace mutation), useful for dry-run checks.
Firewall Status Chat API
GET /api/firewall/statereturns normalized live firewall context for a trace/session.POST /api/firewall/chatanswers status questions using that context.- Body accepts
message, optionaltraceId/sessionId, andincludeContext. POST /api/chat/streampowers the Judge UI chatbot and can use AI with provider fallback.- If
OPENAI_API_KEYand/orANTHROPIC_API_KEYare set, Maple enables AI mode with automatic fallback. - If both model providers fail, Maple falls back to deterministic rules-based firewall answers.
Optional chat model environment variables:
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
MAPLE_FIREWALL_CHAT_PRIMARY=openai # openai | anthropic
MAPLE_FIREWALL_CHAT_OPENAI_MODEL=gpt-4o-mini
MAPLE_FIREWALL_CHAT_ANTHROPIC_MODEL=claude-sonnet-4-6
MAPLE_FIREWALL_CHAT_TIMEOUT_MS=15000
Firewall Hardening (mcpwall-inspired)
Maple now enforces deterministic firewall policy checks on every trace step before risk scoring:
- First-match rules for high-risk behavior (
pipe-to-shell, destructive commands, credential/secret access) - Secret scanning + in-place redaction with marker:
[REDACTED BY MAPLE] - Automatic quarantine (
guardStatus=block) when deny rules hit - JSONL firewall audit logs at
~/.maple/firewall-logs/YYYY-MM-DD.jsonl
Optional environment variables:
MAPLE_FIREWALL_ENABLED=true
MAPLE_FIREWALL_DEFAULT_ACTION=allow # allow | deny | log_only
MAPLE_FIREWALL_LOG_DIR=~/.maple/firewall-logs
Demo Script (2-3 min)
observe_sessionon an OpenClaw sessionaudit_riskto surface risky stepsml_anomaly_reportto show embedding anomaliesguard_actionblock a risky stepreplay_forkfrom blocked step with safe editsshare_trace_anonto publish anonymized patternsuggest_evolved_skillsfrom community datayc_app_briefto show moat/traction/revenue narrative
Example Calls
{
"tool": "ml_anomaly_report",
"input": {
"traceId": "<trace-id>",
"useCommunityBaseline": true,
"threshold": 0.58,
"topAnomalies": 5
}
}
{
"tool": "share_trace_anon",
"input": {
"traceId": "<trace-id>",
"taskLabel": "Inbox triage",
"objective": "Safely automate inbound support triage",
"tags": ["support", "email", "guarded"]
}
}
{
"tool": "suggest_evolved_skills",
"input": {
"query": "safe inbox triage automation",
"limit": 3,
"minConfidence": 0.4
}
}
Current Limits
- Persistence is in-memory for hackathon speed
- Embedding model is intentionally simple (fast + local)
- External model providers are optional for firewall chat; rules mode works without them
Deploy
npm run deploy
Railway Deployment (Recommended)
Yes, Maple can run on Railway with production safeguards.
This repo now includes railway.json, so Railway can use canonical settings automatically:
- Build command:
npm run build - Start command:
npm run start - Health check path:
/health
Required environment variables:
NODE_ENV=production
HOST=0.0.0.0
MCP_URL=https://<your-railway-domain>
MAPLE_API_KEY=<long-random-key>
MAPLE_LOCK_BRIDGE_TARGET=true
OPENCLAW_BRIDGE_URL=<bridge-url-reachable-from-railway>
OPENCLAW_BRIDGE_TOKEN=<bridge-token>
MAPLE_FIREWALL_ENABLED=true
Important notes:
- Railway provides
PORTautomatically; do not hardcode it. scripts/hackathon-start.shis Railway-safe and no longer requires a local.envfile to boot.- In production, Maple enforces API key auth and requires explicit
OPENCLAW_BRIDGE_URL+OPENCLAW_BRIDGE_TOKEN. - Do not use
localhostforOPENCLAW_BRIDGE_URLunless the bridge runs in the same container. - If bridge connectivity is unavailable during demo, use
source=mockto keep UI + guardrail flow live.
Recommended Servers
playwright-mcp
A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.
Magic Component Platform (MCP)
An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.
Audiense Insights MCP Server
Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.
VeyraX MCP
Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.
graphlit-mcp-server
The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.
Kagi MCP Server
An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.
E2B
Using MCP to run code via e2b.
Neon Database
MCP server for interacting with Neon Management API and databases
Exa Search
A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.
Qdrant Server
This repository is an example of how to create a MCP server for Qdrant, a vector search engine.