Skip to content

fix(workspace): gracefully handle invalid MCP config entries during i…#1819

Open
xliu123321 wants to merge 1 commit into
agentscope-ai:mainfrom
xliu123321:fix/workspace-mcp-loading-errors
Open

fix(workspace): gracefully handle invalid MCP config entries during i…#1819
xliu123321 wants to merge 1 commit into
agentscope-ai:mainfrom
xliu123321:fix/workspace-mcp-loading-errors

Conversation

@xliu123321

Copy link
Copy Markdown

AgentScope Version

2.0.1

Description

Fixes #1817

A single invalid MCP config entry in a workspace .mcp file (e.g. is_stateful: false for a STDIO MCP) or a single MCP connection failure would crash LocalWorkspace.initialize() entirely, making the whole workspace permanently non-functional — chat messages silently fail, workspace panels return 500.

The root cause: MCP deserialization and connection in initialize() had zero error handling, unlike skill loading in the same
method which consistently wraps operations in try/except.

Changes:

  1. MCP deserialization: replaced list comprehension with per-entry try/except — invalid entries are skipped with a warning instead of crashing.
  2. MCP connect: added per-entry try/except around mcp.connect() so one connection failure doesn't block others.

Modified files:

  • src/agentscope/workspace/_local_workspace.py — 2 logic changes, no API change
  • tests/workspace_local_test.py — 6 new tests

How to test:

pytest tests/workspace_local_test.py::TestLocalWorkspaceMCPInit -v

Checklist

- [x]  An issue has been created for this PR
- [x]  I have read the CONTRIBUTING.md
- [x]  Docstrings are in Google style
- [ ]  Related documentation has been updated in documentation repository
- [x]  Code is ready for review

…nitialize

MCP deserialization and connection in LocalWorkspace.initialize() had no
error handling, unlike skill loading in the same method. A single invalid
.mcp entry (e.g. is_stateful: false for STDIO MCP) or a single connection
failure would crash the entire workspace permanently.

Changed the list comprehension to per-entry try/except so bad entries are
skipped with a warning instead of crashing, and added per-entry error
handling around stateful MCP connect().

Fixes agentscope-ai#1817
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Single invalid MCP config entry crashes entire workspace, blocking all chat

1 participant