VS Code配置多MCP服务器遇输入定义错误求助
VS Code多MCP服务器配置问题排查
尝试为VS Code配置多个需令牌/密钥的MCP服务器,按官方文档配置后仅显示单个输入框,配置多个promptString类型输入时,所有输入定义均触发如下错误:
Error starting github: CodeExpectedError: Variable 'github_token' must be defined in an 'inputs' section of the debug or task configuration.
单个输入时可正常运行,配置代码如下:
"mcp": { "inputs": [ { "type": "promptString", "id": "github_token", "description": "GitHub Personal Access Token", "password": true }, { "type": "promptString", "id": "perplexity_api_key", "description": "Perplexity API Key", "password": true }, { "type": "promptString", "id": "trello_api_key", "description": "Trello API Key", "password": true }, { "type": "promptString", "id": "trello_api_token", "description": "Trello API Token", "password": true } ], "servers": { "Perplexity-ask": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-perplexity-ask"], "env": { "PERPLEXITY_API_KEY": "${input:perplexity_api_key}" } }, "Playwright": { "command": "npx", "args": ["@playwright/mcp@latest"] }, "github": { "command": "docker", "args": [ "run", "-i", "--rm", "-e", "GITHUB_PERSONAL_ACCESS_TOKEN", "ghcr.io/github/github-mcp-server" ], "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" } }, "trello": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-trello"], "env": { "TRELLO_API_KEY": "${input:trello_api_key}", "TRELLO_TOKEN": "${input:trello_api_token}", "TRELLO_BOARD_ID": "xyz" } } } }
排查方向
- 校验JSON语法合法性:用JSON校验工具检查配置是否存在隐性语法错误,比如末尾多余逗号、引号不闭合,这类错误会导致VS Code无法正确解析
inputs节点 - 核对输入ID引用一致性:确保服务器
env中${input:xxx}的ID和inputs数组中定义的id完全匹配,包括大小写、拼写 - 确认配置层级正确性:验证
inputs数组是否直接属于mcp对象的顶级属性(与servers同级),层级错误会导致输入定义不被识别 - 清除VS Code缓存:通过命令面板执行
Developer: Reload Window重启窗口,排除旧缓存导致的配置解析异常 - 单独测试服务器配置:逐个启动MCP服务器,排查是否是某个特定服务器的配置干扰了全局输入提示逻辑
- 检查VS Code版本兼容性:确保使用的VS Code版本支持多MCP输入提示,较旧版本可能存在功能兼容问题
内容的提问来源于stack exchange,提问作者Sayan Ghosh
相关产品推荐
相关产品推荐

