Skip to content
AgentSearch

How to Add Free Web Search to Google Gemini CLI with MCP (No API Key)

Google's Gemini CLI is an open-source coding agent for the terminal. It can read your project, run commands and edit files. Like other agents, it can also use extra tools from MCP servers, and that is the easiest way to give it a search tool that returns plain search results, reads full pages, and works the same way in your other MCP clients.

This guide adds web search to Gemini CLI with one gemini mcp add command. You don't need an API key, an account, or a wallet. We use AgentSearch, which ships as the @agentsearchhq/agentsearch-mcp package on npm and also runs as a free hosted remote MCP server:

Free tier: 25 free searches per IP, then pay per call. No key needed.

What we tested: on November 22, 2026 we ran the gemini mcp add, list and remove commands below with Gemini CLI 0.70.0 (the current npm release of @google/gemini-cli) on Linux with Node.js 20+, using a fresh home folder and no Google sign-in. We checked what each command writes to settings.json, what gemini mcp list prints, and the tool list each server returns, using @agentsearchhq/agentsearch-mcp 1.8.7 (the current npm release) and the hosted server. The settings keys come from Google's Gemini CLI MCP server documentation.

Doesn't Gemini CLI already search the web?

It has a built-in google_web_search tool. According to its documentation, that tool returns a generated summary of search results with citations, processed by the Gemini API. That is fine for quick answers. An MCP search tool is useful when you want something different:

  • Raw results. AgentSearch returns ranked results (title, URL, snippet, domain) as JSON, so the agent picks what to open.
  • Full pages. agentsearch_extract turns a URL into clean markdown, and agentsearch_render loads JavaScript-heavy pages in a headless browser first.
  • News and screenshots. Dated news results and page screenshots are separate tools.
  • One setup for every client. The same server works in Claude Code, Codex CLI, Cursor and other MCP clients.

You can keep both. Gemini CLI decides which tool fits, or you name the one you want.

Prerequisites

  • Gemini CLI installed (gemini --version should print a version) and signed in the way you normally use it.
  • Node.js 20 or newer with npx on your PATH, for the local option. The hosted option needs nothing extra.

Option A: Add the local MCP server (one command)

Run:

gemini mcp add -s user agentsearch npx -y @agentsearchhq/agentsearch-mcp

Gemini CLI replies:

MCP server "agentsearch" added to user settings. (stdio)

What each part does:

  • -s user saves the server in your user settings, ~/.gemini/settings.json, so it works in every project. Without it, the default scope is project, which writes .gemini/settings.json in the current folder.
  • agentsearch is the server name. Use letters and hyphens. Google's docs warn against underscores in server names, because tool names are built as mcp_<server>_<tool>.
  • npx -y @agentsearchhq/agentsearch-mcp is the command Gemini CLI launches. -y skips npx's install prompt, which a background process can't answer. Options for gemini mcp add itself go before the server name.

The server runs as a local process over stdio. The command writes this to ~/.gemini/settings.json:

{
  "mcpServers": {
    "agentsearch": {
      "command": "npx",
      "args": ["-y", "@agentsearchhq/agentsearch-mcp"]
    }
  }
}

You can also add that block by hand. If the file already has other settings, add mcpServers next to them.

Option B: Use the hosted server (no Node.js)

Gemini CLI also connects to remote MCP servers over the Streamable HTTP transport. AgentSearch runs a free hosted remote MCP server at https://relay.agentsearchhq.com/mcp. Add it with --transport http:

gemini mcp add -s user --transport http agentsearch-hosted https://relay.agentsearchhq.com/mcp

That writes:

{
  "mcpServers": {
    "agentsearch-hosted": {
      "url": "https://relay.agentsearchhq.com/mcp",
      "type": "http"
    }
  }
}

If you write the file by hand, the documented key for Streamable HTTP is httpUrl. We tested both forms and both connected:

{
  "mcpServers": {
    "agentsearch-hosted": {
      "httpUrl": "https://relay.agentsearchhq.com/mcp"
    }
  }
}

Don't use a plain url without "type": "http": on its own, url means the older SSE transport. The hosted server needs no sign-in, so there are no headers and no OAuth step. Pick one option. If you add both, Gemini CLI sees two copies of each tool.

Step 2: Check the connection

Run this from your project folder:

gemini mcp list

You should see:

Configured MCP servers:

