Skip to main content
Glama

brave_web_search_code_mode

Search the web with Brave and extract specific data by running custom JavaScript code on the raw API response in a secure sandbox, minimizing context usage.

Instructions

Performs a web search using the Brave Search API, and then runs a custom JavaScript code string against the RAW API RESPONSE in a secure QuickJS sandbox. This drastically reduces context window usage by only returning the output of your script. Use this for broad information gathering, recent events, or when you need diverse web sources and only need specific parts of the result. Your script should read the 'DATA' global variable (a JSON string of the API response), process it, and use console.log() to print the desired output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code to execute against the 'DATA' variable. E.g. `const r = JSON.parse(DATA); console.log(r.web.results.map(x => x.title).join(', '));`
countNoNumber of results (1-20, default 10)
queryYesSearch query (max 400 chars, 50 words)
offsetNoPagination offset (max 9, default 0)
languageNoLanguage of the code. Only 'javascript' is supported.javascript
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description adequately explains the sandbox execution, the DATA variable, and console.log output. It mentions 'secure QuickJS sandbox' but does not detail error behavior, rate limits, or authentication requirements.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is very concise with two paragraphs: first explains functionality, second gives usage guidance and a code example. No superfluous content; every sentence adds value.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the complexity of executing custom code, the description covers the core workflow and distinguishes from plain search. It lacks details on output format and error handling, but provides enough context for basic use.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3. The description adds value by providing a concrete JavaScript example for the 'code' parameter and explaining the 'DATA' variable, which goes beyond the schema's basic description.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it performs a web search and then executes custom JavaScript on the raw response, distinguishing it from plain search tools. It gives a specific use case ('broad information gathering... needing specific parts of the result') which differentiates it from siblings like brave_web_search.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description explicitly states when to use (broad information gathering, recent events, needing specific parts) and implies when not to (for full results, use non-code version). However, it does not explicitly mention sibling names or provide contraindications.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/dcostenco/prism-coder'

If you have feedback or need assistance with the MCP directory API, please join our Discord server