Brave Search API allows searching web, videos, news and several other things. Brave also has official MCP Server that you can wraps its API so you can plug into your favorite LLM if you have access to npx in your computer.
Brave Search is one of the most popular MCP Servers in HasMCP. The video demonstrates a genuine way of creating MCP Server from scratch using HasMCP without installing a npx/python to your computer by mapping the Brave API into 7/24 token optimized MCP Server using UI. You will explore how to debug when things go wrong, how to fix them in realtime and see the changes immediately taking place in the MCP Server without any restarts. You can see the details of how to optimize token usage of an API response up to 95% per call. All token estimated usages were measured using tiktoken library and payload sizes summed as bytes with and without token optimization.
High Level Look into Brave Web Search API
Brave Web Search API is a GET request to with 2 headers Accept with application/json and X-Subscription-Token basically it is your API Token. It accepts several query string params, you can access the full list from its documentation.
Sample request
curl -s --compressed "https://api.search.brave.com/res/v1/web/search?q=hasmcp" \
-H "Accept: application/json" \
-H "X-Subscription-Token: <YOUR_API_KEY>"
Sample response
{
"type": "search",
"web": {
"type": "search",
"results": [
{
"title": "<>",
"url": "<>",
"is_source_local": false,
"is_source_both": false,
"description": "<>",
"profile": {
...
}…
},
...
]
}
}
The API response includes a lot of details and if not filtered it returns multiple types of responses including web, videos, etc.. LLMs regardless will try to display only necessary information to do that it will spend a lot of tokens and it might even cause issues like context bloating eventually.
Creating MCP Server from Scratch
HasMCP is a GUI-based MCP (Model Context Protocol) Server Framework. It acts as a bridge, converting standard REST API definitions into a 24/7 online MCP Server with Streamable HTTP (SSE). This eliminates the need for local npx or Python installations, allowing you to deploy MCP servers that interface purely with external APIs.
Provider details
First, we need to define the "Provider." In HasMCP, a provider represents the external service you are connecting to.
Action:
Name: Enter a distinct name for the provider (e.g., brave-search).
Base URL: Enter the root URL for the API. For Brave Search, this is https://api.search.brave.com/res/v1.
Description: (Optional) Add a note for yourself about what this API does.
Tool details
Now we define the "Tool." This is the specific function the LLM (like Claude or Cursor) will see and call. We need to map a specific API endpoint to a tool definition.
Action:
Method: GET.
Endpoint Path: /web/search.
Tool name: webSearch (use camelCase to help LLMs to parse)
Parameters: Define the inputs the LLM must provide.
Key: q
Type: string
Description: The search query to find information about.
Token optimization
APIs often return massive JSON objects with meta-data that LLMs don't need. This wastes token limits and slows down context. We use a Response Interceptor (using JMESPath) to filter the output.
Action:
Select Tool: Choose webSearch.
Interceptor Expression: specific JMESPath query to extract only the essentials.
Expression:
web.results[].{title: title, url: url, description: description}
Raw API Response
{
"web": {
"results": [
{ "title": "Example", "url": "...", "meta_url": "...", "thumbnail": "...", "age": "..." }
]
},
"query": { ... },
"mixed": { ... }
}
Optimized response
[
{
"title": "Example",
"url": "[https://example.com](https://example.com)",
"description": "This is the description."
}
]
API Key
We must securely store the credentials required by the 3rd party API. HasMCP injects these into the request headers automatically.
Action:
Header Name: Look up the API docs. Brave requires X-Subscription-Token.
Value: Paste your actual API Key from the Brave Developer Portal.
Generate MCP Server Token
To expose your new server to an LLM client, you need a secure entry point. HasMCP generates a unique URL protected by a token.
Action:
Expiry: Set the token duration (e.g., "Never" or "30 days").
Generate: Click Generate Token.
Copy Connection URL for your favorite LLM: This URL is what you will paste into your Claude Desktop config or Cursor settings.
MCP Telemetry/Analytics
Once connected, you can monitor the health and efficiency of your server. This is crucial for verifying that your Token Optimization (Step 3) is actually working.
Debug
If the LLM says "I encountered an error," you use the Debug logs to see exactly what happened between HasMCP and the Brave API.
Action:
Open the Debug (Realtime Logs/Telemetry) tab.
Trigger a request from your LLM.
Inspect the Request (did the LLM send the right query?) and the Response (did the API key fail?).







Top comments (0)