This document provides a comprehensive guide for integrating the AI-Agent framework with the ai-agent solution, focusing on the Model Context Protocol (MCP) compatibility, agent orchestration, and extensibility points.
AI-Agent is an open-source framework for building general AI agents, designed to provide similar functionality to proprietary agent systems. It offers a flexible architecture for creating, configuring, and deploying AI agents with various capabilities, including:
- Tool-based agent interactions
- Model Context Protocol (MCP) integration
- Browser automation
- Multi-agent workflows
- Extensible tool ecosystem
The integration between our ai-agent solution and AI-Agent can be structured in several ways, depending on your specific requirements:
The most direct integration path leverages the Model Context Protocol (MCP) compatibility in both systems:
┌─────────────┐ ┌───────────────┐ ┌────────────┐
│ ai-agent │ │ MCP Protocol │ │ AI-Agent │
│ (.NET API) ├────►│ Communication ├────►│ Agents │
└─────────────┘ └───────────────┘ └────────────┘
Our ai-agent solution includes DynamicExternalAccessTool.cs and QwenDialogueTool.cs in the Agent.Core/McpTools/ directory, which can be extended to communicate with AI-Agent agents through the MCP protocol.
Both frameworks can share and extend the same tool ecosystem:
┌───────────────────┐
│ Shared Tool │
│ Ecosystem │
└─┬─────────────────┘
│
┌───────────┴───────────┐
│ │
┌──────▼──────┐ ┌──────▼──────┐
│ ai-agent │ │ AI-Agent │
│ Framework │ │ Framework │
└─────────────┘ └─────────────┘
This approach allows for consistent tool behavior across both frameworks while maintaining independent agent implementations.
For more complex scenarios, a hybrid deployment can be implemented:
┌─────────────────────────────────────────────┐
│ │
│ ┌─────────────┐ ┌────────────┐ │
│ │ ai-agent │ │ AI-Agent │ │
│ │ Components │◄────────►│ Components │ │
│ └─────────────┘ └────────────┘ │
│ │
│ Integrated Application │
└─────────────────────────────────────────────┘
-
Installation:
git clone https://github.com/mannaandpoem/AI-Agent.git cd AI-Agent pip install -r requirements.txt -
Configuration: Create a
config.tomlfile in theconfigdirectory:# Global LLM configuration [llm] model = "gpt-4o" base_url = "https://api.openai.com/v1" api_key = "sk-..." # Your API key max_tokens = 4096 temperature = 0.0
AI-Agent can be run as an MCP server that our ai-agent solution can connect to:
python run_mcp_server.pyThis starts an MCP server on the default port (8000) that exposes AI-Agent tools through the MCP protocol.
To connect our ai-agent solution to the AI-Agent MCP server:
-
Update the MCP Client Configuration:
Modify the
QwenServiceClient.csto connect to the AI-Agent MCP server:// Example configuration for connecting to AI-Agent MCP server var mpcConfig = new McpConfiguration { ServerUrl = "http://localhost:8000/sse", ConnectionType = "sse" };
-
Extend the DynamicExternalAccessTool:
The existing
DynamicExternalAccessTool.cscan be extended to handle AI-Agent-specific tools:// Example extension for AI-Agent tools public async Task<ToolResponse> HandleAI-AgentToolAsync(string toolName, JObject parameters) { // Implementation for handling AI-Agent-specific tools // ... }
To create a shared tool ecosystem:
-
Define Common Tool Interfaces:
Create shared interfaces that both frameworks can implement:
// In ai-agent public interface ISharedTool { string Name { get; } string Description { get; } Task<object> ExecuteAsync(JObject parameters); }
-
Implement Tools in Both Frameworks:
Implement the same tools in both frameworks following the shared interfaces.
-
Tool Registration:
Register the tools in both frameworks:
// In ai-agent toolRegistry.RegisterTool(new SharedSearchTool());
# In AI-Agent tools.register(SharedSearchTool())
For complex workflows requiring bidirectional communication between agents:
┌─────────────┐ ┌───────────────┐ ┌────────────┐
│ ai-agent │◄───►│ Message Queue │◄───►│ AI-Agent │
│ Agents │ │ (e.g., Redis) │ │ Agents │
└─────────────┘ └───────────────┘ └────────────┘
Implementation steps:
- Set up a message queue (Redis, RabbitMQ, etc.)
- Implement message producers and consumers in both frameworks
- Define a common message format for agent communication
For maintaining consistent state across frameworks:
┌─────────────┐ ┌───────────────┐ ┌────────────┐
│ ai-agent │◄───►│ Shared State │◄───►│ AI-Agent │
│ Framework │ │ Database │ │ Framework │
└─────────────┘ └───────────────┘ └────────────┘
Implementation steps:
- Set up a shared database (PostgreSQL, MongoDB, etc.)
- Implement data access layers in both frameworks
- Define common data models and state transition rules
-
Consistent Configuration Management:
- Use environment variables for shared configuration
- Implement configuration validation in both frameworks
-
Error Handling and Logging:
- Implement consistent error handling patterns
- Use structured logging with correlation IDs across frameworks
-
Testing Integration Points:
- Create integration tests that verify cross-framework communication
- Implement contract tests for API boundaries
-
Deployment Considerations:
- Use Docker Compose for local development
- Consider Kubernetes for production deployments
- Implement health checks for all components
AI-Agent includes browser automation capabilities that can be integrated with our ai-agent solution:
// Example: Invoking AI-Agent browser automation from ai-agent
public async Task<string> PerformBrowserAutomation(string url, string action)
{
var parameters = new JObject
{
["url"] = url,
["action"] = action
};
var result = await mcpClient.InvokeTool("browser_navigate", parameters);
return result.ToString();
}Integrating AI-Agent with our ai-agent solution provides several benefits:
- Extended Tool Ecosystem: Access to AI-Agent's growing tool collection
- Flexible Agent Architectures: Combine different agent approaches for optimal solutions
- Open-Source Foundation: Build on a transparent, community-driven framework
- MCP Compatibility: Leverage the standardized Model Context Protocol for seamless integration
By following this integration guide, you can create powerful hybrid agent systems that leverage the strengths of both frameworks while maintaining flexibility and extensibility.