Fix Amp MCP config parsing to support JSON with comments#386
Conversation
- Add loadConfigForAmp function using github.com/marcozac/go-jsonc library - Modify Detect and Uninstall functions to use JSONC parsing for IsAMP configs - Resolves 'invalid character \'/\' looking for beginning of value' error - Maintains backward compatibility for non-Amp MCP configs Co-Authored-By: Rick Blalock <rickblalock@mac.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
| return &config, nil | ||
| } | ||
|
|
||
| func loadConfigForAmp(path string) (*MCPConfig, error) { |
There was a problem hiding this comment.
lets just use this for loadConfig not just for AMP that way we can have JSON comments in other mcp configs too
- Replace loadConfig function to use jsonc.Unmarshal for all configs - Remove loadConfigForAmp function and conditional logic - All MCP configs now support JSON with comments, not just Amp configs - Addresses GitHub PR feedback to enable comments in all MCP configs Co-Authored-By: Rick Blalock <rickblalock@mac.com>
This completes the JSONC parsing fix started in PR #386. While the loadConfig function was updated to use jsonc.Unmarshal, the custom MCPConfig.UnmarshalJSON method still used json.Unmarshal in three locations, causing the 'invalid character \'/\' looking for beginning of value' error to persist when parsing VS Code settings with comments. Updated all three json.Unmarshal calls to jsonc.Unmarshal: - Line 69: Unmarshaling into auxiliary struct - Line 74: Unmarshaling into map for extra fields - Line 85: Unmarshaling individual values in extra fields This ensures consistent JSONC parsing throughout the MCP config system. Co-Authored-By: Rick Blalock <rickblalock@mac.com>
* Fix MCPConfig.UnmarshalJSON to use JSONC parsing for comment support This completes the JSONC parsing fix started in PR #386. While the loadConfig function was updated to use jsonc.Unmarshal, the custom MCPConfig.UnmarshalJSON method still used json.Unmarshal in three locations, causing the 'invalid character \'/\' looking for beginning of value' error to persist when parsing VS Code settings with comments. Updated all three json.Unmarshal calls to jsonc.Unmarshal: - Line 69: Unmarshaling into auxiliary struct - Line 74: Unmarshaling into map for extra fields - Line 85: Unmarshaling individual values in extra fields This ensures consistent JSONC parsing throughout the MCP config system. Co-Authored-By: Rick Blalock <rickblalock@mac.com> * Complete JSONC parsing fix: convert MarshalJSON method and add comprehensive tests - Fix remaining json.Unmarshal call in MarshalJSON method to use jsonc.Unmarshal - Add comprehensive test cases for JSONC comment support including: - User's exact case: /* test */ comment at top of JSON - Single line comments (//) - Multi-line comments (/* */) - Mixed comment types - Empty JSON with comments - Comments at end of JSON - Complete load-save cycle testing - Cursor settings with comments testing This completes the JSONC parsing implementation throughout the entire MCP config system, resolving the persistent 'unexpected end of JSON input' error when parsing VS Code/Cursor settings files containing comments. Co-Authored-By: Rick Blalock <rickblalock@mac.com> --------- Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Rick Blalock <rickblalock@mac.com>
Fix Amp MCP Config Parsing to Support JSON with Comments
Problem
The Agentuity CLI was failing to load MCP config for Amp (VS Code) with the error:
This error occurred because Amp configurations attempt to parse VS Code's
settings.jsonfile, which contains comments that are valid in VS Code but invalid in strict JSON parsing.Solution
loadConfigForAmpfunction that uses the existinggithub.com/marcozac/go-jsonclibrary to parse JSON with commentsDetectandUninstallfunctions to conditionally use JSONC parsing for Amp configs (identified byIsAMP: true)Changes
github.com/marcozac/go-jsoncloadConfigForAmp()function using JSONC parsingDetect()andUninstall()functions to use appropriate parser based onconfig.IsAMPflagTesting
go build -vLink to Devin run
https://app.devin.ai/sessions/7144f22861c54068a3f3690e22c3bf60
Requested by: jhaynie@agentuity.com