Skip to main content
Glama

brave_local_search_code_mode

Execute custom JavaScript on Brave local search results to return only the specific fields you need, reducing context usage.

Instructions

Performs a local search using Brave APIs, and then runs a custom JavaScript code string against the RAW API RESPONSE in a secure QuickJS sandbox. This reduces context window usage by only returning the output of your script. Use this for local/business lookups when you only need specific fields from large local payloads. Your script should read the 'DATA' global variable (a JSON string payload) and use console.log() to print the desired output.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesJavaScript code to execute against the 'DATA' variable.
countNoNumber of results (1-20, default 5)
queryYesLocal search query (e.g. 'pizza near Central Park')
languageNoLanguage of the code. Only 'javascript' is supported.javascript
Behavior4/5

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

Without annotations, description fully discloses behavior: performs search, runs JS in QuickJS sandbox, returns only script output. It explains the purpose of reducing context. It does not mention rate limits or authentication, but for a search tool this is acceptable. The sandbox and script execution are clearly described.

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 4 sentences, front-loaded with the main action, followed by usage guidance and script instructions. Every sentence provides value with no redundant information. Highly efficient.

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?

The tool combines search and code execution, and the description covers the main workflow and intent. It lacks details on error handling or script failure behavior, but it mentions the sandbox and output mechanism. Given the complexity and absence of output schema, it is fairly complete.

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

Parameters3/5

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

Schema coverage is 100%, so baseline is 3. Description adds context for 'code' parameter by mentioning 'DATA' variable and console.log, and gives a query example. But overall it doesn't add significant meaning beyond the schema's own descriptions. The language parameter is explicitly noted as only supporting JavaScript.

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?

Description clearly states that the tool performs a local search via Brave APIs and runs custom JS on the raw response, reducing context window usage. It distinguishes itself from siblings like 'brave_local_search' and 'brave_web_search_code_mode' by specifying 'local search' and 'code mode'.

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: 'local/business lookups when you only need specific fields from large local payloads.' It implies not to use when full payload is needed. Provides instructions on how to write the script (read DATA global, use console.log). However, it does not explicitly mention when not to use or alternatives beyond the use case.

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