autogen icon indicating copy to clipboard operation
autogen copied to clipboard

Improve error messages for missing MCP server dependencies in AssistantAgent

Open KlementMultiverse opened this issue 8 months ago • 2 comments

Problem

When users follow the MCP Server quickstart example in the README and run code without installing the required MCP server (e.g., @playwright/mcp), they encounter cryptic error messages that don't clearly indicate the root cause or remediation steps.

For example, attempting to use Playwright-based browsing without running npm install -g @playwright/mcp@latest first results in generic connection or import errors rather than a helpful message pointing to the missing installation step.

Why This Matters

The MCP integration pattern is becoming a primary way users extend AutoGen agents with tools. The README explicitly documents this workflow, but the error experience breaks the documented flow. New users waste time debugging network/import issues when the solution is a single npm command.

Current Behavior

  • User runs MCP Server quickstart code
  • MCP server is not installed or running
  • Error message is generic (connection timeout, module not found, etc.)
  • User has no clear path to fix the issue

Expected Behavior

When an agent attempts to connect to an MCP server and the connection fails, the error message should:

  1. Explicitly state which MCP server is missing or unreachable
  2. Provide the exact installation command (e.g., npm install -g @playwright/mcp@latest)
  3. Suggest checking if the server is running locally
  4. Link to the relevant documentation section

Example

MCPConnectionError: Could not connect to MCP server 'playwright' at localhost:5000.

This usually means the server is not installed or running.

To install: npm install -g @playwright/mcp@latest
To start: mcp-playwright (or see https://...)

If already installed, verify the server is running and accessible.

Suggested Implementation

Enhance error handling in autogen_agentchat/agents/assistant_agent.py where MCP connections are initialized. Check the connection attempt and catch connection/timeout errors, then provide context-specific guidance based on which server was being connected to.

Consider maintaining a small registry mapping MCP server names to installation instructions (e.g., in autogen_ext/mcp/ or similar).


Contributed by Klement Gunndu

KlementMultiverse avatar Mar 03 '26 06:03 KlementMultiverse

Opened a fix PR: https://github.com/microsoft/autogen/pull/7339

This adds actionable MCP startup guidance (including Playwright install hints) when MCP stdio dependencies are missing and updates tests for the new error paths.

Rishirandhawa avatar Mar 03 '26 21:03 Rishirandhawa

Withdrawing this issue. Apologies for any inconvenience.

KlementMultiverse avatar Mar 09 '26 02:03 KlementMultiverse