<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: HasMCP</title>
    <description>The latest articles on DEV Community by HasMCP (@hasmcp).</description>
    <link>https://dev.to/hasmcp</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Forganization%2Fprofile_image%2F12022%2Faed63b78-e944-4d43-866e-a367fee48d80.png</url>
      <title>DEV Community: HasMCP</title>
      <link>https://dev.to/hasmcp</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hasmcp"/>
    <language>en</language>
    <item>
      <title>Brave Search MCP Server Token Optimization</title>
      <dc:creator>HasMCP</dc:creator>
      <pubDate>Thu, 29 Jan 2026 07:41:17 +0000</pubDate>
      <link>https://dev.to/hasmcp/brave-search-mcp-server-token-optimization-2mnk</link>
      <guid>https://dev.to/hasmcp/brave-search-mcp-server-token-optimization-2mnk</guid>
      <description>&lt;p&gt;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 &lt;code&gt;npx&lt;/code&gt; in your computer. &lt;/p&gt;

&lt;p&gt;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 &lt;code&gt;tiktoken&lt;/code&gt; library and payload sizes summed as bytes with and without token optimization.&lt;/p&gt;

&lt;h2&gt;
  
  
  High Level Look into Brave Web Search API
&lt;/h2&gt;

&lt;p&gt;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 &lt;a href="https://api-dashboard.search.brave.com/documentation/services/web-search" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Sample request&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl -s --compressed "https://api.search.brave.com/res/v1/web/search?q=hasmcp" \
  -H "Accept: application/json" \
  -H "X-Subscription-Token: &amp;lt;YOUR_API_KEY&amp;gt;"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Sample response&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    "type": "search",
    "web": {
        "type": "search",
        "results": [
            {
                "title": "&amp;lt;&amp;gt;",
                "url": "&amp;lt;&amp;gt;",
                "is_source_local": false,
                "is_source_both": false,
                "description": "&amp;lt;&amp;gt;",
                "profile": {
                    ...
                }…
            },
            ...
       ]
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;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.&lt;/p&gt;

&lt;h2&gt;
  
  
  Creating MCP Server from Scratch
&lt;/h2&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Provider details&lt;/strong&gt;&lt;br&gt;
First, we need to define the "Provider." In HasMCP, a provider represents the external service you are connecting to.&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Name: Enter a distinct name for the provider (e.g., brave-search).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Base URL: Enter the root URL for the API. For Brave Search, this is &lt;a href="https://api.search.brave.com/res/v1" rel="noopener noreferrer"&gt;https://api.search.brave.com/res/v1&lt;/a&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Description: (Optional) Add a note for yourself about what this API does.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h1xhrsj3x2pn5a9pt02.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7h1xhrsj3x2pn5a9pt02.png" alt="HasMCP - API Provider Details" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Tool details&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Method: GET.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Endpoint Path: /web/search.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tool name: webSearch (use camelCase to help LLMs to parse)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Parameters: Define the inputs the LLM must provide.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Key: q&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Type: string&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Description: The search query to find information about.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfb412tt2lv220hrshp0.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvfb412tt2lv220hrshp0.png" alt="HasMCP - Tool Details" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Token optimization&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Select Tool: Choose webSearch.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interceptor Expression: specific JMESPath query to extract only the essentials.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expression:&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;web.results[].{title: title, url: url, description: description}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Raw API Response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "web": {
    "results": [
      { "title": "Example", "url": "...", "meta_url": "...", "thumbnail": "...", "age": "..." }
    ]
  },
  "query": { ... },
  "mixed": { ... }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Optimized response&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "title": "Example",
    "url": "[https://example.com](https://example.com)",
    "description": "This is the description."
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjoctl7vtk1507l05nj9l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fjoctl7vtk1507l05nj9l.png" alt="HasMCP - Response Interceptor Window" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;API Key&lt;/strong&gt;&lt;br&gt;
We must securely store the credentials required by the 3rd party API. HasMCP injects these into the request headers automatically.&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Header Name: Look up the API docs. Brave requires X-Subscription-Token.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Value: Paste your actual API Key from the Brave Developer Portal.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn3o5168how4bbb23skm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkn3o5168how4bbb23skm.png" alt="Brave Search API Key for MCP Server" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Generate MCP Server Token&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To expose your new server to an LLM client, you need a secure entry point. HasMCP generates a unique URL protected by a token.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F90x9dteabco79s5spfae.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F90x9dteabco79s5spfae.png" alt="HasMCP - Generate Auth Token for MCP Server" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Expiry: Set the token duration (e.g., "Never" or "30 days").&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Generate: Click Generate Token.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Copy Connection URL for your favorite LLM: This URL is what you will paste into your Claude Desktop config or Cursor settings.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;MCP Telemetry/Analytics&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;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.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F890qdrilo3o7hzun34cn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F890qdrilo3o7hzun34cn.png" alt="HasMCP - MCP telemetry, token optimization stats" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Debug&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If the LLM says "I encountered an error," you use the Debug logs to see exactly what happened between HasMCP and the Brave API.&lt;/p&gt;

&lt;p&gt;Action:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Open the Debug (Realtime Logs/Telemetry) tab.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Trigger a request from your LLM.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Inspect the Request (did the LLM send the right query?) and the Response (did the API key fail?).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxufhekcje7z5ix3wi4a8.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxufhekcje7z5ix3wi4a8.png" alt="HasMCP - Realtime MCP server debug logs" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>bravesearch</category>
      <category>mcp</category>
      <category>mcpserver</category>
      <category>rag</category>
    </item>
  </channel>
</rss>
