Skip to content

fix: show MCP config file paths correctly in error messages#2785

Draft
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/mcp-config-error-path-display
Draft

fix: show MCP config file paths correctly in error messages#2785
laileni-aws wants to merge 1 commit into
aws:mainfrom
laileni-aws:fix/mcp-config-error-path-display

Conversation

@laileni-aws

Copy link
Copy Markdown
Contributor

Problem

When MCP config loading fails, the error is shown to the user (in the MCP servers view / status), and the message embeds the config file path. That message is rendered as markdown, so a Windows path segment such as \.aws has its backslash stripped (\. is a markdown escape). The path is therefore displayed incorrectly — e.g. C:\Users\me\.aws\amazonq\mcp.json shows as C:\Users\me.aws\amazonq\mcp.json.

This misleads users into thinking Amazon Q is looking at the wrong path (a reported case: a user concluded "it's a path issue, the file doesn't exist" when the path was actually correct and their mcp.json was simply empty — "Unexpected end of JSON input").

Fix

Wrap the file path in a markdown code span (backticks) so it renders verbatim, including backslashes:

  • server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpUtils.ts: the "Failed to read", "Invalid JSON", and "missing/invalid mcpServers" messages now wrap the path as `<path>`.
  • mcpManager.ts (getConfigLoadErrors): the File: <path> prefix now wraps the path/server key as File: `<path>`.

Testing

  • Updated mcpManager.test.ts assertions for the new File: `…``` format.
  • Added a test asserting a Windows path containing a \.aws segment is wrapped in a code span (so its backslash survives markdown rendering).
  • Ran the MCP unit tests (mcpManager.test.ts + mcpUtils.test.ts): 112 passing.
  • prettier --check passes; eslint reports no new issues (only pre-existing warnings unrelated to this change).

Notes

  • This corrects the misleading path display; the underlying config errors (e.g. empty/invalid mcp.json) are unchanged and still reported.

MCP config load errors embed the file path and are rendered as markdown
in the UI. For Windows paths, a segment such as "\.aws" had its
backslash stripped by the markdown parser, so the path was displayed
incorrectly (e.g. C:\Users\me.aws\... instead of C:\Users\me\.aws\...),
which misled users into thinking the path was wrong.

Wrap the file path in a code span (backticks) in the config-load error
messages and in the 'File: <path>' prefix so paths render verbatim.
Updates and adds unit tests, including a Windows path with a ".aws"
segment.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 60.16%. Comparing base (abb1096) to head (0e08f9e).

Files with missing lines Patch % Lines
.../language-server/agenticChat/tools/mcp/mcpUtils.ts 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2785      +/-   ##
==========================================
- Coverage   60.20%   60.16%   -0.05%     
==========================================
  Files         281      281              
  Lines       71191    71194       +3     
  Branches     4575     4560      -15     
==========================================
- Hits        42861    42832      -29     
- Misses      28241    28274      +33     
+ Partials       89       88       -1     
Flag Coverage Δ
unittests 60.16% <85.71%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

2 participants