CherryHQ/cherry-studio · warning · Error
Invalid arguments for brave_web_search
Error message
Invalid arguments for brave_web_search
What it means
Thrown when isBraveWebSearchArgs(args) returns false before running brave_web_search. That type guard (braveSearch.ts:139) requires args to be a non-null object whose 'query' property is a string. Any other shape — missing query, non-string query, or non-object — fails.
Source
Thrown at src/main/ai/mcp/servers/braveSearch.ts:331
initialize() {
// Tool handlers
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
tools: [WEB_SEARCH_TOOL, LOCAL_SEARCH_TOOL]
}))
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
try {
const { name, arguments: args } = request.params
if (!args) {
throw new Error('No arguments provided')
}
switch (name) {
case 'brave_web_search': {
if (!isBraveWebSearchArgs(args)) {
throw new Error('Invalid arguments for brave_web_search')
}
const { query, count = 10 } = args
const results = await performWebSearch(this.apiKey, query, count)
return {
content: [{ type: 'text', text: results }],
isError: false
}
}
case 'brave_local_search': {
if (!isBraveLocalSearchArgs(args)) {
throw new Error('Invalid arguments for brave_local_search')
}
const { query, count = 5 } = args
const results = await performLocalSearch(this.apiKey, query, count)
return {
content: [{ type: 'text', text: results }],
isError: falseView on GitHub (pinned to 726446b54c)
Solutions
- Ensure the tool call includes a string 'query' field, e.g. {query: 'latest rust news'}.
- If integrating programmatically, validate with the same type guard before sending the request.
- Check the tool's inputSchema (required: ['query']) and align the call.
Example fix
// before — caller omits query
tool.call('brave_web_search', { count: 10 })
// after — include a string query
tool.call('brave_web_search', { query: 'latest rust news', count: 10 }) Defensive patterns
Strategy: type-guard
Validate before calling
function validateWebSearchArgs(args) {
if (typeof args.query !== 'string' || !args.query.trim()) {
throw new Error('brave_web_search requires a non-empty string "query"')
}
} Type guard
function isBraveWebSearchArgs(a): a is { query: string; count?: number } {
return typeof a === 'object' && a !== null && typeof a.query === 'string' && a.query.trim().length > 0
} Try / catch
if (!isBraveWebSearchArgs(args)) {
return { content: [{ type: 'text', text: 'Invalid args: string "query" required' }], isError: true }
} Prevention
- Always include a non-empty string query.
- Run the same type guard client-side in tests.
- Align calls with the tool inputSchema (required: ['query']).
When it happens
Trigger: CallTool for brave_web_search where args.query is missing, undefined, null, a number, or an array; or args itself is not a plain object.
Common situations: An LLM emits only {count: 10} forgetting query; passes query as a number; or sends the query under a wrong key like 'q' or 'search'.
Related errors
- Invalid arguments for brave_local_search
- No arguments provided
- Unknown chat type: ${type}
- Invalid command: command must be a non-empty string
- Invalid command: command cannot be empty
AI-assisted analysis of CherryHQ/cherry-studio@726446b54c (2026-08-12).
Data as JSON: /api/errors/dbd96785cef2a9ee.
Report an issue: GitHub.