DEV Community

Masih Maafi
Masih Maafi

Posted on • Originally published at masihmoafi.com

🏰 A-Modular-Kingdom: The Foundation for AI-Powered Multi-Agent Systems

A comprehensive AI infrastructure providing building blocks for sophisticated multi-agent workflows. Built with modularity and standardization at its core, seamlessly connecting different multi-agent architectures through a unified foundation.

A-Modular-Kingdom Architecture

✨ Features

  • πŸ”— Seamless Integration - Multi-agent systems connect to host.py for instant access to long-term memory, RAG, and powerful tools
  • πŸ—οΈ Modular Architecture - Build hierarchical or sequential workflows on the same foundation
  • πŸ› οΈ Rich Toolset - Vision, code execution, browser automation, web search, and more
  • πŸ“š Smart Memory - Persistent memory and RAG systems working across all agents
  • 🌐 MCP Protocol - Model Context Protocol for reliable, structured interactions
  • 🎀 Voice Control - Speech-to-text and text-to-speech capabilities

πŸ—οΈ Architecture

The foundation layer (host.py) provides unified access to all capabilities, allowing different multi-agent architectures to share the same powerful toolset and knowledge base.

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Multi-Agent Layer           β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚   Council   β”‚ β”‚     Gym     β”‚   β”‚
β”‚  β”‚   Chamber   β”‚ β”‚             β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
              β”‚         β”‚
              β–Ό         β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         Foundation Layer            β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚   RAG   β”‚ β”‚ Memory  β”‚ β”‚ Tools  β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚            host.py                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
Enter fullscreen mode Exit fullscreen mode

πŸ› οΈ Core Components

πŸ“‘ Host.py - MCP Server

The central hub providing MCP (Model Context Protocol) access to all capabilities:

  • save_memory - Direct memory storage
  • search_memories - Semantic memory search
  • query_knowledge_base - RAG document search
  • web_search - Current information retrieval
  • browser_automation - Web interaction
  • code_execute - Safe Python execution
  • analyze_media - Image/video analysis
  • text_to_speech & speech_to_text - Voice capabilities

πŸ’¬ Main.py - Interactive Client

Feature-rich chat interface with:

  • Auto-completion for @ mentions and / commands
  • Direct memory saving with # prefix
  • Automatic tool selection (memory vs RAG vs web)
  • Interactive command interface

πŸ“š RAG System

Three versions with different strategies:

  • V1 - Basic Chroma + BM25 ensemble
  • V2 - FAISS + CrossEncoder reranking
  • V3 - Custom indexes + RRF fusion + LLM reranking

πŸ€– Multi-Agent Systems

πŸ‘‘ Council Chamber

Hierarchical multi-agent system with defined roles:
πŸ‘‘ King (User) β†’ πŸ‘Έ Queen Juliette β†’ πŸ”₯ Sexy Teacher β†’ πŸ€– Code Agent

Features:

  • Hierarchical validation
  • Smart task delegation
  • MCP tool integration
  • Code-first solutions with smolagents

πŸ’ͺ Gym

Sequential fitness-focused multi-agent system:
Interviewer β†’ Plan Generator β†’ Nutrition Agent

Features:

  • CrewAI powered workflows
  • Specialized fitness agents
  • Web interface
  • Flexible LLM support

πŸ”§ Available Tools

Tool Description Status
RAG Document retrieval βœ… 3 versions
Memory Long-term storage βœ… Integrated
Vision Image analysis βœ… Ready
Code Exec Python sandbox βœ… Secure
Browser Web automation βœ… Playwright
Web Search Info retrieval βœ… DuckDuckGo
TTS Text-to-speech βœ… Kokoro
STT Speech-to-text βœ… Whisper

πŸš€ Quick Start

# Clone the repository
git clone https://github.com/MasihMoafi/A-Modular-Kingdom.git
cd A-Modular-Kingdom

# Install dependencies
uv sync
# Or with pip
pip install -r requirements.txt

# Start the MCP server
python agent/host.py

# In another terminal, start the interactive client
python agent/main.py
Enter fullscreen mode Exit fullscreen mode

πŸ“ Commands Reference

Memory Management

  • #message - Save directly to memory
  • /memory - List and manage memories

Document Access

  • @filename - Reference documents
  • /files - Show available documents

RAG Search

/rag "search term"        # Default: v2, current dir
/rag "search term" v3     # Specify version
/rag "search term" v2 /path/to/docs  # Custom path
Enter fullscreen mode Exit fullscreen mode

🎯 CLI Integration

Claude Code and Gemini-cli both connect to host.py as clients.

Compatible with:

  • Gemini CLI Extension
  • Claude Code
  • Any MCP-compatible client

πŸ”— Links & Resources


Originally published at masihmoafi.com

A-Modular-Kingdom: Where AI agents come together in harmony 🏰✨

Top comments (0)