Skip to content

Commit c145ace

Browse files
authored
Add warning for MCP server docs (#6901)
1 parent 6a22249 commit c145ace

File tree

3 files changed

+48
-37
lines changed

3 files changed

+48
-37
lines changed

README.md

Lines changed: 38 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@
1111

1212
</div>
1313

14-
<div align="center" style="background-color: rgba(255, 235, 59, 0.5); padding: 10px; border-radius: 5px; margin: 20px 0;">
15-
<strong>Important:</strong> This is the official project. We are not affiliated with any fork or startup. See our <a href="https://x.com/pyautogen/status/1857264760951296210">statement</a>.
16-
</div>
17-
1814
# AutoGen
1915

2016
**AutoGen** is a framework for creating multi-agent AI applications that can act autonomously or work alongside humans.
@@ -55,43 +51,49 @@ async def main() -> None:
5551
asyncio.run(main())
5652
```
5753

58-
### Web Browsing Agent Team
59-
60-
Create a group chat team with a web surfer agent and a user proxy agent
61-
for web browsing tasks. You need to install [playwright](https://playwright.dev/python/docs/library).
54+
### MCP Server
6255

6356
```python
64-
# pip install -U autogen-agentchat autogen-ext[openai,web-surfer]
65-
# playwright install
57+
# First run `npm install -g @playwright/mcp@latest` to install the MCP server.
6658
import asyncio
67-
from autogen_agentchat.agents import UserProxyAgent
68-
from autogen_agentchat.conditions import TextMentionTermination
59+
from autogen_agentchat.agents import AssistantAgent
6960
from autogen_agentchat.teams import RoundRobinGroupChat
61+
from autogen_agentchat.conditions import TextMessageTermination
7062
from autogen_agentchat.ui import Console
7163
from autogen_ext.models.openai import OpenAIChatCompletionClient
72-
from autogen_ext.agents.web_surfer import MultimodalWebSurfer
64+
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
65+
7366

7467
async def main() -> None:
75-
model_client = OpenAIChatCompletionClient(model="gpt-4o")
76-
# The web surfer will open a Chromium browser window to perform web browsing tasks.
77-
web_surfer = MultimodalWebSurfer("web_surfer", model_client, headless=False, animate_actions=True)
78-
# The user proxy agent is used to get user input after each step of the web surfer.
79-
# NOTE: you can skip input by pressing Enter.
80-
user_proxy = UserProxyAgent("user_proxy")
81-
# The termination condition is set to end the conversation when the user types 'exit'.
82-
termination = TextMentionTermination("exit", sources=["user_proxy"])
83-
# Web surfer and user proxy take turns in a round-robin fashion.
84-
team = RoundRobinGroupChat([web_surfer, user_proxy], termination_condition=termination)
85-
try:
86-
# Start the team and wait for it to terminate.
87-
await Console(team.run_stream(task="Find information about AutoGen and write a short summary."))
88-
finally:
89-
await web_surfer.close()
90-
await model_client.close()
68+
model_client = OpenAIChatCompletionClient(model="gpt-4.1")
69+
server_params = StdioServerParams(
70+
command="npx",
71+
args=[
72+
"@playwright/mcp@latest",
73+
"--headless",
74+
],
75+
)
76+
async with McpWorkbench(server_params) as mcp:
77+
agent = AssistantAgent(
78+
"web_browsing_assistant",
79+
model_client=model_client,
80+
workbench=mcp, # For multiple MCP servers, put them in a list.
81+
model_client_stream=True,
82+
max_tool_iterations=10,
83+
)
84+
team = RoundRobinGroupChat(
85+
[agent],
86+
termination_condition=TextMessageTermination(source="web_browsing_assistant"),
87+
)
88+
await Console(team.run_stream(task="Find out how many contributors for the microsoft/autogen repository"))
89+
9190

9291
asyncio.run(main())
9392
```
9493

94+
> **Warning**: Only connect to trusted MCP servers as they may execute commands
95+
> in your local environment or expose sensitive information.
96+
9597
### AutoGen Studio
9698

9799
Use AutoGen Studio to prototype and run multi-agent workflows without writing code.
@@ -132,17 +134,16 @@ With AutoGen you get to join and contribute to a thriving ecosystem. We host wee
132134

133135
<div align="center">
134136

135-
| | [![Python](https://img.shields.io/badge/AutoGen-Python-blue?logo=python&logoColor=white)](./python) | [![.NET](https://img.shields.io/badge/AutoGen-.NET-green?logo=.net&logoColor=white)](./dotnet) | [![Studio](https://img.shields.io/badge/AutoGen-Studio-purple?logo=visual-studio&logoColor=white)](./python/packages/autogen-studio) |
136-
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
137-
| Installation | [![Installation](https://img.shields.io/badge/Install-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/installation.html) | [![Install](https://img.shields.io/badge/Install-green)](https://microsoft.github.io/autogen/dotnet/dev/core/installation.html) | [![Install](https://img.shields.io/badge/Install-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/installation.html) |
138-
| Quickstart | [![Quickstart](https://img.shields.io/badge/Quickstart-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/quickstart.html#) | [![Quickstart](https://img.shields.io/badge/Quickstart-green)](https://microsoft.github.io/autogen/dotnet/dev/core/index.html) | [![Usage](https://img.shields.io/badge/Quickstart-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
139-
| Tutorial | [![Tutorial](https://img.shields.io/badge/Tutorial-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/index.html) | [![Tutorial](https://img.shields.io/badge/Tutorial-green)](https://microsoft.github.io/autogen/dotnet/dev/core/tutorial.html) | [![Usage](https://img.shields.io/badge/Tutorial-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
140-
| API Reference | [![API](https://img.shields.io/badge/Docs-blue)](https://microsoft.github.io/autogen/stable/reference/index.html#) | [![API](https://img.shields.io/badge/Docs-green)](https://microsoft.github.io/autogen/dotnet/dev/api/Microsoft.AutoGen.Contracts.html) | [![API](https://img.shields.io/badge/Docs-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html) |
141-
| Packages | [![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/) <br> [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/) <br> [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/) | [![NuGet Contracts](https://img.shields.io/badge/NuGet-Contracts-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Contracts/) <br> [![NuGet Core](https://img.shields.io/badge/NuGet-Core-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Core/) <br> [![NuGet Core.Grpc](https://img.shields.io/badge/NuGet-Core.Grpc-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Core.Grpc/) <br> [![NuGet RuntimeGateway.Grpc](https://img.shields.io/badge/NuGet-RuntimeGateway.Grpc-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.RuntimeGateway.Grpc/) | [![PyPi autogenstudio](https://img.shields.io/badge/PyPi-autogenstudio-purple?logo=pypi)](https://pypi.org/project/autogenstudio/) |
137+
| | [![Python](https://img.shields.io/badge/AutoGen-Python-blue?logo=python&logoColor=white)](./python) | [![.NET](https://img.shields.io/badge/AutoGen-.NET-green?logo=.net&logoColor=white)](./dotnet) | [![Studio](https://img.shields.io/badge/AutoGen-Studio-purple?logo=visual-studio&logoColor=white)](./python/packages/autogen-studio) |
138+
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
139+
| Installation | [![Installation](https://img.shields.io/badge/Install-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/installation.html) | [![Install](https://img.shields.io/badge/Install-green)](https://microsoft.github.io/autogen/dotnet/dev/core/installation.html) | [![Install](https://img.shields.io/badge/Install-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/installation.html) |
140+
| Quickstart | [![Quickstart](https://img.shields.io/badge/Quickstart-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/quickstart.html#) | [![Quickstart](https://img.shields.io/badge/Quickstart-green)](https://microsoft.github.io/autogen/dotnet/dev/core/index.html) | [![Usage](https://img.shields.io/badge/Quickstart-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
141+
| Tutorial | [![Tutorial](https://img.shields.io/badge/Tutorial-blue)](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/index.html) | [![Tutorial](https://img.shields.io/badge/Tutorial-green)](https://microsoft.github.io/autogen/dotnet/dev/core/tutorial.html) | [![Usage](https://img.shields.io/badge/Tutorial-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
142+
| API Reference | [![API](https://img.shields.io/badge/Docs-blue)](https://microsoft.github.io/autogen/stable/reference/index.html#) | [![API](https://img.shields.io/badge/Docs-green)](https://microsoft.github.io/autogen/dotnet/dev/api/Microsoft.AutoGen.Contracts.html) | [![API](https://img.shields.io/badge/Docs-purple)](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html) |
143+
| Packages | [![PyPi autogen-core](https://img.shields.io/badge/PyPi-autogen--core-blue?logo=pypi)](https://pypi.org/project/autogen-core/) <br> [![PyPi autogen-agentchat](https://img.shields.io/badge/PyPi-autogen--agentchat-blue?logo=pypi)](https://pypi.org/project/autogen-agentchat/) <br> [![PyPi autogen-ext](https://img.shields.io/badge/PyPi-autogen--ext-blue?logo=pypi)](https://pypi.org/project/autogen-ext/) | [![NuGet Contracts](https://img.shields.io/badge/NuGet-Contracts-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Contracts/) <br> [![NuGet Core](https://img.shields.io/badge/NuGet-Core-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Core/) <br> [![NuGet Core.Grpc](https://img.shields.io/badge/NuGet-Core.Grpc-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.Core.Grpc/) <br> [![NuGet RuntimeGateway.Grpc](https://img.shields.io/badge/NuGet-RuntimeGateway.Grpc-green?logo=nuget)](https://www.nuget.org/packages/Microsoft.AutoGen.RuntimeGateway.Grpc/) | [![PyPi autogenstudio](https://img.shields.io/badge/PyPi-autogenstudio-purple?logo=pypi)](https://pypi.org/project/autogenstudio/) |
142144

143145
</div>
144146

145-
146147
Interested in contributing? See [CONTRIBUTING.md](./CONTRIBUTING.md) for guidelines on how to get started. We welcome contributions of all kinds, including bug fixes, new features, and documentation improvements. Join our community and help us make AutoGen better!
147148

148149
Have questions? Check out our [Frequently Asked Questions (FAQ)](./FAQ.md) for answers to common queries. If you don't find what you're looking for, feel free to ask in our [GitHub Discussions](https://github.com/microsoft/autogen/discussions) or join our [Discord server](https://aka.ms/autogen-discord) for real-time support. You can also read our [blog](https://devblogs.microsoft.com/autogen/) for updates.

python/packages/autogen-ext/src/autogen_ext/tools/mcp/_factory.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ async def mcp_server_tools(
1313
) -> list[StdioMcpToolAdapter | SseMcpToolAdapter | StreamableHttpMcpToolAdapter]:
1414
"""Creates a list of MCP tool adapters that can be used with AutoGen agents.
1515
16+
.. warning::
17+
18+
Only connect to trusted MCP servers, especially when using
19+
`StdioServerParams` as it executes commands in the local environment.
20+
1621
This factory function connects to an MCP server and returns adapters for all available tools.
1722
The adapters can be directly assigned to an AutoGen agent's tools list.
1823

python/packages/autogen-ext/src/autogen_ext/tools/mcp/_workbench.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ class McpWorkbench(Workbench, Component[McpWorkbenchConfig]):
4848
"""A workbench that wraps an MCP server and provides an interface
4949
to list and call tools provided by the server.
5050
51+
.. warning::
52+
53+
Only connect to trusted MCP servers, especially when using
54+
`StdioServerParams` as it executes commands in the local environment.
55+
5156
This workbench should be used as a context manager to ensure proper
5257
initialization and cleanup of the underlying MCP session.
5358

0 commit comments

Comments
 (0)