AG2

v1.0.0Coding Agentsstable

AG2 (formerly AutoGen): The Open-Source AgentOS.Join us at: https://discord.gg/sNGSwQME3x

a2aag2agent-frameworkagenticagentic-ai
Share:
4,590
Stars
0
Downloads
0
Weekly
0/5

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

Open-source AgentOS for multi-agent workflows
Enable agent-to-agent communication and collaboration
ag2ai

Maintainer

LicenseApache-2.0
Languagepython
Versionv1.0.0
UpdatedMay 22, 2026
Statushealthy
Maintenanceactive

Works with

ClaudeOpenAIwindowsmacoslinux

Installation

Manual Installation

npx ag2

Configuration

Configuration Details

Config File

claude_desktop_config.json

Performance

Response Metrics

Response Time< 200ms
ThroughputMedium

Resource Usage

Memory UsageLow
CPU UsageLow

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
1

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]
2

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>"
  }
]
3

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.")
4

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")
5

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.

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.

Quick Config Preview

{ "mcpServers": { "ag2": { "command": "npx", "args": ["-y", "ag2"] } } }

Add this to your claude_desktop_config.json or .cursor/mcp.json

Read the full setup guide →

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.

33,000+ ServersFree & Open SourceStep-by-Step Guides