惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

J
Java Code Geeks
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
爱范儿
爱范儿
罗磊的独立博客
美团技术团队
Jina AI
Jina AI
量子位
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
酷 壳 – CoolShell
酷 壳 – CoolShell
有赞技术团队
有赞技术团队
V
V2EX
阮一峰的网络日志
阮一峰的网络日志
小众软件
小众软件
IT之家
IT之家
雷峰网
雷峰网
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
大猫的无限游戏
大猫的无限游戏
博客园 - 聂微东
月光博客
月光博客
人人都是产品经理
人人都是产品经理
博客园 - 三生石上(FineUI控件)

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Bridging the Gap: Connect Local AI Agents to A-Modular-Ki...
Masih Maafi · 2026-06-16 · via DEV Community

Masih Maafi

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:

  1. Config gymnastics: Editing agent configuration files (like ~/.codex/config.toml or running CLI command configurations) manually is tedious and error-prone.
  2. Path issues: Absolute paths on different systems break config files easily.
  3. 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