Bridging the Gap: Connect Local AI Agents to A-Modular-Kingdom MCP Server Automatically
DEV Community Grade 10 1h ago

Bridging the Gap: Connect Local AI Agents to A-Modular-Kingdom MCP Server Automatically

Bridging the Gap: Connect Local AI Agents to A-Modular-Kingdom MCP Server Automatically The Model Context Protocol (MCP) has changed how we build AI-assisted development tools. It allows local coding agents (like Codex, Claude Code, or Cursor) to seamlessly query knowledge bases, execute code, and retrieve persistent memory. However, setting them up can be a friction-filled developer experience: Config gymnastics : Editing agent configuration files (like ~/.codex/config.toml or running CLI command configurations) manually is tedious and error-prone. Path issues : Absolute paths on different systems break config files easily. Resource exhaustion : Running heavy RAG pipelines can consume excessive CPU, causing system slowdowns or high battery drain. To address this, I've added a local setup harness to my flagship project, A-Modular-Kingdom (AMK) . This harness acts as a bridge that automatically configures local agents to talk to the AMK server, with thermal monitoring built-in. The Solution: Automated MCP Harness Setup Rather than requiring developers to copy-paste config blocks, the repo now includes a single bootstrap script: ./scripts/setup_mcp.sh This script automates two integrations under the hood: 1. Codex Integration It runs a Python registration script ( scripts/register_mcp.py ) that checks for the presence of Codex configuration at ~/.codex/config.toml . It automatically registers and configures modular_kingdom_host with paths mapped dynamically to your local clone, adding the following setup: [mcp_servers.modular_kingdom_host] command = "/path/to/A-Modular-Kingdom/scripts/thermal_runner.py" args = [ "--threshold" , "85" , "--" , "/path/to/A-Modular-Kingdom/.venv/bin/python" , "-u" , "/path/to/A-Modular-Kingdom/src/agent/host.py" ] startup_timeout_sec = 60 tool_timeout_sec = 30 env = { "PYTHONUNBUFFERED" = "1" , "MCP_LOG_FILE" = "/tmp/modular_kingdom_mcp.log" } 2. Claude Code Integration It auto-detects if the claude CLI tool is installed and registers the server using Claude Code's native command: claude mcp add a-modular-kingdom \ /path/to/python \ /path/to/thermal_runner.py --threshold 85 -- \ /path/to/python -u /path/to/host.py Safety First: The Thermal Runner Wrapper A key part of the new bridge is the thermal_runner.py wrapper. Local agents running large code bases or dense RAG models can cause significant CPU spikes. If your laptop thermal limits kick in, your whole development workspace lags. The thermal runner sits between the agent and the MCP server. It continuously monitors the CPU core temperatures. If the system temperature exceeds a safe threshold (e.g., 85°C), it gently pauses the MCP server execution, resuming it only once the cores cool down. This ensures your local development flow remains smooth and your machine doesn't overheat. Why A-Modular-Kingdom? With the bridge in place, your local agent gets immediate, friction-free access to: Hybrid RAG : Fast lexical search + semantic vector retrieval with Qdrant and Cross-Encoder reranking. Hierarchical Scoped Memory : Automatic classification of memories into global rules, preferences, personas, or project-specific contexts. No more manual configurations. Clone, run the setup script, and let your local agent benefit from a standardized memory and knowledge baseline. Check out the repository and set it up today: 👉 MasihMoafi/A-Modular-Kingdom For more of my work, visit my website: 👉 masihmoafi.tech

Bridging the Gap: Connect Local AI Agents to A-Modular-Kingdom MCP Server Automatically The Model Context Protocol (MCP) has changed how we build AI-assisted development tools. It allows local coding agents (like Codex, Claude Code, or Cursor) to seamlessly query knowledge bases, execute code, and retrieve persistent memory. However, setting them up can be a friction-filled developer experience: - Config gymnastics: Editing agent configuration files (like ~/.codex/config.toml or running CLI command configurations) manually is tedious and error-prone. - Path issues: Absolute paths on different systems break config files easily. - Resource exhaustion: Running heavy RAG pipelines can consume excessive CPU, causing system slowdowns or high battery drain. To address this, I've added a local setup harness to my flagship project, A-Modular-Kingdom (AMK). This harness acts as a bridge that automatically configures local agents to talk to the AMK server, with thermal monitoring built-in. The Solution: Automated MCP Harness Setup Rather than requiring developers to copy-paste config blocks, the repo now includes a single bootstrap script: ./scripts/setup_mcp.sh This script automates two integrations under the hood: 1. Codex Integration It runs a Python registration script (scripts/register_mcp.py ) that checks for the presence of Codex configuration at ~/.codex/config.toml . It automatically registers and configures modular_kingdom_host with paths mapped dynamically to your local clone, adding the following setup: [mcp_servers.modular_kingdom_host] command = "/path/to/A-Modular-Kingdom/scripts/thermal_runner.py" args = ["--threshold", "85", "--", "/path/to/A-Modular-Kingdom/.venv/bin/python", "-u", "/path/to/A-Modular-Kingdom/src/agent/host.py"] startup_timeout_sec = 60 tool_timeout_sec = 30 env = { "PYTHONUNBUFFERED" = "1", "MCP_LOG_FILE" = "/tmp/modular_kingdom_mcp.log" } 2. Claude Code Integration It auto-detects if the claude CLI tool is installed and registers the server using Claude Code's native command: claude mcp add a-modular-kingdom \ /path/to/python \ /path/to/thermal_runner.py --threshold 85 -- \ /path/to/python -u /path/to/host.py Safety First: The Thermal Runner Wrapper A key part of the new bridge is the thermal_runner.py wrapper. Local agents running large code bases or dense RAG models can cause significant CPU spikes. If your laptop thermal limits kick in, your whole development workspace lags. The thermal runner sits between the agent and the MCP server. It continuously monitors the CPU core temperatures. If the system temperature exceeds a safe threshold (e.g., 85°C), it gently pauses the MCP server execution, resuming it only once the cores cool down. This ensures your local development flow remains smooth and your machine doesn't overheat. Why A-Modular-Kingdom? With the bridge in place, your local agent gets immediate, friction-free access to: - Hybrid RAG: Fast lexical search + semantic vector retrieval with Qdrant and Cross-Encoder reranking. - Hierarchical Scoped Memory: Automatic classification of memories into global rules, preferences, personas, or project-specific contexts. No more manual configurations. Clone, run the setup script, and let your local agent benefit from a standardized memory and knowledge baseline. Check out the repository and set it up today: 👉 MasihMoafi/A-Modular-Kingdom For more of my work, visit my website: 👉 masihmoafi.tech Top comments (0)

Comments

No comments yet. Start the discussion.