#9337: fix: correct GLM MCP web-search-prime API parameter name and response parsing [AI-assisted]
agents
stale
Cluster:
Web Search Provider Enhancements
## 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
#13370: Tools: rewrite Grok parser, add Tavily provider, multi-provider con...
by a-anand-91119 · 2026-02-10
77.7%
#13814: feat(web-search): add ZAI Search (zsearch) provider
by strelov1 · 2026-02-11
77.7%
#4445: fix: resolve Antigravity "unsupported version" and tool_use schema ...
by harry2690 · 2026-01-30
76.1%
#11048: fix: address repository issues (env, author, CI comments, security ...
by cavula · 2026-02-07
75.3%
#13386: feat(web-search): add Nimble Web Search API provider
by ilchemla · 2026-02-10
75.3%
#19326: Agents: improve z.ai GLM-5 integration and failover
by gabrielespinheira · 2026-02-17
75.2%
#22505: Feature/clean grok search base url
by vacuityv · 2026-02-21
75.1%
#8715: fix(web-search): safer provider resolution & Perplexity auto-detection
by abhijeet117 · 2026-02-04
75.0%
#7741: fix: gracefully handle missing OpenRouter API key in models scan
by rohanjangala · 2026-02-03
74.7%
#19094: Fix empty tool_call_id and function names in provider transcript pa...
by yxshee · 2026-02-17
74.6%