Guide

How to add web search to Claude Code with an MCP server

Give Claude Code web search, page reading, pay-per-result data tools and a browser agent with one claude mcp add command and a spend-limited API key.

Prepaid, no subscriptionREST or MCPOne key for models, data and agents
claude — mcp$ claude mcp add --transport http lovely-tools https://lovelyrouter… ✓ connected · web_search · run_tool · browser_run> Find 20 dentists in Austin with emails, save as CSV ⏺ suggest_tools → google-maps-leads ⏺ run_tool google-maps-leads {"location": "Austin, TX"} 20 results · 17 with emails ⏺ run_tool email-verify (17 addresses) ✓ wrote dentists-austin.csv

Claude Code reads and writes your code, but to check a library's latest release notes or read an API reference, it needs tools that reach the web. An MCP server gives it those tools. This guide shows how to add web search to Claude Code with a single claude mcp add command, what Claude Code can do with it, and keeps its spending under a limit you set.

01

What an MCP server adds to Claude Code

search_toolsrun_toolget_run

MCP, the Model Context Protocol, is a standard way for an agent to call tools that live on a server. Claude Code connects to the server, reads the list of tools it offers, and decides when to call them while it works on your request.

The server at https://lovelyrouter.com/mcp speaks Streamable HTTP and authenticates with Authorization: Bearer lr-..., the same key as the REST API. Each call is billed from your prepaid balance like the same call over REST:

Web search and page reading

cost $0.0009 per search or page. A search with no results, or a page that can't be read, costs nothing.

Data tools

charge a per-call fee, a per-result fee or both, capped by max_results.

The browser agent

charges per step: $0.006 in fast mode, $0.012 in accurate mode.

Planning and catalog lookups

are free.

There's no subscription, and the server works whichever model endpoint Claude Code itself uses.

02

Connect it

search_toolsrun_toolget_run
  1. Create a key with a spend limit

    Create a key in API keys, give it a spend limit, and export it in your shell as LOVELY_API_KEY.

  2. Add the server

    Shell
    claude mcp add --transport http lovely-tools https://lovelyrouter.com/mcp \
      --header "Authorization: Bearer $LOVELY_API_KEY"

    This adds it to the current project only. Add --scope user to use it in every project.

  3. Check that it connects

    Run claude mcp list. Inside a session, /mcp shows the server's status and its tools.

To share the server with your team, commit a .mcp.json at the project root instead. Claude Code expands ${LOVELY_API_KEY} from each person's environment, so the key stays out of the file:

.mcp.json
{
  "mcpServers": {
    "lovely-tools": {
      "type": "http",
      "url": "https://lovelyrouter.com/mcp",
      "headers": { "Authorization": "Bearer ${LOVELY_API_KEY}" }
    }
  }
}

You can also test the server without Claude Code. This lists its tools:

cURL
curl https://lovelyrouter.com/mcp \
  -H "Authorization: Bearer $LOVELY_API_KEY" \
  -H "content-type: application/json" \
  -d '{"jsonrpc": "2.0", "id": 1, "method": "tools/list"}'
03

The tools Claude Code gets

search_toolsrun_toolget_run
GroupToolsWhat Claude Code uses them for
Search and readweb_search, web_fetchSearch the web for up to 50 results, each with a summary written for a model, or read one page as clean Markdown.
Data catalogsuggest_tools, search_tools, get_tool, run_tool, get_runPlan a task with costs, find a tool, read its input schema and price (all free), then run it and read the results.
Browser agentbrowser_run, browser_status, browser_reply, browser_takeoverWork through pages it has to click, type or log in to.
Imagesgenerate_image, get_imageMake an image from a description.

The server tells Claude Code to use web_search and web_fetch for anything it only needs to read, and to keep the browser agent for pages it has to interact with. web_search accepts operators in the query: site:, -site:, "exact phrase", -word, lang:, after: and before:. web_fetch returns long pages in parts of about 12,000 characters, and reading on is free. Every argument and return format is in the MCP server docs.

04

Prompts to try

