← Back to PRs

#9337: fix: correct GLM MCP web-search-prime API parameter name and response parsing [AI-assisted]

by shoa-lin open 2026-02-05 04:06 View on GitHub →
agents stale
## AI-Assisted PR - [x] Marked as AI-assisted - [x] Testing level: Lightly tested (manual API testing with real key) - [x] Context: Developed with Claude Code assistance ## Summary Fix GLM MCP web-search-prime integration to enable proper web search functionality. ## Problem The original `web_search_prime` tool had two issues: 1. **Incorrect parameter name**: Used `query` instead of GLM API's expected `search_query` 2. **Response parsing failure**: GLM API returns JSON wrapped in extra quotes (`"[{...}]"`) ## Changes - **Fix parameter name**: Changed from `query` to `search_query` in MCP tool calls - **Fix response parsing**: Added logic to strip outer quotes and unescape JSON - **Add testing exports**: Export internal functions via `__testing` for unit testing - **Add CHANGELOG entry**: Document the fix in the changelog ## Testing Tested with real GLM API key against https://open.bigmodel.cn/api/mcp/web_search_prime/mcp: - ✅ Basic search queries (English: "TypeScript programming") - ✅ Chinese search queries ("人工智能 大模型") - ✅ Special characters handling (C++, "quoted text") - ✅ Session caching - ✅ Error handling and retry logic ## Configuration Users can enable this feature by setting: ```bash export GLM_API_KEY="your-glm-api-key" # or export ZHIPU_API_KEY="your-zhipu-api-key" ``` Or in config: ```json5 { tools: { web: { searchPrime: { enabled: true, apiKey: "your-api-key" } } } } ``` ## Context The GLM web-search-prime API documentation: https://docs.bigmodel.cn/cn/coding-plan/mcp/search-mcp-server This fix enables OpenClaw users in China to use GLM's web search service as an alternative to other search providers. <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> This PR wires up a new `web_search_prime` tool that calls GLM’s MCP-based `webSearchPrime` endpoint, adds config types for `tools.web.searchPrime`, and updates tool policy groups so `web_search_prime` is included in the `group:web` allowlist. It also updates the changelog to note the GLM MCP integration fix, and introduces a new `PR_GUIDE.md` document. <h3>Confidence Score: 3/5</h3> - This PR is close, but has a couple functional mismatches and an extra file that should be removed before merging. - Core integration changes are straightforward, but `web_search_prime` currently ignores its `count` argument and the MCP notification request path relies on swallowed JSON parse failures for empty responses; additionally `PR_GUIDE.md` appears to be an accidental personal doc that should not ship. - src/agents/tools/web-search-prime.ts, PR_GUIDE.md <!-- greptile_other_comments_section --> <sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub> <!-- /greptile_comment -->

Most Similar PRs