✓ agentsearch: npx -y @agentsearchhq/agentsearch-mcp (stdio) - Connected

Two things can get in the way:

  • "Disabled" and a folder trust warning. Gemini CLI connects MCP servers only in folders you trust, and that includes servers from your user settings. Start gemini in the folder and choose to trust it when asked, or run /permissions inside a session to change it.
  • "Disconnected" on the very first run. The first npx run downloads the package. Run npx -y @agentsearchhq/agentsearch-mcp once in a terminal (it prints a "listening on stdio" line; press Ctrl+C), then check again.

Inside a session, type /mcp to see each server, its status and its tools.

The local server (Option A) gives Gemini CLI these tools:

  • agentsearch_web_search: web search that returns up to 5 results (title, URL and a snippet). 25 free calls per IP.
  • agentsearch_news_search, agentsearch_search_and_read and agentsearch_screenshot: news with publish dates, search plus the top pages as markdown in one call, and page screenshots. 10 free calls per IP each.
  • agentsearch_extract: reads a URL and returns clean markdown or text. Free trial of 5 calls a day per IP.
  • agentsearch_render: loads a JavaScript-heavy page in a headless browser first, then returns its content. Free trial of 3 calls a day per IP.
  • agentsearch_review_lookup and agentsearch_review_submit: read and share agent-written reviews of web tools.

The hosted server (Option B) has the first six tools with the same free limits. The search, news, search + read and screenshot allowances are totals per IP and don't reset. The extract and render trials reset daily. Gemini CLI shows each MCP tool to the model with a server prefix, for example mcp_agentsearch_agentsearch_web_search.

Step 3: Try it

Start gemini in your project and ask for something that needs current information:

Search the web for the latest stable release of Vite and tell me if our package.json is behind.
Use agentsearch to find the official migration guide for Express 5, then list the breaking changes that affect src/server.ts.
Find the changelog for the newest TypeScript release and extract the section on breaking changes.

The first time a tool runs, Gemini CLI asks you to confirm the call. If it picks its built-in search instead, name the tool in the prompt ("use agentsearch to..."). Search results are snippets. When the agent needs the whole page, it can call agentsearch_extract, or agentsearch_render for pages built with JavaScript.

Useful settings.json options

Each server entry takes a few optional keys. These are the ones that matter most here:

{
  "mcpServers": {
    "agentsearch": {
      "command": "npx",
      "args": ["-y", "@agentsearchhq/agentsearch-mcp"],
      "timeout": 60000,
      "includeTools": ["agentsearch_web_search", "agentsearch_extract", "agentsearch_render"]
    }
  }
}
  • timeout is in milliseconds. Google's docs give a default of 600,000 (10 minutes) for requests, so you rarely need it. gemini mcp add --timeout 60000 sets it too.
  • includeTools is an allow list, and excludeTools is a block list that wins over it. The example keeps search plus the two page readers. In our test, --include-tools a,b on the command line saved the list as one string, so we recommend writing this key in the file.
  • trust: true skips the confirmation prompt for every tool on the server. Leave it off unless you're sure; the prompts are your check on what the agent sends out.
  • gemini mcp disable agentsearch turns a server off without deleting it, and gemini mcp enable agentsearch turns it back on.

Project scope. To share the setup with a repo, run the add command without -s user from the project root. It writes .gemini/settings.json there. Gemini CLI only changes project settings in a trusted folder.

Optional: pay per call with a wallet

When you need more than the free allowance, the local server can pay per call in USDC on Base over x402, with no account and no API key. Paid calls go to AgentSearch's direct x402 API: search and news $0.003, extract $0.002, render $0.005, search + read $0.005, screenshot $0.004. See pricing for details. Calls are settled only after a successful answer.

Use a new, dedicated wallet that holds only a small amount of USDC. The wallet setup guide walks through it. With release 1.8.7, a wallet key makes extract and render paid once their free trial is used up. Search, news, search + read and screenshots stay on the free tier unless you also set AGENTSEARCH_MODE=paid.

Gemini CLI removes variables whose names contain KEY, TOKEN, SECRET and similar words from the environment it passes to MCP servers. So the wallet key must be listed in the server's env block. Don't paste the key itself. Use $VAR expansion, which Gemini CLI fills in from your shell when it starts the server:

