配置Wiz远程MCP服务器时OAuth2认证报404及JSON输入异常求助
问题分析与解决方案
核心问题
你的MCP配置中,OAuth2认证请求默认使用JSON格式发送请求体,但Wiz的OAuth令牌端点仅接受application/x-www-form-urlencoded编码的请求,这导致服务器返回非JSON的404响应,触发了JSON解析错误。
修正后的MCP配置
在auth节点中添加body_format: "form",强制MCP以表单编码格式发送令牌请求:
{ "mcpServers": { "wiz-remote": { "type": "remote", "url": "https://api.us63.app.wiz.io/graphql", "auth": { "type": "oauth2", "token_url": "https://auth.app.wiz.io/oauth/token", "client_id": "<client_id>", "client_secret": "<client_secret>", "grant_type": "client_credentials", "audience": "wiz-api", "body_format": "form" } } } }
原理说明
- 该配置项会让MCP将OAuth请求参数以
grant_type=client_credentials&client_id=xxx&...的表单格式发送,与你手动用Python测试的请求格式完全匹配。 - 这样Wiz的令牌端点就能正确处理请求,返回合法的JSON格式令牌响应,避免解析错误。
验证步骤
- 替换配置中的
<client_id>和<client_secret>为你的实际凭证。 - 重启MCP服务。
- 测试与Wiz远程MCP服务器的连接,此时应能成功获取访问令牌并执行GraphQL查询。
内容的提问来源于stack exchange,提问作者Adarsh Udayan
相关产品推荐
相关产品推荐

