Building an Expert Sub-Agent System for Claude Code with MCP
Claude Code is an excellent development assistant. But even the best generalist has its limits. When I do a code review, I need a specialized security eye. When I design an architecture, I need a system trade-offs expert. When I plan a feature, I need a scope analyst.
That’s the problem GLM Delegator solves: a system of 5 specialized expert agents, integrated into Claude Code via the MCP protocol.
The concept: intelligent delegation
Instead of a single LLM that does everything, GLM Delegator offers 5 experts with distinct roles:
| Expert | Role | Use case |
|---|---|---|
| Architect | System design, trade-offs, complex debugging | Architecture decisions, pattern choices |
| Plan Reviewer | Plan validation before execution | Verify that an implementation plan is coherent |
| Scope Analyst | Ambiguity detection | Identify fuzzy areas in requirements |
| Code Reviewer | Bugs, quality, patterns | Multilingual code review (EN/FR/CN) |
| Security Analyst | Vulnerabilities, threat modeling | OWASP audit, attack surface analysis |
Each expert has a specialized system prompt, its own heuristics, and an output format adapted to its domain.
Technical architecture: MCP Server
The project is a MCP server (Model Context Protocol) in Python that exposes the 5 experts as tools available in Claude Code.
# Each expert is an MCP tool
@server.tool("glm_architect")
async def architect(task: str, files: list[str], mode: str = "advisory"):
"""System design, tradeoffs, complex debugging"""
return await delegate_to_expert("architect", task, files, mode)
@server.tool("glm_security_analyst")
async def security(task: str, files: list[str], mode: str = "advisory"):
"""Vulnerability detection, threat modeling"""
return await delegate_to_expert("security", task, files, mode)
Claude Code discovers these tools automatically via MCP config:
{
"mcpServers": {
"glm-experts": {
"type": "stdio",
"command": "python3",
"args": ["glm_mcp_server.py", "--provider", "anthropic", "--model", "claude-sonnet-4-5-20250929"]
}
}
}
Two operating modes
- Advisory: the expert analyzes and recommends, without touching code
- Implementation: the expert proposes concrete modifications
Advisory mode is the default — you want expert opinion, not an autonomous agent modifying code without validation.
Multi-provider: no vendor lock-in
The particularity of GLM Delegator: it works with any LLM provider compatible with OpenAI or Anthropic:
- Anthropic Claude (Sonnet, Opus, Haiku)
- OpenAI GPT
- GLM-4.7 (via Z.AI)
- Ollama (local models)
- Groq, DeepInfra, TogetherAI
- vLLM, LM Studio
Each expert can use a different provider. You can have the Architect on Claude Opus for critical decisions, and the Code Reviewer on a local model for confidentiality.
Practical use cases
Architecture review
"Ask the architect to evaluate my hexagonal structure
for the payment module. Files: src/Domain/Payment/,
src/Infrastructure/Stripe/"
The Architect expert analyzes the structure, verifies dependency direction, and identifies coupling. The result is a structured report with prioritized recommendations.
This type of review complements the reflection on software architecture for modern web applications that I do upfront.
Security audit
"Have the security analyst audit the auth endpoints
in src/Controller/AuthController.php"
The Security expert checks for OWASP vulnerabilities: injection, XSS, weak authentication, sensitive data exposure. The report classifies findings by severity (critical/high/medium/low).
Scope analysis before sprint
"Analyze the scope of this user story:
'As an admin, I want to manage team permissions'.
Identify ambiguities and questions to ask the PO."
The Scope Analyst breaks down the story, identifies fuzzy areas (“manage” means what exactly? Full CRUD? Permission inheritance?), and generates a list of structured questions.
This approach integrates perfectly into a Product Management for developers approach — clarifying scope before coding.
Feedback
What works
- Automatic routing: Claude Code chooses the right expert based on the task, without manual intervention
- Advisory mode: getting a second opinion without risk of undesired modification
- Multi-provider: being able to test different models for each expert role
What required iteration
- System prompts: calibrating the level of detail in responses (too short = useless, too long = noise)
- Context management: passing the right files to the expert without overloading their context
- Output format: structuring reports so they’re actionable, not just informative
The real gain
The gain isn’t replacing human review. It’s automating the initial screening. The Security expert catches obvious vulnerabilities before the human reviewer looks for them. The Architect validates structural coherence before team discussion. Human time concentrates on decisions that require judgment.
This is exactly the philosophy I describe in my article on AI in developer workflow: AI for the mechanical, humans for judgment.
In summary
GLM Delegator transforms Claude Code into a team of 5 specialized experts via the MCP protocol:
- 5 roles: Architect, Plan Reviewer, Scope Analyst, Code Reviewer, Security Analyst
- Multi-provider: Anthropic, OpenAI, Ollama, Groq, and more
- Two modes: Advisory (recommendations) and Implementation (modifications)
- Native integration: automatic discovery via MCP config
The project is open source: github.com/MakFly/glm-delegator.
Kevin De Vaubree
Senior Full-Stack Developer