Add support for Claude MCP.json configuration files in CLI run command#1922
Add support for Claude MCP.json configuration files in CLI run command#1922Copilot wants to merge 4 commits into
Conversation
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
|
|
||
| ```json title="mcp.json" | ||
| { | ||
| "servers": { |
There was a problem hiding this comment.
Added support for mcpServers as an alternative key name to servers in the configuration interface and updated documentation to show both options. Changes in commit 064492a.
| The configuration file supports Claude environment variable interpolation syntax: | ||
|
|
||
| - `${workspaceFolder}` - Resolves to the workspace folder (or the directory containing the config file) | ||
| - `${env:VARIABLE_NAME}` - Resolves to the value of the environment variable `VARIABLE_NAME` |
There was a problem hiding this comment.
@copilot also support ${VARIABLE_NAME} to resolve a env variable (must be capitalized)
There was a problem hiding this comment.
Added support for ${VARIABLE_NAME} syntax to resolve capitalized environment variables in addition to the existing ${env:VARIABLE_NAME} format. Updated both code and documentation. Changes in commit 064492a.
| @@ -0,0 +1,113 @@ | |||
| import { readJSON } from "fs-extra" | |||
There was a problem hiding this comment.
use genaiscriptDebug and add debug statements in the file to trace the mcp server resolution
There was a problem hiding this comment.
Added genaiscriptDebug logging throughout the MCP configuration loading process to trace server resolution, including config file parsing, workspace folder detection, server processing, and final server count. Changes in commit 064492a.
…ng in MCP config Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Applied all feedback from the comments - added support for Warning Firewall rules blocked me from connecting to one or more addresses (expand for details)I tried to connect to the following addresses, but was blocked by firewall rules:
If you need me to access, download, or install something from one of these locations, you can either:
|
This PR adds support for loading MCP (Model Context Protocol) servers from Claude format configuration files using the new
--mcp-configoption in thegenaiscript runcommand.Problem
Previously, MCP servers could only be configured directly in script files using the
mcpServersproperty. Users working with Claude Desktop who already have MCP configuration files (.vscode/mcp.jsonor similar) had to duplicate their server configurations when using GenAIScript.Solution
Added a new
--mcp-config <file>CLI option that:serversandmcpServersobject structures${workspaceFolder}- resolves to workspace directory or config file directory${env:VARIABLE_NAME}- resolves to environment variable values${VARIABLE_NAME}- resolves to capitalized environment variable valuesmcpServersdefined in the scriptgenaiscriptDebugto trace MCP server resolutionUsage
# Load MCP servers from Claude configuration file genaiscript run my-script --mcp-config .vscode/mcp.jsonExample MCP configuration file:
{ "mcpServers": { "filesystem": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "${workspaceFolder}"], "env": { "DEBUG": "${env:DEBUG}", "API_KEY": "${API_KEY}" } }, "memory": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-memory"] } } }Implementation Details
packages/cli/src/mcp-config.tshandles configuration parsing and variable interpolationPromptScriptRunOptionsinterface to includemcpConfigpropertyTesting
The implementation includes comprehensive testing for:
This change is backwards compatible and doesn't affect existing functionality when the
--mcp-configoption is not used.Warning
cdn.sheetjs.comnode /usr/local/bin/yarn install(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.