Features: - FastMCP-based MCP server for Claude Code agent recommendations - Hierarchical agent architecture with 39 specialized agents - 10 MCP tools with enhanced LLM-friendly descriptions - Composed agent support with parent-child relationships - Project root configuration for focused recommendations - Smart agent recommendation engine with confidence scoring Server includes: - Core recommendation tools (recommend_agents, get_agent_content) - Project management tools (set/get/clear project roots) - Discovery tools (list_agents, server_stats) - Hierarchy navigation (get_sub_agents, get_parent_agent, get_agent_hierarchy) All tools properly annotated for calling LLM clarity with detailed arguments, return values, and usage examples.
137 lines
5.4 KiB
Python
137 lines
5.4 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script for composed agent functionality
|
|
"""
|
|
|
|
import asyncio
|
|
import os
|
|
from pathlib import Path
|
|
import sys
|
|
|
|
# Add the source directory to the path
|
|
sys.path.insert(0, str(Path(__file__).parent / "src"))
|
|
|
|
from agent_mcp_server.server import AgentLibrary
|
|
|
|
async def test_composed_agents():
|
|
"""Test the composed agent functionality"""
|
|
|
|
print("🧪 Testing Composed Agent Functionality")
|
|
print("=" * 50)
|
|
|
|
# Initialize agent library with local templates
|
|
templates_path = Path(__file__).parent / "agent_templates"
|
|
library = AgentLibrary(templates_path)
|
|
|
|
await library.initialize()
|
|
|
|
print(f"\n📊 Total agents loaded: {len(library.agents)}")
|
|
|
|
# Analyze agent types
|
|
individual = composed = sub_agents = 0
|
|
for agent in library.agents.values():
|
|
if agent.agent_type == "individual":
|
|
individual += 1
|
|
elif agent.agent_type == "composed":
|
|
composed += 1
|
|
elif agent.agent_type == "sub":
|
|
sub_agents += 1
|
|
|
|
print(f" • Individual agents: {individual}")
|
|
print(f" • Composed agents: {composed}")
|
|
print(f" • Sub-agents: {sub_agents}")
|
|
|
|
# Test composed agent detection
|
|
print(f"\n🎯 Testing Composed Agent Structure")
|
|
for name, agent in library.agents.items():
|
|
if agent.agent_type == "composed":
|
|
print(f"\n📋 Composed Agent: {agent.emoji} {agent.name}")
|
|
print(f" Type: {agent.agent_type}")
|
|
print(f" Sub-agents: {len(agent.sub_agents)}")
|
|
for sub_name in agent.sub_agents:
|
|
if sub_name in library.agents:
|
|
sub_agent = library.agents[sub_name]
|
|
print(f" └─ {sub_agent.emoji} {sub_agent.name} (parent: {sub_agent.parent_agent})")
|
|
|
|
# Test hierarchical recommendations
|
|
print(f"\n🔧 Testing Hierarchical Recommendations")
|
|
test_tasks = [
|
|
"I need help with Python testing framework development",
|
|
"How do I create beautiful HTML reports?",
|
|
"Help me with testing in general",
|
|
"I need a testing architecture overview"
|
|
]
|
|
|
|
for task in test_tasks:
|
|
print(f"\n📝 Task: \"{task}\"")
|
|
recommendations = await library.recommend_agents(task, "", 3)
|
|
|
|
for i, rec in enumerate(recommendations, 1):
|
|
agent_type_desc = rec.get('agent_type', 'unknown')
|
|
parent_info = f" (part of {rec.get('parent_agent', 'N/A')})" if rec.get('parent_agent') else ""
|
|
print(f" {i}. {rec['emoji']} {rec['name']} - {agent_type_desc}{parent_info}")
|
|
print(f" Confidence: {rec['confidence']:.2f} | Reason: {rec['reason']}")
|
|
|
|
# Test agent content enhancement
|
|
print(f"\n📄 Testing Agent Content Enhancement")
|
|
|
|
# Test composed agent content
|
|
composed_agent_name = None
|
|
sub_agent_name = None
|
|
|
|
for name, agent in library.agents.items():
|
|
if agent.agent_type == "composed":
|
|
composed_agent_name = name
|
|
elif agent.agent_type == "sub":
|
|
sub_agent_name = name
|
|
|
|
if composed_agent_name:
|
|
print(f"\n🏗️ Composed Agent Content: {composed_agent_name}")
|
|
content_result = await library.get_agent_content(composed_agent_name)
|
|
if content_result["success"]:
|
|
print(" ✅ Content includes specialist team references")
|
|
if "My Specialist Team" in content_result["content"]:
|
|
print(" ✅ Found 'My Specialist Team' section")
|
|
else:
|
|
print(" ❌ Missing 'My Specialist Team' section")
|
|
|
|
if sub_agent_name:
|
|
print(f"\n🔬 Sub-Agent Content: {sub_agent_name}")
|
|
content_result = await library.get_agent_content(sub_agent_name)
|
|
if content_result["success"]:
|
|
print(" ✅ Content includes parent framework context")
|
|
if "Framework" in content_result["content"]:
|
|
print(" ✅ Found parent framework reference")
|
|
else:
|
|
print(" ❌ Missing parent framework reference")
|
|
|
|
# Test flat structure maintenance
|
|
print(f"\n📋 Testing Flat Structure Maintenance")
|
|
all_agents = await library.list_agents()
|
|
print(f" Total agents in flat list: {len(all_agents)}")
|
|
|
|
# Verify all agents are accessible
|
|
accessible_individual = accessible_composed = accessible_sub = 0
|
|
for agent_data in all_agents:
|
|
agent = library.agents[agent_data["name"]]
|
|
if agent.agent_type == "individual":
|
|
accessible_individual += 1
|
|
elif agent.agent_type == "composed":
|
|
accessible_composed += 1
|
|
elif agent.agent_type == "sub":
|
|
accessible_sub += 1
|
|
|
|
print(f" ✅ Individual accessible: {accessible_individual}")
|
|
print(f" ✅ Composed accessible: {accessible_composed}")
|
|
print(f" ✅ Sub-agents accessible: {accessible_sub}")
|
|
print(f" 📊 Claude Code sees ALL {len(all_agents)} agents in flat list")
|
|
|
|
print(f"\n✅ Composed Agent Testing Complete!")
|
|
print(f"📋 Summary:")
|
|
print(f" • Flat structure maintained: All {len(all_agents)} agents accessible")
|
|
print(f" • Hierarchical intelligence: Sub-agents prioritized for specialized tasks")
|
|
print(f" • Content enhancement: Dynamic cross-references added")
|
|
print(f" • Backward compatibility: Individual agents work unchanged")
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(test_composed_agents()) |