AG2
AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at: https://discord.gg/sNGSwQME3x
What is AG2?
AG2 is a Model Context Protocol (MCP) server that allows AI assistants like Claude, Cursor, and VS Code to ag2 (formerly autogen): the open-source agentos.join us at: https://discord.gg/sngswqme3x
AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at: https://discord.gg/sNGSwQME3x
This server falls under the Coding Agents category on MCPgee, the world's largest MCP server directory with 33,000+ servers.
Features
- AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at:
Use Cases
Maintainer
Works with
Installation
Manual Installation
npx ag2Configuration
Configuration Details
claude_desktop_config.json
Performance
Response Metrics
Resource Usage
How to Set Up and Use AG2
AG2 (formerly AutoGen) is the open-source AgentOS from ag2ai that provides a framework for building multi-agent AI systems with support for conversable agents, group chats, swarms, nested agents, and agent-to-agent (A2A) communication. It supports structured outputs, RAG, code execution, tool registration via register_function(), and integrates with any OpenAI-compatible LLM provider. Developers and researchers use AG2 to orchestrate complex multi-step workflows where multiple specialized agents collaborate to solve tasks that a single LLM call cannot handle.
Prerequisites
- Python 3.10 or higher
- pip for package installation
- An OpenAI API key or another supported LLM provider's credentials
- A config file (e.g. OAI_CONFIG_LIST) listing your model and API key
- An MCP-compatible client if using AG2's MCP server integration
Install AG2 with the OpenAI extra
Install the ag2 package with the openai extra for LLM access. On Mac, wrap the extra in single quotes. On Windows/Linux, square brackets work without quotes.
# macOS
pip install 'ag2[openai]'
# Windows / Linux
pip install ag2[openai]Create your LLM configuration file
Create an OAI_CONFIG_LIST JSON file with your model name and API key. Add this file to .gitignore to prevent accidental commits.
[
{
"model": "gpt-4o",
"api_key": "<your OpenAI API key here>"
}
]Create a basic two-agent conversation
Write a Python script that loads the LLM config and creates two ConversableAgents. The UserProxyAgent acts as a human proxy to kick off the conversation.
from autogen import ConversableAgent, LLMConfig
llm_config = LLMConfig.from_json(path="OAI_CONFIG_LIST")
coder = ConversableAgent(
name="coder",
system_message="You are an expert Python developer. Write clean, well-commented code.",
llm_config=llm_config,
)
reviewer = ConversableAgent(
name="reviewer",
system_message="Review code for bugs, style, and performance issues.",
llm_config=llm_config,
)
coder.initiate_chat(reviewer, message="Write a Python function to compute fibonacci numbers.")Register custom tools with an agent
Extend agent capabilities by registering Python functions as callable tools using register_function. The executor agent runs the function while the LLM agent decides when to call it.
from autogen import register_function
def web_search(query: str) -> str:
"""Search the web for information."""
return f"Search results for: {query}"
register_function(web_search, caller=coder, executor=reviewer, description="Search the web")Add AG2 to your MCP client configuration
Configure Claude Desktop or another MCP client to launch the AG2 MCP server. Replace the path with the actual location of your AG2 server entry point.
{
"mcpServers": {
"ag2": {
"command": "npx",
"args": ["ag2"]
}
}
}AG2 Examples
Client configuration
MCP client configuration for connecting to the AG2 MCP server.
{
"mcpServers": {
"ag2": {
"command": "npx",
"args": ["ag2"]
}
}
}Prompts to try
Use AG2's multi-agent framework through your MCP-connected client.
- "Create a group chat with a coder agent and a reviewer agent to write and review a REST API client in Python"
- "Set up a swarm of agents to research, outline, and write a blog post about quantum computing"
- "Build a UserProxyAgent workflow that asks me to approve each step before the coder executes it"
- "Use AG2 to create an agent that can search the web and summarize findings into a structured report"Troubleshooting AG2
ImportError: cannot import name 'ConversableAgent' from 'autogen'
AG2 is the continuation of AutoGen. Make sure you have installed ag2 (not pyautogen or autogen-agentchat). Run: pip uninstall autogen pyautogen && pip install 'ag2[openai]'
LLMConfig.from_json raises FileNotFoundError
Ensure OAI_CONFIG_LIST exists in your current working directory, or provide an absolute path to the file. The file must be valid JSON containing a list of model config objects.
Agents loop indefinitely without terminating
Set a max_consecutive_auto_reply on the UserProxyAgent (e.g. max_consecutive_auto_reply=10), or add a termination condition using is_termination_msg to stop the conversation when a specific phrase appears.
Frequently Asked Questions about AG2
What is AG2?
AG2 is a Model Context Protocol (MCP) server that ag2 (formerly autogen): the open-source agentos.join us at: https://discord.gg/sngswqme3x It connects AI assistants to external tools and data sources through a standardized interface.
How do I install AG2?
Follow the installation instructions on the AG2 GitHub repository. Clone the repo, install dependencies, and add the server config to your AI client.
Which AI clients work with AG2?
AG2 works with all major MCP-compatible AI clients including Claude Desktop, Claude Code, Cursor, VS Code (GitHub Copilot), Windsurf, and Cline.
Is AG2 free to use?
Yes, AG2 is open source and available under the Apache-2.0 license. You can use it freely in both personal and commercial projects.
AG2 Alternatives — Similar Coding Agents Servers
Looking for alternatives to AG2? Here are other popular coding agents servers you can use with Claude, Cursor, and VS Code.
Dify
★ 142.2kProduction-ready platform for agentic workflow development.
Ruflo
★ 54.0k🌊 The leading agent orchestration platform for Claude. Deploy intelligent multi-agent swarms, coordinate autonomous workflows, and build conversational AI systems. Features enterprise-grade architecture, self-learning swarm intelligence, RAG integrat
Goose
★ 45.7kan open source, extensible AI agent that goes beyond code suggestions - install, execute, edit, and test with any LLM
Antigravity Awesome Skills
★ 38.3kInstallable GitHub library of 1,400+ agentic skills for Claude Code, Cursor, Codex CLI, Gemini CLI, Antigravity, and more. Includes installer CLI, bundles, workflows, and official/community skill collections.
AgentScope
★ 25.5kBuild and run agents you can see, understand and trust.
Serena
★ 24.5kA coding agent toolkit that provides IDE-like semantic code retrieval and editing tools, enabling LLMs to efficiently navigate and modify codebases using symbol-level operations instead of basic file reading and string replacements.
Browse More Coding Agents MCP Servers
Explore all coding agents servers available in the MCPgee directory. Each server includes setup guides for Claude, Cursor, and VS Code.
Set Up AG2 in Your Editor
Choose your AI client for step-by-step setup instructions.
Quick Config Preview
Add this to your claude_desktop_config.json or .cursor/mcp.json
Ready to use AG2?
Browse our complete directory of 33,000+ MCP servers, read setup guides for your editor, and start building with the Model Context Protocol.