A2A Agent Invention: A self-aware AI agent with dual MCP servers, Zero-Trust security, and a RAG feedback loop powered by MotherBrain.app (native MacOS app) MCP Tools, Multi-Vector Architecure Memory, and an Obsidian knowledge base #2055
native-apps
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
We built something different...
Mother is our production AI agent — deployed from Mother Brain's A2A Agent Invention, a plugin for motherbrain.app. She lives on Cloudflare's global edge, speaks the A2A Protocol fluently, and connects to two independent MCP servers powered by Mother Brain's core, giving her 40 live tools. She serves three roles simultaneously — website onboarding guide, in-app support agent, and A2A integration partner for external AI clients like ChatGPT, Gemini, and Claude.
This isn't locked to our brand. The A2A Agent Invention is universal — any Mother Brain license owner can deploy their own agent. Add a Sub-Agent user, name it whatever you want, point it at your own Markdown knowledge base (like an Obsidian vault), and generate skills from that knowledge. Your agent, your identity, your domain — running on the same infrastructure.
Try ours live: a2a.motherbrain.app | Open source invention: github.com/native-apps/a2a-agent-invention | Powered by: motherbrain.app
But what makes her genuinely different isn't the tool count or the protocol compliance. It's the feedback loop.
Mother doesn't just answer questions. Every conversation she has — every visitor question on the website, every support ticket from the desktop app, every A2A message from an external agent — feeds back into a vectorized Obsidian knowledge base via Mother Brain. Owners can curate conversations into memories through the CRM dashboard — tagging support questions, bug reports, and feature requests that make the agent smarter over time. When the next visitor asks a similar question, Mother already knows the answer.
This is a living RAG loop — conversations improve the knowledge base, and the knowledge base improves conversations. (Note: The CRM-to-memory pipeline is currently manual — owners curate. Automated curation is on the roadmap.)
TL;DR
How It Uses the A2A Protocol
The agent is fully A2A Protocol v1.0 compliant, built on JSON-RPC 2.0 over HTTPS.
JSON-RPC Methods
ping{ status: "ok" }message/sendtasks/gettasks/canceltasks/getArtifactsvisitor/suggestionsvisitor/historyagent/suggest-skillsagent/getCard/.well-known/agent.json)Agent Card (
/.well-known/agent.json)The Agent Card is dynamically generated from Worker env vars — each deployment gets its own identity:
streaming: true; current implementation uses a client-side typewriter reveal effect — true SSE streaming is on the roadmap.)text/plainandapplication/jsonAGENT_SKILLS_JSONenv var (A2A v1.0 spec: id, name, description, tags, examples, inputModes, outputModes)Served at three discovery endpoints:
/.well-known/agent-card.json,/.well-known/agent.json,/agent.jsonThe RAG Loop — A Living Knowledge Base (Design)
This is what sets Mother apart from every other A2A agent: conversations feed the knowledge base, and the knowledge base feeds conversations.
How It Works
The Components
Obsidian Vault (Knowledge Source)
The project's knowledge base is maintained as a local Obsidian vault. Mother Brain vectorizes every note into Supabase pgvector using the VMVA 3-layer cascade (voyage-4-lite → voyage-4 → voyage-code-3). Visitor messages are embedded with voyage-4-large. When Mother searches for knowledge, she's searching the vectorized vault — not a static document, but a living, evolving intelligence layer.
CRM-to-Memory Pipeline (Knowledge Curator)
Owners use the CRM dashboard in the Mother Brain app to review every conversation — from website visitors, in-app users, and external AI agents. Useful exchanges are converted into tagged memories (
support,bug,feature-request,docs) that get vectorized and stored in pgvector. Future conversations benefit from this accumulated knowledge.[PLANNED] An automated Sub-Agent (e.g., OpenClaw) that monitors conversations and documents new knowledge patterns without manual intervention.
Mother (A2A Agent — Knowledge Consumer)
Mother accesses the vectorized vault through Mother Brain's MCP tools (
search_memories,search_codebase,vmva_search,search_chat_history). Every response is grounded in the accumulated knowledge — not hallucinated, not guessed.Why This Matters
Most RAG systems are one-directional: you index documents, the AI searches them. Ours is bidirectional: conversations create knowledge that improves future conversations. The knowledge base gets smarter every day through owner curation — with automated curation on the roadmap.
Mother's Three-Layer Knowledge Organization
Mother's intelligence draws from three nested knowledge sources. Each layer is progressively broader and more detailed:
Layer 1 (Innermost): Core - Mother Brain Internal Docs & APIs
The source of truth. This is Mother Brain's own internal documentation — API schemas, database architecture, code index, deployment configs, and internal systems. Mother accesses this layer through Mother Brain's MCP tools (
search_codebase,vmva_search,get_file_content). It is never exposed publicly.Layer 2 (Middle): Official Website Documentation
The public knowledge. The documentation pages at motherbrain.app/docs — covering every feature, architecture overview, VMVA, A2A protocol, embedded PostgreSQL, and more. Mother reads these via Mother Brain's MCP tools (which access vectorized knowledge including Brainstorm Mode outputs) and via Firecrawl web scraping. This is what visitors see on the website. (Brainstorm Mode is a Mother Brain feature — Mother accesses its vectorized results, not the feature itself.)
Layer 3 (Outermost): Mother's Hidden Knowledge Base
The intelligence layer. This is a much larger, more extensive knowledge base that does not exist on the website or in the app's internal docs. It includes:
When a visitor asks a question, Mother searches all three layers — but the richest, most detailed answers come from Layer 3, the hidden knowledge that makes her responses feel genuinely intelligent rather than scripted.
Dual MCP Server Architecture
This is the core differentiator. The A2A Agent connects to two independent MCP servers simultaneously, giving it both project knowledge and website control:
MCP Server 1: Project Knowledge Gateway (Mother Brain Local)
Connected via the Mother Brain Cloudflare Gateway with Zero-Trust authentication. Provides 27 tools for accessing the host project's vectorized knowledge base:
search_codebasevmva_searchsearch_memoriessearch_chat_historysearch_git_historyadd_memoryget_project_statslist_imageslist_indexed_filesget_file_contentanalyze_imageget_instructionstraining_cycle_startfirecrawl_scrapefirecrawl_searchfirecrawl_mapfirecrawl_extractfirecrawl_parsefirecrawl_agentfirecrawl_research_search_papersfirecrawl_research_related_papersfirecrawl_research_read_paperfirecrawl_research_search_githubgateway_statuslist_skillsskillspawn_agentMCP Server 2: Website Controller (API MCP)
Exposes 13 tools for live website interaction — the agent doesn't just answer questions, it takes actions on the website:
website.list_pageswebsite.read_pagewebsite.create_pagewebsite.edit_pagewebsite.delete_pagewebsite.navigatewebsite.highlightwebsite.get_visitor_statuswebsite.get_accountwebsite.update_accountwebsite.get_referralswebsite.list_inventionswebsite.analyticsHow the Dual-MCP Agentic Loop Works
The agent autonomously decides which tools to call, executes them through the appropriate MCP server, and synthesizes a response. Up to 5 rounds of tool-calling per message.
Zero-Trust Security Architecture
Security is the foundational design principle. The A2A Agent operates under a default-deny Zero-Trust model across every layer:
Layer 1: Network Isolation
a2a_agent_chat), completely separate from the host project's private data. Visitor messages never touch the project's code, memories, or chat history.X-Mother-Brain-InventionandX-Mother-Brain-Sourceheaders so the AI Router can identify, isolate, and attribute all invention traffic.Layer 2: Triple-Path Authentication
The agent supports three authentication paths, resolved in priority order:
Authorization: Bearer <jwt>(HS256 via Web Crypto API)subclaim to customer_idmetadata.license_keyto Encore API resolutionFail-closed policy: If a JWT is presented but
JWT_SECRETis not configured, the Worker returns503— it never silently downgrades security.Layer 3: Credential Scoping
The AI Router validates both credentials. The agent can only access what the Sub-Agent user has been explicitly granted.
Layer 4: Chat History Isolation (Shared-Computer Safe)
On shared computers, chat history is isolated by customer_id:
claim_anonymous_messages()RPC only claims messages wherecustomer_id IS NULL. Messages already owned by another customer are never touched.customer_idwhen a JWT is present — User B cannot see User A's history on the same device.Layer 5: Rate Limiting & Input Validation
Retry-AfterandX-RateLimit-*headers. Rate limited at 20 requests/minute per IP and per visitor.Layer 6: Client-Side Token Protection (Website)
X-Frame-Options: DENY,X-Content-Type-Options: nosniff(configured at Cloudflare edge).motherbrain.app(the open-source invention usesorigin: *for embeddability).Layer 7: Public Repository Safety
The invention is open source on GitHub. Security measures for public distribution:
wrangler.tomlcontains onlyENVIRONMENTandAI_MODEL.4-Tier LLM Fallback Chain (Zero Downtime)
The agent is always available — even when the host infrastructure is completely down. This is achieved through a cascading fallback chain:
Key insight: Tier 3 (Cloudflare Workers AI) is the critical innovation. When the Gateway is completely unreachable, the Worker queries the project's Supabase database directly (vector search works — it's a separate service), then feeds the retrieved knowledge to Llama 3.3 70B running on Cloudflare's edge infrastructure. The visitor gets an intelligent, synthesized response — never a raw data dump, never a "sorry, I'm offline" message.
Three-Channel Intelligent Routing
The agent detects which of three channels a message originates from and adapts its behavior, tone, and skill selection:
The system prompt is dynamically constructed per-channel with:
Cross-Device Chat Continuity
When a user pairs multiple devices (phone, tablet, desktop) via QR code login, the agent provides seamless cross-device chat history:
visitor_id(Broprint.js canvas + audio fingerprint)customer_idvia the auth systemresolve-visitor-idsto get ALL visitor_ids for the customer5-minute cache on device resolution to avoid redundant API calls.
License-to-Visitor Linking (Unified Support Chat)
When anonymous visitors chat on the website and later purchase, their full conversation history is automatically unified:
license_keyin metadataclaim_anonymous_messages()links all anonymous messages to the customerWhether a visitor asked a pre-sales question on the website, reported a bug in-app, or chatted from their phone — it's one conversation thread with full context.
AI-Generated Prompt Suggestions
When a visitor opens the chat widget, the agent generates personalized suggested questions:
Powered by the
visitor/suggestionsJSON-RPC method, which calls the AI model with the visitor's conversation context.AI-Powered Skill Generation
The agent includes an AI Skill Suggestion feature (
agent/suggest-skillsJSON-RPC method):This means any user can deploy the agent and have AI generate appropriate skills for their specific product — no manual configuration needed.
CRM Dashboard with Conversation-to-Memory Pipeline
The Mother Brain app includes a full CRM dashboard for monitoring every conversation:
The Feedback Loop
The more the agent talks, the smarter it gets. Owners curate that intelligence through the CRM.
Configurable Agent Identity
Every aspect of the agent is configurable — it's not locked to any brand:
#39ff14)When deployed, the agent card, system prompt, and personality all reflect the configured identity. The public tarball ships with generic defaults.
Pure SVG Hero Search Interface
The chat widget features an octagonal Hero Search built entirely with pure SVG — no images, no canvas, no external assets:
Supabase pgvector Persistent Memory
The agent uses Supabase (PostgreSQL + pgvector) as its cloud-side persistent memory:
local(embedded PostgreSQL),remote(Supabase), orboth(sync)Image Analysis Capabilities
The agent can analyze images through Mother Brain's vision tools (accessible via MCP when the Gateway is connected):
analyze_imageMCP tool — Analyzes images stored in the Mother Brain project's Media LibraryTechnology Stack
voyage-4-largefor text,voyage-4-lite/voyage-4/voyage-code-3for VMVA cascade)@cf/meta/llama-3.3-70b-instruct-fp8-fast)Embeddability
The A2A Agent is designed to be embedded on any website:
motherbrain-widget/) — importable React components for any React project<HeroSearchHost />— All-in-one hero section with AI suggestion dropdown<ChatApp />— Fullscreen chat overlay with markdown rendering + typewriter streaming reveal<SuggestionsPreloader />— Invisible background suggestion generator<ne-hero-search>) — Framework-agnostic custom element with Shadow DOM for any frameworkArchitecture Diagram
Complete Feature List
Protocol & Architecture
/.well-known/agent.json(+ variants)Security (7-Layer Zero-Trust)
origin: *for embeddability)AI & Intelligence
Cross-Device & Unified Chat
Website Control (13 MCP Tools)
Knowledge Tools (27 MCP Tools)
CRM & Monitoring (Mother Brain Desktop App)
Widget & UI
<ne-hero-search>with Shadow DOM) + React components (<HeroSearchHost />,<ChatApp />)Configuration & Deployment (Mother Brain App)
VMVA Benchmark — Up to 90% Token Savings
Mother Brain includes a built-in VMVA Benchmark Tester that proves the quality and efficiency of the 3-layer cascade:
📖 Full benchmark documentation
Session-less Chat — Total Recall
Mother Brain doesn't have "chat sessions" in the traditional sense. Every conversation, across every project, across every session, is forever:
search_chat_historyComplete Third-Party Stack
Mother Brain Feature Ecosystem
The A2A Agent is the flagship Invention (plugin) for Mother Brain. The full platform includes:
/mothercommand router and FunctionGemma 270M ONNX model for slash command interpretation and internal app operations.Feature Status: Built vs Planned
Here's what's production-ready vs on the roadmap:
✅ Production-Ready (in the open-source invention)
/.well-known/agent.jsonagent/suggest-skills)pack-knowledge-base.cjs)🔧 PLANNED / Roadmap
Links
Built by NativeApps.io with 🧠🧪. The A2A Agent Invention is a plugin for Mother Brain — the persistent memory layer for AI coding assistants. Mother Brain gives AI agents vector memory across local PostgreSQL + Supabase, with MCP tools for code search, knowledge management, and now agent-to-agent communication.
All reactions