Describe the Feature
Currently, pi-mcp-adapter throws a SyntaxError when reading configuration files such as mcp.json or .mcp.json if they contain:
- line comments (
//)
- block comments (
/* ... */)
- trailing commas after the last item in an object or array
Many developers use JSONC-style config files to document environment variables, explain CLI arguments, or temporarily disable servers. In the VS Code and Claude Desktop ecosystem, this is a common and expected format.
It would be very helpful if pi-mcp-adapter could accept JSON files with comments and trailing commas.
Current Behavior
The adapter reads configuration files in config.ts and parses them directly with JSON.parse():
JSON.parse(readFileSync(configPath, "utf-8"))
Because of this, files with comments or trailing commas fail with errors like:
SyntaxError: Unexpected token / in JSON at position ...
SyntaxError: Unexpected token } in JSON at position ...
Proposed Solution
Strip comments and trailing commas from the raw file string before parsing it.
A lightweight and proven option is strip-json-comments, using its trailingCommas: true option.
Example:
import stripJsonComments from "strip-json-comments";
const rawConfig = readFileSync(configPath, "utf-8");
const config = JSON.parse(stripJsonComments(rawConfig, { trailingCommas: true }));
Additional Context
- This would improve the experience for users migrating from other MCP hosts like Cursor or VS Code, where commented config files are common.
- It would prevent unnecessary crashes when teams share
.mcp.json files in repositories.
- Supporting both comments and trailing commas makes the config format much more practical for hand-edited files.
Describe the Feature
Currently,
pi-mcp-adapterthrows aSyntaxErrorwhen reading configuration files such asmcp.jsonor.mcp.jsonif they contain://)/* ... */)Many developers use JSONC-style config files to document environment variables, explain CLI arguments, or temporarily disable servers. In the VS Code and Claude Desktop ecosystem, this is a common and expected format.
It would be very helpful if
pi-mcp-adaptercould accept JSON files with comments and trailing commas.Current Behavior
The adapter reads configuration files in
config.tsand parses them directly withJSON.parse():Because of this, files with comments or trailing commas fail with errors like:
SyntaxError: Unexpected token / in JSON at position ...SyntaxError: Unexpected token } in JSON at position ...Proposed Solution
Strip comments and trailing commas from the raw file string before parsing it.
A lightweight and proven option is
strip-json-comments, using itstrailingCommas: trueoption.Example:
Additional Context
.mcp.jsonfiles in repositories.