{
  "mcpServers": {
    "agentsearch-paid": {
      "command": "npx",
      "args": ["-y", "@agentsearchhq/agentsearch-mcp"],
      "env": {
        "AGENTSEARCH_WALLET_PRIVATE_KEY": "$AGENTSEARCH_WALLET_PRIVATE_KEY",
        "AGENTSEARCH_MAX_TOTAL_ATOMIC": "50000"
      }
    }
  }
}

Then export AGENTSEARCH_WALLET_PRIVATE_KEY=0x... in the shell where you start gemini. You can write the same entry from the command line. The single quotes keep your shell from expanding the variable, so the file stores $AGENTSEARCH_WALLET_PRIVATE_KEY and not the key:

gemini mcp add -s user -e 'AGENTSEARCH_WALLET_PRIVATE_KEY=$AGENTSEARCH_WALLET_PRIVATE_KEY' -e AGENTSEARCH_MAX_TOTAL_ATOMIC=50000 agentsearch-paid npx -y @agentsearchhq/agentsearch-mcp

Spend caps. The server checks these before it signs anything:

  • AGENTSEARCH_MAX_TOTAL_ATOMIC caps total spend per server session, in USDC atomic units (1000000 = $1.00). The default is $1.00; the example sets $0.05.
  • AGENTSEARCH_MAX_PER_CALL_ATOMIC lowers the per-call ceiling (the default ceiling is $0.020).

When a cap is reached, the tool returns a message saying nothing was signed instead of paying.

Troubleshooting

gemini mcp list says "Disabled". The current folder isn't trusted, so Gemini CLI holds back all MCP servers. Trust the folder when Gemini CLI asks, or use /permissions in a session.

"Cannot modify settings in an untrusted workspace". You ran gemini mcp add without -s user in a folder that isn't trusted. Add -s user, or trust the folder first.

The server shows "Disconnected" right after adding it. The first npx run downloads the package. Run npx -y @agentsearchhq/agentsearch-mcp once to warm the npm cache, then check again.

npx: command not found or an engine error. Gemini CLI launches the command with the PATH it sees. Install Node.js 20+ and start gemini from a shell where node -v works. With nvm or similar tools, the shell matters.

Extract or Render says a wallet is needed. The free trial for the day is used up (5 extracts, 3 renders per IP), or you set AGENTSEARCH_FREE_TRIAL=0. Nothing was charged. Add a wallet server or wait for the next day.

Search says it needs payment. The 25 free searches for your IP are used up. Add a wallet and set AGENTSEARCH_MODE=paid, or call the direct x402 API from your own code.

Remove a server. gemini mcp remove -s user agentsearch (or without -s user for a project server).

FAQ

Do I need an API key to add web search to Gemini CLI?

No. gemini mcp add -s user agentsearch npx -y @agentsearchhq/agentsearch-mcp needs no key, account or wallet. You get 25 free searches per IP, then pay per call.

Does Gemini CLI support remote MCP servers?

Yes. Gemini CLI supports Streamable HTTP servers with httpUrl in settings.json, and gemini mcp add --transport http <name> <url> adds one for you. AgentSearch's hosted server is https://relay.agentsearchhq.com/mcp and needs no authentication.

Where does Gemini CLI store MCP servers?

In the mcpServers object of ~/.gemini/settings.json for user scope, or .gemini/settings.json in a project folder for project scope. gemini mcp add uses project scope unless you pass -s user.

Why doesn't my server connect in some folders?

Gemini CLI only connects MCP servers in trusted folders, including servers from your user settings. Trust the folder when asked, or change it with /permissions.

How much do paid calls cost?

On the direct x402 API: search and news $0.003, extract $0.002, render $0.005, search + read $0.005 and screenshot $0.004 per call, in USDC on Base. You pay only after the free allowance is used up.

Is it safe to let Gemini CLI read web pages?

Treat web content as untrusted input. A page can contain text written to steer an AI. Keep Gemini CLI's confirmation prompts on (don't set trust: true without a reason) and review what it proposes after reading external pages.

Get started

Run gemini mcp add -s user agentsearch npx -y @agentsearchhq/agentsearch-mcp, check it with gemini mcp list, and ask Gemini CLI about something that changed last week. No Node.js? Use the hosted remote MCP server instead. Using Codex CLI or Claude Code too? See How to Add Free Web Search to OpenAI Codex CLI with MCP and How to Add Free Web Search to Claude Code with MCP. Setup for other clients is on the MCP page.

More from the blog

Service pages: Web Search API · Web Extract API · Web Render API