Skip to main content
Claude Code includes two web tools: WebFetch for fetching a specific URL and WebSearch for discovering information across the web.

WebFetch

Fetches content from a URL and processes it with an AI model to extract the information you need. HTML is converted to Markdown before processing.

Parameters

url
string
required
The fully-formed URL to fetch. HTTP URLs are automatically upgraded to HTTPS. Must be a valid URL — an invalid URL will produce an error without making a network request.
prompt
string
required
Instructions describing what information to extract from the fetched page. The content is processed by a small, fast model using this prompt, and the model’s response is returned.Example: "What are the required parameters for the createUser endpoint?"

Output

result
string
The processed response from the model, based on the fetched content and the prompt.
url
string
The URL that was fetched.
code
number
HTTP response status code.
codeText
string
HTTP response status text (e.g., "OK", "Not Found").
bytes
number
Size of the fetched content in bytes.
durationMs
number
Time taken to fetch and process the content in milliseconds.

Usage notes

  • Authenticated URLs will fail. WebFetch cannot access Google Docs, Confluence, Jira, GitHub private repos, or any URL requiring a login. Use a specialized MCP tool if you need authenticated access.
  • If an MCP server provides a web fetch tool, prefer it — it may have fewer restrictions.
  • For GitHub URLs, prefer using the gh CLI via the Bash tool (e.g., gh pr view, gh issue view).
  • HTTP redirects to the same host are followed automatically. Redirects to a different host are surfaced in the result field with the redirect URL. Make a new WebFetch call with the redirect URL to continue.
  • Results may be summarized when content is very large.
  • A 15-minute cache is maintained for repeated fetches of the same URL.
  • Binary content (PDFs, etc.) is saved to a temporary file and the path is noted in result.

Permissions

WebFetch requires permission before fetching from a domain. Claude Code will prompt you on the first request to a new domain. You can permanently allow a domain in your settings.

Examples

Fetch API documentation
url: "https://docs.example.com/api/reference"
prompt: "List all available endpoints and their HTTP methods"
Extract a code example
url: "https://docs.example.com/quickstart"
prompt: "Show me the minimal code example for getting started"
Check library version requirements
url: "https://github.com/example/library/blob/main/package.json"
prompt: "What are the peer dependencies and their version constraints?"

WebSearch

Searches the web and returns results with summaries and source links. Uses Anthropic’s web search capability, which performs searches automatically within a single API call.
WebSearch is only available when using Anthropic’s API directly (first-party), Vertex AI with Claude 4.0+ models, or Foundry. It is not available with all API configurations.

Parameters

query
string
required
The search query. Minimum 2 characters. Be specific — include the current year when searching for recent information, documentation, or news.
allowed_domains
string[]
When provided, only include search results from these domains. Cannot be used together with blocked_domains.Example: ["docs.python.org", "pypi.org"]
blocked_domains
string[]
When provided, exclude search results from these domains. Cannot be used together with allowed_domains.Example: ["stackoverflow.com"]

Output

query
string
The search query that was executed.
results
array
An array of search result objects and text commentary from the model. Each element is either:Or a plain string containing the model’s commentary or summary.
durationSeconds
number
Time taken to complete the search operation.

Response format

Claude Code’s response to a WebSearch call includes both the search results and a synthesized answer. Sources must be cited at the end of the response as markdown hyperlinks.
Example response format
[Answer based on search results]

Sources:
- [Source Title 1](https://example.com/1)
- [Source Title 2](https://example.com/2)

Usage notes

  • WebSearch is only available in the US.
  • A single WebSearch call may internally perform up to 8 sub-searches.
  • Domain filtering (allowed_domains and blocked_domains) is mutually exclusive — only provide one or the other.
  • Always include the current year in queries about recent releases, documentation versions, or current events.

Examples

Search for library documentation
query: "React 19 new features 2025"
Search within specific domains
query: "Python asyncio tutorial"
allowed_domains: ["docs.python.org", "realpython.com"]
Search excluding specific domains
query: "best practices for JWT authentication"
blocked_domains: ["medium.com"]