Skip to content

fix(agent): surface MCP discovery scope errors#2861

Open
tracerat[bot] wants to merge 1 commit into
mainfrom
fix/mcp-scope-error-detail
Open

fix(agent): surface MCP discovery scope errors#2861
tracerat[bot] wants to merge 1 commit into
mainfrom
fix/mcp-scope-error-detail

Conversation

@tracerat

@tracerat tracerat Bot commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • surface the failing agent scope in strict MCP discovery errors
  • include the failing MCP server name and HTTP status when available
  • add focused regression coverage for strict MCP discovery error details

Testing

  • uv run ruff format tracecat/agent/mcp/user_client.py packages/tracecat-ee/tracecat_ee/agent/activities.py tests/unit/test_agent_mcp_user_client.py tests/unit/test_agent_activities.py
  • uv run ruff check tracecat/agent/mcp/user_client.py packages/tracecat-ee/tracecat_ee/agent/activities.py tests/unit/test_agent_mcp_user_client.py tests/unit/test_agent_activities.py
  • uv run python -m compileall -q tracecat/agent/mcp/user_client.py packages/tracecat-ee/tracecat_ee/agent/activities.py
  • uv run python - <<'PY' ... direct formatting assertions

Note

  • uv run pytest tests/unit/test_agent_mcp_user_client.py -q is blocked locally because the test harness requires Postgres on localhost:5432, which is not running in this environment.

Summary by cubic

Show which agent scope and MCP server failed during strict discovery, and include HTTP status codes when available. Improves error messages and logs for faster debugging.

  • Bug Fixes
    • Use MCPToolDiscoveryError in UserMCPClient.discover_tools to include server_name and HTTP status (if present).
    • Add _http_status_code_from_exception and _mcp_discovery_error_message; logs now include scope, server, and status; strict errors raise a detailed ApplicationError.
    • Add focused unit tests for strict error messages and HTTP status propagation.

Written for commit 34c1d0b. Summary will update on new commits.

Review in cubic

@daryllimyt

Copy link
Copy Markdown
Contributor

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 34c1d0b45b

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

http_status_code=status_code,
error_type=type(e).__name__,
server_count=len(hydrated_servers),
configured_mcp_servers=[cfg["name"] for cfg in http_servers],

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Remove tenant MCP server names from logs

For any MCP discovery failure this now serializes every configured MCP server name into activity logs. These names are tenant-supplied identifiers and the repo-wide AGENTS.md rule says not to put customer-provided identifiers in logs; logging the full configured list also exposes unrelated server names when only one server failed. Please drop this field or replace it with a count/redacted value.

Useful? React with 👍 / 👎.

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.

1 participant