{}
  • "Find the release notes for the latest FastAPI version, read them, and list the changes that affect our routes." Claude Code searches with web_search, then reads the notes with web_fetch.
  • "Search site:github.com for open issues about this error message, after:2026-06-01, and tell me if there's a known fix." Operators narrow the search to recent issues.
  • "Read https://docs.example.com/api/authentication and write a client for it in src/client.py." web_fetch turns the page into Markdown Claude Code can work from.
  • "Get the transcript of this YouTube talk and add a summary with timestamps to NOTES.md." Claude Code plans with suggest_tools and runs the YouTube transcript tool with run_tool.
  • "Sign up on our public staging site with a test address and tell me what the confirmation page says." browser_run does it in a cloud browser.
05

Keep the cost under control

A key per agent, with a spend limit

The limit covers model requests, data tools and browser runs. See API keys.

Rules in your project instructions

Add a line to CLAUDE.md such as: "Use web_search and web_fetch to look things up. Always set max_results on run_tool, check the price with get_tool first, and ask me before any run with more than 50 results or any browser run."

Keep paid runs behind a prompt

Claude Code asks before it calls an MCP tool. Allow the cheap reads with rules such as mcp__lovely-tools__web_search and mcp__lovely-tools__web_fetch, and keep approving run_tool and browser_run by hand, so you see each run before it starts.

Cap browser runs

A browser run's hold is based on max_steps times the step price, and max_steps defaults to 50. Ask for a lower max_steps for short tasks.

Today's prices for the tools Claude Code calls most:

Every run and its charge is listed under Tools in your dashboard. See pricing for the rest.

06

Troubleshooting the connection

search_toolsrun_toolget_run
SymptomFix
claude mcp list says the server failed to connectCheck the URL is https://lovelyrouter.com/mcp and that you passed --transport http. The cURL test above shows whether the server answers.
suggest_tools works, but run_tool returns an authentication errorThe key didn't reach the server. Your shell filled in $LOVELY_API_KEY when you ran claude mcp add, so if it was empty the header holds no key. Run claude mcp remove lovely-tools, export the key, and add the server again. With .mcp.json, export the variable in the shell that starts claude.
The server is missing in another projectIt was added to one project only. Add it again with --scope user.
A .mcp.json server doesn't appearClaude Code asks before it uses servers from a project's .mcp.json. Approve it when asked, or check /mcp.
402 from a toolYour balance or the key's spend limit can't cover the run's maximum cost. Lower max_results, top up, or raise the limit.
429 from a toolTen runs are already in progress on your account. Wait for one to finish.
Still running. Call get_run with this run idNormal for runs over 50 seconds: Claude Code calls get_run to wait for the results.
The browser agent can't open your local appIt runs in the cloud and can't reach localhost or private addresses. Use a public URL.
07

Frequently asked questions

?
Do I have to run Claude Code on this API to use the MCP server?+

No. The MCP server is separate from the model endpoint, so it works with any Claude Code setup. To run Claude Code's models on the same key and balance as well, set the base URL and key as described in the Claude Code integration docs.

How much does a web search from Claude Code cost?+

Each web_search call costs $0.0009, whether it returns 10 or 50 results, and a search with no results costs nothing. Reading a page with web_fetch costs the same per page.

When does Claude Code use the browser agent instead of web_fetch?+

The server tells Claude Code to use web_fetch for pages it only needs to read, and the browser agent for pages it has to click, type or log in to. web_fetch is faster and cheaper.

Can I use the same server in Cursor or Claude Desktop?+

Yes. Cursor takes the URL and header in its mcp.json, and Claude Desktop connects through the mcp-remote bridge. Any client that supports remote MCP servers over Streamable HTTP works with the same key.

How do I stop Claude Code from overspending?+

Give it its own API key with a spend limit, tell it in CLAUDE.md to set max_results and ask before large runs, and keep paid tools behind Claude Code's permission prompt. A run that could take the key past its limit is refused before anything is charged.

Next, see the web search API to call search from your own code, AI coding agents to run Claude Code itself on a pay-as-you-go key, and Claude Code setup for base URL, models and caching. The MCP server page covers the other clients.

One prepaid key for models, data and agents

No subscription. Top up, use what you need, see every charge in your logs.