mirror of
https://github.com/microsoft/autogen.git
synced 2026-01-10 11:17:55 -05:00
Add warning for MCP server docs (#6901)
This commit is contained in:
75
README.md
75
README.md
@@ -11,10 +11,6 @@
|
||||
|
||||
</div>
|
||||
|
||||
<div align="center" style="background-color: rgba(255, 235, 59, 0.5); padding: 10px; border-radius: 5px; margin: 20px 0;">
|
||||
<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>.
|
||||
</div>
|
||||
|
||||
# AutoGen
|
||||
|
||||
**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:
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
### Web Browsing Agent Team
|
||||
|
||||
Create a group chat team with a web surfer agent and a user proxy agent
|
||||
for web browsing tasks. You need to install [playwright](https://playwright.dev/python/docs/library).
|
||||
### MCP Server
|
||||
|
||||
```python
|
||||
# pip install -U autogen-agentchat autogen-ext[openai,web-surfer]
|
||||
# playwright install
|
||||
# First run `npm install -g @playwright/mcp@latest` to install the MCP server.
|
||||
import asyncio
|
||||
from autogen_agentchat.agents import UserProxyAgent
|
||||
from autogen_agentchat.conditions import TextMentionTermination
|
||||
from autogen_agentchat.agents import AssistantAgent
|
||||
from autogen_agentchat.teams import RoundRobinGroupChat
|
||||
from autogen_agentchat.conditions import TextMessageTermination
|
||||
from autogen_agentchat.ui import Console
|
||||
from autogen_ext.models.openai import OpenAIChatCompletionClient
|
||||
from autogen_ext.agents.web_surfer import MultimodalWebSurfer
|
||||
from autogen_ext.tools.mcp import McpWorkbench, StdioServerParams
|
||||
|
||||
|
||||
async def main() -> None:
|
||||
model_client = OpenAIChatCompletionClient(model="gpt-4o")
|
||||
# The web surfer will open a Chromium browser window to perform web browsing tasks.
|
||||
web_surfer = MultimodalWebSurfer("web_surfer", model_client, headless=False, animate_actions=True)
|
||||
# The user proxy agent is used to get user input after each step of the web surfer.
|
||||
# NOTE: you can skip input by pressing Enter.
|
||||
user_proxy = UserProxyAgent("user_proxy")
|
||||
# The termination condition is set to end the conversation when the user types 'exit'.
|
||||
termination = TextMentionTermination("exit", sources=["user_proxy"])
|
||||
# Web surfer and user proxy take turns in a round-robin fashion.
|
||||
team = RoundRobinGroupChat([web_surfer, user_proxy], termination_condition=termination)
|
||||
try:
|
||||
# Start the team and wait for it to terminate.
|
||||
await Console(team.run_stream(task="Find information about AutoGen and write a short summary."))
|
||||
finally:
|
||||
await web_surfer.close()
|
||||
await model_client.close()
|
||||
model_client = OpenAIChatCompletionClient(model="gpt-4.1")
|
||||
server_params = StdioServerParams(
|
||||
command="npx",
|
||||
args=[
|
||||
"@playwright/mcp@latest",
|
||||
"--headless",
|
||||
],
|
||||
)
|
||||
async with McpWorkbench(server_params) as mcp:
|
||||
agent = AssistantAgent(
|
||||
"web_browsing_assistant",
|
||||
model_client=model_client,
|
||||
workbench=mcp, # For multiple MCP servers, put them in a list.
|
||||
model_client_stream=True,
|
||||
max_tool_iterations=10,
|
||||
)
|
||||
team = RoundRobinGroupChat(
|
||||
[agent],
|
||||
termination_condition=TextMessageTermination(source="web_browsing_assistant"),
|
||||
)
|
||||
await Console(team.run_stream(task="Find out how many contributors for the microsoft/autogen repository"))
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
```
|
||||
|
||||
> **Warning**: Only connect to trusted MCP servers as they may execute commands
|
||||
> in your local environment or expose sensitive information.
|
||||
|
||||
### AutoGen Studio
|
||||
|
||||
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
|
||||
|
||||
<div align="center">
|
||||
|
||||
| | [](./python) | [](./dotnet) | [](./python/packages/autogen-studio) |
|
||||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Installation | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/installation.html) | [](https://microsoft.github.io/autogen/dotnet/dev/core/installation.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/installation.html) |
|
||||
| Quickstart | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/quickstart.html#) | [](https://microsoft.github.io/autogen/dotnet/dev/core/index.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
|
||||
| Tutorial | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/index.html) | [](https://microsoft.github.io/autogen/dotnet/dev/core/tutorial.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
|
||||
| API Reference | [](https://microsoft.github.io/autogen/stable/reference/index.html#) | [](https://microsoft.github.io/autogen/dotnet/dev/api/Microsoft.AutoGen.Contracts.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html) |
|
||||
| Packages | [](https://pypi.org/project/autogen-core/) <br> [](https://pypi.org/project/autogen-agentchat/) <br> [](https://pypi.org/project/autogen-ext/) | [](https://www.nuget.org/packages/Microsoft.AutoGen.Contracts/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.Core/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.Core.Grpc/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.RuntimeGateway.Grpc/) | [](https://pypi.org/project/autogenstudio/) |
|
||||
| | [](./python) | [](./dotnet) | [](./python/packages/autogen-studio) |
|
||||
| ------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||
| Installation | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/installation.html) | [](https://microsoft.github.io/autogen/dotnet/dev/core/installation.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/installation.html) |
|
||||
| Quickstart | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/quickstart.html#) | [](https://microsoft.github.io/autogen/dotnet/dev/core/index.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
|
||||
| Tutorial | [](https://microsoft.github.io/autogen/stable/user-guide/agentchat-user-guide/tutorial/index.html) | [](https://microsoft.github.io/autogen/dotnet/dev/core/tutorial.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html#) |
|
||||
| API Reference | [](https://microsoft.github.io/autogen/stable/reference/index.html#) | [](https://microsoft.github.io/autogen/dotnet/dev/api/Microsoft.AutoGen.Contracts.html) | [](https://microsoft.github.io/autogen/stable/user-guide/autogenstudio-user-guide/usage.html) |
|
||||
| Packages | [](https://pypi.org/project/autogen-core/) <br> [](https://pypi.org/project/autogen-agentchat/) <br> [](https://pypi.org/project/autogen-ext/) | [](https://www.nuget.org/packages/Microsoft.AutoGen.Contracts/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.Core/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.Core.Grpc/) <br> [](https://www.nuget.org/packages/Microsoft.AutoGen.RuntimeGateway.Grpc/) | [](https://pypi.org/project/autogenstudio/) |
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
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!
|
||||
|
||||
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.
|
||||
|
||||
@@ -13,6 +13,11 @@ async def mcp_server_tools(
|
||||
) -> list[StdioMcpToolAdapter | SseMcpToolAdapter | StreamableHttpMcpToolAdapter]:
|
||||
"""Creates a list of MCP tool adapters that can be used with AutoGen agents.
|
||||
|
||||
.. warning::
|
||||
|
||||
Only connect to trusted MCP servers, especially when using
|
||||
`StdioServerParams` as it executes commands in the local environment.
|
||||
|
||||
This factory function connects to an MCP server and returns adapters for all available tools.
|
||||
The adapters can be directly assigned to an AutoGen agent's tools list.
|
||||
|
||||
|
||||
@@ -48,6 +48,11 @@ class McpWorkbench(Workbench, Component[McpWorkbenchConfig]):
|
||||
"""A workbench that wraps an MCP server and provides an interface
|
||||
to list and call tools provided by the server.
|
||||
|
||||
.. warning::
|
||||
|
||||
Only connect to trusted MCP servers, especially when using
|
||||
`StdioServerParams` as it executes commands in the local environment.
|
||||
|
||||
This workbench should be used as a context manager to ensure proper
|
||||
initialization and cleanup of the underlying MCP session.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user