Overview
Micro-Agent is a flexible, extensible Python agent framework designed to provide intelligent agent capabilities as a callable service layer for upstream applications. The "Micro" naming mirrors microservices architecture: lightweight, modular components that expose a standardized async streaming interface. It implements the ReAct (Reasoning + Acting) pattern over an MCP tool ecosystem, with an integrated shell environment and web-based execution visualization.
Problem Addressed
| Problem |
Solution |
| Agents tightly coupled to specific tools or LLM providers |
MCP protocol abstraction allows dynamic connection to multiple local (stdio) and remote (SSE) tool servers at runtime |
| No separation between agent logic and calling application |
Standardized run_agent(task_name, prompt) async API isolates agent internals from upstream consumers |
| Agent execution is opaque and hard to debug |
Execution records saved as JSON + auto-generated HTML visualization showing thought/action/result per step |
| Shell operations risk host system damage |
Docker-first deployment with SSH access isolates agent shell execution in a container sandbox |
| Context window exhaustion in long-running agents |
TokenCounter tracks cumulative input tokens against configurable max_input_tokens limit, raises TokenLimitExceeded before overflow |
Key Statistics
| Metric |
Value |
Date Gathered |
| GitHub Stars |
7 |
2026-02-20 |
| GitHub Forks |
9 |
2026-02-20 |
| Contributors |
3 |
2026-02-20 |
| Latest Release |
No formal release (v1.0.0 in README badge) |
2026-02-20 |
| Open Issues |
0 |
2026-02-20 |
| Repo Created |
2025-03-25 |
2026-02-20 |
| Last Pushed |
2025-10-31 |
2026-02-20 |
| Primary Language |
Python 3.12 |
2026-02-20 |
Key Features
ReAct Agent Architecture
BaseAgent (Pydantic BaseModel) defines the step-based execution loop with state machine (IDLE, RUNNING, FINISHED, ERROR)
ReActAgent extends BaseAgent with abstract think() and act() methods; each step returns a Record dict containing thought, action, action_result, and token_usage
max_steps configurable (default 10 for base ReAct, 40 for MCPAgent); duplicate-response detection via duplicate_threshold
MCPAgent extends ToolCallAgent and manages tool schema refresh every N steps (_refresh_tools_interval = 5)
MCP Protocol Integration
- Connects to multiple MCP servers simultaneously via both SSE (HTTP/SSE for remote) and stdio (subprocess for local) transports
- Built-in MCP server (
app/mcp/server.py) exposes: bash, cmd (Windows), terminate, file_saver, json_saver
- Additional built-in servers:
aml_server, deepseek_server, mysql_server, time_server
config.json declaratively lists external MCP server connections; auto-loaded at runtime by MCPRunner
- Tool list refreshed dynamically during agent runs to detect schema changes mid-task
LLM Abstraction Layer
- Uses OpenAI-compatible API via
AsyncOpenAI; supports any OpenAI-compatible endpoint including Claude models
- Explicitly supports reasoning models (
o1, o3-mini) and multimodal models (gpt-4o, claude-3-* variants) with separate handling
TokenCounter uses tiktoken for precise per-message token counting including image token estimation (low-detail: 85 tokens, high-detail tiles: 170 tokens each)
- Retry logic via
tenacity with exponential backoff for APIError, RateLimitError
- Config loaded from TOML (
config/config.toml) with per-model override support; singleton thread-safe Config class
Execution Visualization
- Each agent run saves two artifacts to
visualization/: {task_name}_record.json (structured execution log) and {task_name}.html (interactive HTML report)
- HTML report renders thought/action/result sequence for post-run inspection
- Web interface (
app.py) on port 8010 using Flask + Flask-SocketIO + flask-restx
Deployment
- Docker image based on
python:3.12-slim with SSH server exposed on port 22 (agent shell execution isolation)
- Ports: 8010 (Web UI), 22 (SSH), 8000 (docs server)
docker-compose.yml provided for single-command startup
meta_app.py and run_meta_app.py provide a meta-agent mode for orchestrating multiple sub-agents
Technical Architecture
The app/ module hierarchy:
Installation & Usage
# Clone repository
git clone https://github.com/fdueblab/Micro-Agent
cd Micro-Agent
# Docker (recommended for shell isolation)
cp .env.example .env
cp config/config.example.toml config/config.toml
# Edit config.toml: set LLM model, base_url, api_key
docker-compose up -d
docker-compose exec micro_agent bash
python main.py
# Local (Python 3.12 via conda)
conda create -n micro-agent python=3.12
conda activate micro-agent
pip install -r requirements.txt
python main.py # CLI agent run
python app.py # Web UI on http://localhost:8010
Configuring external MCP servers in config.json:
{
"servers": [
{
"connection_type": "sse",
"server_url": "http://your-mcp-server.com/sse",
"server_id": "remote_tools"
},
{
"connection_type": "stdio",
"command": "python",
"args": ["-m", "your_module.mcp_server"],
"server_id": "local_tools"
}
]
}
Invoking the agent programmatically:
import asyncio
from main import run_agent
# task_name used for output filenames; prompt defines agent role and task
asyncio.run(run_agent("code_analysis", """
You are a code analyst. Examine the project structure, identify main modules,
analyze dependencies, and generate a structured report.
"""))
# Output: visualization/code_analysis_record.json
# visualization/code_analysis.html
Relevance to Claude Code Development
Applications
- Demonstrates a clean separation pattern between agent infrastructure and task-specific prompting: the
run_agent(task_name, prompt) contract is directly applicable to how Claude Code could expose agent capabilities to orchestrators
- The
MCPAgent's multi-server connection management (simultaneous stdio + SSE) shows how to dynamically aggregate tools from heterogeneous MCP sources at runtime
- Token budget enforcement via
TokenLimitExceeded exception prevents runaway API costs in long-running autonomous tasks
Patterns Worth Adopting
- TOML-based LLM config with per-model overrides enables switching between Claude models (opus, sonnet, haiku) per agent role without code changes
- Step-level
Record persistence (thought + action + action result + token usage) provides full audit trail for debugging agent failures
- Tool schema refresh every N steps compensates for dynamic MCP server state changes during long runs
- Duplicate-response detection (
duplicate_threshold) prevents infinite loops when an agent repeatedly produces the same action
Integration Opportunities
- The built-in MCP server (
FastMCP wrapping Bash, FileSaver, JsonSaver) can be imported directly to extend Claude Code skill agents with shell execution capabilities
- The HTML visualization generator (
app/utils/visualize_record.py) could be adapted for Claude Code skill audit reports
MCPRunner multi-server aggregation pattern is directly applicable to Claude Code's MCP ecosystem management, particularly for routing tool calls across local and remote servers
References
1---2name: micro-agent3description: Micro-Agent is a flexible, extensible Python agent framework designed to provide intelligent agent capabilities as a callable service layer for upstream applications. The "Micro" naming mirrors...4license: MIT5---6
7## Overview
8
9Micro-Agent is a flexible, extensible Python agent framework designed to provide intelligent agent capabilities as a callable service layer for upstream applications. The "Micro" naming mirrors microservices architecture: lightweight, modular components that expose a standardized async streaming interface. It implements the ReAct (Reasoning + Acting) pattern over an MCP tool ecosystem, with an integrated shell environment and web-based execution visualization.
10
11---
12
13## Problem Addressed
14
15| Problem | Solution |
16|---------|----------|
17| Agents tightly coupled to specific tools or LLM providers | MCP protocol abstraction allows dynamic connection to multiple local (stdio) and remote (SSE) tool servers at runtime |
18| No separation between agent logic and calling application | Standardized `run_agent(task_name, prompt)` async API isolates agent internals from upstream consumers |
19| Agent execution is opaque and hard to debug | Execution records saved as JSON + auto-generated HTML visualization showing thought/action/result per step |
20| Shell operations risk host system damage | Docker-first deployment with SSH access isolates agent shell execution in a container sandbox |
21| Context window exhaustion in long-running agents | `TokenCounter` tracks cumulative input tokens against configurable `max_input_tokens` limit, raises `TokenLimitExceeded` before overflow |
22
23---
24
25## Key Statistics
26
27| Metric | Value | Date Gathered |
28|--------|-------|---------------|
29| GitHub Stars | 7 | 2026-02-20 |
30| GitHub Forks | 9 | 2026-02-20 |
31| Contributors | 3 | 2026-02-20 |
32| Latest Release | No formal release (v1.0.0 in README badge) | 2026-02-20 |
33| Open Issues | 0 | 2026-02-20 |
34| Repo Created | 2025-03-25 | 2026-02-20 |
35| Last Pushed | 2025-10-31 | 2026-02-20 |
36| Primary Language | Python 3.12 | 2026-02-20 |
37
38---
39
40## Key Features
41
42### ReAct Agent Architecture
43
44- `BaseAgent` (Pydantic `BaseModel`) defines the step-based execution loop with state machine (`IDLE`, `RUNNING`, `FINISHED`, `ERROR`)
45- `ReActAgent` extends `BaseAgent` with abstract `think()` and `act()` methods; each step returns a `Record` dict containing `thought`, `action`, `action_result`, and `token_usage`
46- `max_steps` configurable (default 10 for base ReAct, 40 for `MCPAgent`); duplicate-response detection via `duplicate_threshold`
47- `MCPAgent` extends `ToolCallAgent` and manages tool schema refresh every N steps (`_refresh_tools_interval = 5`)
48
49### MCP Protocol Integration
50
51- Connects to multiple MCP servers simultaneously via both SSE (HTTP/SSE for remote) and stdio (subprocess for local) transports
52- Built-in MCP server (`app/mcp/server.py`) exposes: `bash`, `cmd` (Windows), `terminate`, `file_saver`, `json_saver`
53- Additional built-in servers: `aml_server`, `deepseek_server`, `mysql_server`, `time_server`
54- `config.json` declaratively lists external MCP server connections; auto-loaded at runtime by `MCPRunner`
55- Tool list refreshed dynamically during agent runs to detect schema changes mid-task
56
57### LLM Abstraction Layer
58
59- Uses OpenAI-compatible API via `AsyncOpenAI`; supports any OpenAI-compatible endpoint including Claude models
60- Explicitly supports reasoning models (`o1`, `o3-mini`) and multimodal models (`gpt-4o`, `claude-3-*` variants) with separate handling
61- `TokenCounter` uses `tiktoken` for precise per-message token counting including image token estimation (low-detail: 85 tokens, high-detail tiles: 170 tokens each)
62- Retry logic via `tenacity` with exponential backoff for `APIError`, `RateLimitError`
63- Config loaded from TOML (`config/config.toml`) with per-model override support; singleton thread-safe `Config` class
64
65### Execution Visualization
66
67- Each agent run saves two artifacts to `visualization/`: `{task_name}_record.json` (structured execution log) and `{task_name}.html` (interactive HTML report)
68- HTML report renders thought/action/result sequence for post-run inspection
69- Web interface (`app.py`) on port 8010 using Flask + Flask-SocketIO + flask-restx
70
71### Deployment
72
73- Docker image based on `python:3.12-slim` with SSH server exposed on port 22 (agent shell execution isolation)
74- Ports: 8010 (Web UI), 22 (SSH), 8000 (docs server)
75- `docker-compose.yml` provided for single-command startup
76- `meta_app.py` and `run_meta_app.py` provide a meta-agent mode for orchestrating multiple sub-agents
77
78---
79
80## Technical Architecture
81
82<eg>
83Upstream Application
84 |
85 v
86 run_agent(task_name, prompt) [main.py async entry point]
87 |
88 v
89 MCPRunner
90 - add_server() for each config.json entry + built-in server
91 |
92 v
93 MCPAgent (ToolCallAgent -> ReActAgent -> BaseAgent)
94 - state: IDLE -> RUNNING -> FINISHED/ERROR
95 - max_steps: 40
96 - loop: think() -> act() -> record step -> check duplicate/terminate
97 |
98 think() act()
99 - LLM.ask() with tools - Execute MCP tool call
100 - Returns: should_act, - Returns: tool result string
101 thought, action,
102 token_usage
103 |
104 v
105 MCP Tool Ecosystem
106 - stdio: local subprocess servers (built-in: bash, file_saver, json_saver, terminate)
107 - SSE: remote HTTP servers (configured in config.json)
108 - Tool schema refreshed every 5 steps
109 |
110 v
111 Record Persistence
112 - JSON execution log -> visualization/
113 - HTML report generated from JSON
114</eg>
115
116The `app/` module hierarchy:
117
118<eg>
119app/
120 agent/ # BaseAgent, ReActAgent, ToolCallAgent, MCPAgent, MetaApp agent
121 llm.py # AsyncOpenAI wrapper with TokenCounter and retry logic
122 mcp/ # FastMCP-based built-in servers (bash, file tools, mysql, AML, time)
123 prompt/ # System and next-step prompt templates for MCP agent
124 schema.py # Pydantic models: Message, Memory, Record, AgentState, TokenUsage
125 config.py # Singleton TOML config loader with per-model LLM settings
126 tool/ # BaseTool + concrete tools: Bash, Cmd, Terminal, FileSaver, JsonSaver
127 utils/ # Visualization HTML generator, record serializer
128</eg>
129
130---
131
132## Installation & Usage
133
134```bash
135# Clone repository
136git clone https://github.com/fdueblab/Micro-Agent
137cd Micro-Agent
138
139# Docker (recommended for shell isolation)
140cp .env.example .env
141cp config/config.example.toml config/config.toml
142# Edit config.toml: set LLM model, base_url, api_key
143docker-compose up -d
144docker-compose exec micro_agent bash
145python main.py
146
147# Local (Python 3.12 via conda)
148conda create -n micro-agent python=3.12
149conda activate micro-agent
150pip install -r requirements.txt
151python main.py # CLI agent run
152python app.py # Web UI on http://localhost:8010
153```
154
155Configuring external MCP servers in `config.json`:
156
157```json
158{
159 "servers": [
160 {
161 "connection_type": "sse",
162 "server_url": "http://your-mcp-server.com/sse",
163 "server_id": "remote_tools"
164 },
165 {
166 "connection_type": "stdio",
167 "command": "python",
168 "args": ["-m", "your_module.mcp_server"],
169 "server_id": "local_tools"
170 }
171 ]
172}
173```
174
175Invoking the agent programmatically:
176
177```python
178import asyncio
179from main import run_agent
180
181# task_name used for output filenames; prompt defines agent role and task
182asyncio.run(run_agent("code_analysis", """
183You are a code analyst. Examine the project structure, identify main modules,
184analyze dependencies, and generate a structured report.
185"""))
186# Output: visualization/code_analysis_record.json
187# visualization/code_analysis.html
188```
189
190---
191
192## Relevance to Claude Code Development
193
194### Applications
195
196- Demonstrates a clean separation pattern between agent infrastructure and task-specific prompting: the `run_agent(task_name, prompt)` contract is directly applicable to how Claude Code could expose agent capabilities to orchestrators
197- The `MCPAgent`'s multi-server connection management (simultaneous stdio + SSE) shows how to dynamically aggregate tools from heterogeneous MCP sources at runtime
198- Token budget enforcement via `TokenLimitExceeded` exception prevents runaway API costs in long-running autonomous tasks
199
200### Patterns Worth Adopting
201
202- TOML-based LLM config with per-model overrides enables switching between Claude models (opus, sonnet, haiku) per agent role without code changes
203- Step-level `Record` persistence (thought + action + action result + token usage) provides full audit trail for debugging agent failures
204- Tool schema refresh every N steps compensates for dynamic MCP server state changes during long runs
205- Duplicate-response detection (`duplicate_threshold`) prevents infinite loops when an agent repeatedly produces the same action
206
207### Integration Opportunities
208
209- The built-in MCP server (`FastMCP` wrapping `Bash`, `FileSaver`, `JsonSaver`) can be imported directly to extend Claude Code skill agents with shell execution capabilities
210- The HTML visualization generator (`app/utils/visualize_record.py`) could be adapted for Claude Code skill audit reports
211- `MCPRunner` multi-server aggregation pattern is directly applicable to Claude Code's MCP ecosystem management, particularly for routing tool calls across local and remote servers
212
213---
214
215## References
216
217- [fdueblab/Micro-Agent GitHub Repository](https://github.com/fdueblab/Micro-Agent) (accessed 2026-02-20)
218- [README.md - Micro-Agent](https://github.com/fdueblab/Micro-Agent/blob/master/README.md) (accessed 2026-02-20)
219- [app/agent/react.py - ReActAgent implementation](https://github.com/fdueblab/Micro-Agent/blob/master/app/agent/react.py) (accessed 2026-02-20)
220- [app/agent/mcp.py - MCPAgent implementation](https://github.com/fdueblab/Micro-Agent/blob/master/app/agent/mcp.py) (accessed 2026-02-20)
221- [app/llm.py - LLM wrapper with TokenCounter](https://github.com/fdueblab/Micro-Agent/blob/master/app/llm.py) (accessed 2026-02-20)
222- [app/mcp/server.py - Built-in MCP server](https://github.com/fdueblab/Micro-Agent/blob/master/app/mcp/server.py) (accessed 2026-02-20)
223- [requirements.txt](https://github.com/fdueblab/Micro-Agent/blob/master/requirements.txt) (accessed 2026-02-20)
224- [GitHub API - repos/fdueblab/Micro-Agent](https://api.github.com/repos/fdueblab/Micro-Agent) (accessed 2026-02-20)