---
title: "AI Agent Tools: What an Agent Needs for Web Data"
description: "An agent tool is a name, a description, an input schema and a result. How search, lookup and fetch tools map to three MCP tools, two of them free."
url: https://perceptlayer.com/blog/ai-agent-tools-web-data
---

[Blog](https://perceptlayer.com/blog) / [AI agents](https://perceptlayer.com/blog/category/ai-agents)

# AI Agent Tools: What an Agent Needs for Web Data

26 Oct 2026 Updated 10 Nov 2026 Perceptlayer 7 min read

AI agent tools are functions a model can ask to run: each has a name, a description, an input schema and a result the model reads back. For web data, an agent needs three kinds: search to find candidates, lookup to get details on one known item, and fetch to retrieve data for exact inputs. Perceptlayer's MCP server covers all three with `search_endpoints`, `get_endpoint` and `call_endpoint`; the first two are free and the third costs the endpoint's credits on success.

## Key takeaways

-   A tool has four parts: a name the model calls, a description that tells it when to call, an input schema for the arguments, and a result it reads.
-   Web data work splits into search (query in, candidates out), lookup (an ID in, one record out) and fetch (exact inputs in, a dataset out).
-   `search_endpoints` and `get_endpoint` only look up the catalogue of 3,834 endpoints and cost nothing; `call_endpoint` runs one and spends its credits, 1 for nearly all, on success only.
-   The worked example below answers a two-part question with two data calls: Google Maps `simple-search` and `directions`, 2 credits in total.
-   What a tool returns matters as much as what it calls: pass the model `name`, `rating` and `full_address`, not all 28 fields a recorded place carries.

## What is a tool for an AI agent?

A tool is a contract between your code and the model. The model never runs anything itself: it reads the tool's name and description, decides a call would help, writes arguments that match the input schema, and your code (or an MCP server) runs the call and hands back the result. The model then reads that result as text and carries on.

Each of the four parts does a different job:

| Part | What it does | What goes wrong when it's weak |
| --- | --- | --- |
| Name | The identifier the model emits to call the tool | Similar names lead to the wrong tool being picked |
| Description | Tells the model when the tool helps and what it returns | The model calls it for the wrong questions, or never |
| Input schema | Typed arguments, which are required, allowed values | Invalid arguments and wasted round trips |
| Result | The data the model reads after the call | Bloated results fill the context window |

Here is a tool for one web data endpoint, written as a plain Python dict. The parameter names, types and allowed values come from the Google Maps directions endpoint in the catalogue:

```python
directions_tool = {
    "name": "driving_directions",
    "description": "Routes between two places from Google Maps, with distance and duration. "
                   "Use when the user asks how far or how long a trip is.",
    "input_schema": {
        "type": "object",
        "properties": {
            "origin": {"type": "string", "maxLength": 500},
            "destination": {"type": "string", "maxLength": 500},
            "mode": {"type": "string", "enum": ["driving", "walking", "bicycling", "transit"]},
        },
        "required": ["origin", "destination"],
    },
}
```

Agent frameworks each take this in their own format, but the four parts are the same.

## Which kinds of tools does an agent need for web data?

Most web data questions break into three moves, and each move is a different kind of tool. Search turns an open question into candidates. Lookup takes one candidate's ID and returns its details. Fetch takes exact inputs and returns a dataset for them. An agent that has one tool of each kind can answer most "find, then check" questions.

| Kind | Input | Output | Example endpoint |
| --- | --- | --- | --- |
| Search | A query | A ranked list of candidates | `GET /v1/google-search/search` ( `query`), `GET /v1/google-maps/simple-search` ( `query`) |
| Lookup | An ID from a previous result | One record in detail | `GET /v1/google-maps/business-details` ( `business_id`) |
| Fetch | Exact inputs | Data computed or collected for them | `GET /v1/google-maps/directions` ( `origin`, `destination`) |

Search covers the open web too: the [Google Search API](https://perceptlayer.com/apis/google-search) returns ranked results for a `query` at 1 credit, the same as a place search. The link between search and lookup is the ID. In the recorded `simple-search` response each place has a `business_id`, and `business-details`, `reviews` and `photos` all take a parameter of the same name. That shared name is what lets an agent chain the calls without a human copying values between them.

You could write one tool per endpoint, but the catalogue has 3,834 endpoints across 707 websites. Describing them all would fill the model's context before it read the question. [MCP Server Too Many Tools](https://perceptlayer.com/blog/mcp-too-many-tools-context) works through that problem in numbers.

## How do the MCP server's three tools map onto search, lookup and fetch?

The MCP server at `https://perceptlayer.com/mcp` applies the same three kinds one level up, to the catalogue itself. `search_endpoints` is a search tool over endpoints, `get_endpoint` is a lookup of one endpoint's catalogue entry, and `call_endpoint` is the fetch: it takes an endpoint ID and that endpoint's parameters and returns the endpoint's JSON response.

| MCP tool | Kind | What it does | Cost |
| --- | --- | --- | --- |
| `search_endpoints` | Search | Finds endpoints in the catalogue that match what the agent needs | 0 credits |
| `get_endpoint` | Lookup | Looks up one endpoint in the catalogue, by ID | 0 credits |
| `call_endpoint` | Fetch | Runs the endpoint with the given parameters and returns its JSON | The endpoint's credits (1 for nearly all), on success only |

So the model's context holds three tool definitions instead of 1,642, and it pays only when it actually fetches data. `call_endpoint` also reports the credits used and remaining, so the agent can see its spend after every call. To add the server to Claude Code:

```bash
claude mcp add --transport http perceptlayer https://perceptlayer.com/mcp --header "Authorization: Bearer $API_KEY"
```

[What Is an MCP Server?](https://perceptlayer.com/blog/what-is-an-mcp-server) shows the protocol messages, and the [AI agents docs](https://docs.perceptlayer.com/ai-agents) cover other clients.

## What does a worked example look like?

Take the question "Where's a well-rated restaurant in New York, and how long is the drive to Boston from there?". It needs one search and one fetch. The agent first uses the two free tools to find and read the Google Maps endpoints, then makes two paid calls: `simple-search`, then `directions`. Total: 2 credits.

### Step 1: find the endpoints (0 credits)

The agent calls `search_endpoints` to find a place search and a directions endpoint, then `get_endpoint` on each to read its catalogue entry. That's where it sees that `simple-search` requires `query` and `directions` requires `origin` and `destination`. Neither call spends credits.

### Step 2: search for places (1 credit)

The agent runs `call_endpoint` with the `simple-search` endpoint. The same request over HTTP:

```bash
curl "https://api.perceptlayer.com/v1/google-maps/simple-search?query=restaurants+in+new+york" \
  -H "X-API-Key: $API_KEY"
```

The recorded response, trimmed:

```json
{
  "items": [
    {
      "name": "Altair Restaurant NYC",
      "review_count": 1225,
      "rating": 4.8,
      "business_id": "0x89c2591598891521:0x4ebcde18610e64",
      "subtypes": [
        "New American restaurant",
        "Restaurant"
      ],
      "full_address": "351 W 38th St, New York, NY 10018, United States",
      …
    },
    {
      "name": "Lulla NYC",
      "review_count": 1571,
      "rating": 4.8,
      …
    }
  ],
  "pagination": {
    "current_page": 0,
    "total_results": 173,
    "has_more": false
  }
}
```

### Step 3: fetch the route (1 credit)

Next the agent calls [directions](https://perceptlayer.com/apis/google-maps/directions). The recorded call used city names for both ends:

```bash
curl "https://api.perceptlayer.com/v1/google-maps/directions?origin=New+York%2C+NY&destination=Boston%2C+MA" \
  -H "X-API-Key: $API_KEY"
```

```json
{
  "search_parameters": {
    "start_addr": "New York, NY",
    "end_addr": "Boston, MA",
    "travel_mode": "driving"
  },
  "directions": [
    {
      "travel_mode": "Driving",
      "via": "I-90 E",
      "formatted_distance": "216 miles",
      "formatted_duration": "3 hr 46 min",
      "extensions": [
        "This route has tolls."
      ],
      "formatted_duration_in_traffic": "3 hr 36 min",
      "typical_duration_range": "3 hr 24 min to 4 hr 13 min",
      …
    },
    {
      "travel_mode": "Driving",
      "via": "I-95 N",
      "formatted_distance": "234 miles",
      "formatted_duration": "4 hr 11 min",
      …
    }
  ],
  "status": "OK",
  "routes_count": 3
}
```

The model now has enough to answer: two restaurants rated 4.8, and a drive of about 3 hr 46 min via I-90 E, with tolls. In the same recording, `places_info` came back with coordinates of 0 and an empty `data_id`, so the agent should read the `directions` entries and not rely on `places_info`. Passing the restaurant's `full_address` as `origin` instead of a city name is the obvious refinement; it's still one call.

## What should a tool hand back to the model?

A tool's result should carry the fields the model needs to answer and nothing else. The recorded `simple-search` place has 28 top-level fields, including photo samples, owner links and accessibility attributes. Each one costs tokens every time the model reads the result. If you wrap the endpoint yourself, trim it in code before returning:

```python
import os

import requests

def find_places(query, limit=5):
    resp = requests.get(
        "https://api.perceptlayer.com/v1/google-maps/simple-search",
        params={"query": query},
        headers={"X-API-Key": os.environ["API_KEY"]},
        timeout=60,
    )
    if resp.status_code != 200:
        return {"error": resp.json().get("error", {}).get("code")}
    keep = ("name", "rating", "review_count", "full_address", "business_id")
    return [{k: p.get(k) for k in keep} for p in resp.json().get("items", [])[:limit]]
```

Keep `business_id` even though the model won't show it to the user: it's what a later lookup needs. For reviews, the recorded `reviews` items include `author_name`, `author_link` and profile photos; drop those and pass `rating`, `timestamp` and `review_text`. [Trim API Responses for LLM Context](https://perceptlayer.com/blog/trim-api-responses-llm-context) goes further.

Errors are results too. A failed call returns an HTTP status and a JSON body with `error.code`, such as `invalid_parameters` (422) or `rate_limited` (429), and costs nothing. Return the code to the model so it can fix its arguments or wait. The [errors docs](https://docs.perceptlayer.com/errors) list every code.

## What does an agent's tool use cost?

Discovery is free and data costs per successful call, so an agent's bill is the number of data calls that succeed. The worked example above is 2 credits per question. At 200 questions a day, that's 200 × 2 × 30 = 12,000 credits a month, well past the 100 free credits and inside the Build pack's 50,000. An agent that asks for reviews on its top pick adds one more credit per question.

The free tier is 100 credits, granted once when you verify your email, with no card, which covers 50 runs of the example. See [pricing](https://perceptlayer.com/pricing) for packs. To try the calls yourself, run `simple-search` and `directions` in the playground on the [Google Maps API page](https://perceptlayer.com/apis/google-maps), then [get a free API key](https://perceptlayer.com/signup) and add the MCP server.

## APIs in this post

-   [Google Search **1 credit per call** · 7 endpoints](https://perceptlayer.com/apis/google-search)
-   [Google Maps **1 credit per call** · 11 endpoints](https://perceptlayer.com/apis/google-maps)

## Frequently asked questions

### What are AI agent tools?

AI agent tools are functions a model can request by name. Each has a description that tells the model when to use it, an input schema for its arguments, and a result the model reads after your code or an MCP server runs the call. For web data, the useful kinds are search, lookup and fetch.

### Do search\_endpoints and get\_endpoint cost credits?

No. Both only look up the catalogue and cost nothing, so an agent can browse endpoints and read their parameters as often as it needs. Only `call_endpoint` spends credits: the endpoint's cost, 1 for nearly all, and only when the call succeeds. It reports the credits used and remaining after each call.

### How many tools should an agent have?

As few as cover its questions. Every tool definition sits in the model's context, so one tool per endpoint doesn't scale to 3,834 endpoints. Either write a handful of trimmed tools for the endpoints you use most, or give the agent the three MCP tools and let it find endpoints with `search_endpoints` when it needs them.

### What happens when a tool call fails?

The endpoint returns an HTTP status and a JSON error with a `code`, a `message` and a `request_id`, and nothing is debited. `rate_limited` (429) and `temporarily_unavailable` (503) come with a `Retry-After` header. Pass the code back to the model so it can correct its arguments, wait, or try another source.

### Can I use these tools without MCP?

Yes. Every endpoint is a plain HTTPS `GET` with an `X-API-Key` header, so you can wrap any of them as a function tool in your own framework, as the `find_places` example does. MCP saves you writing and maintaining those wrappers; hand-written tools let you trim each result exactly.

ai agents mcp tool calling web data google maps

## More from the blog

1.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 20 Jul 2026 Perceptlayer 7 min read
    
    ## [LLM Tool Schema Design: A Checklist for Web APIs](https://perceptlayer.com/blog/agent-tool-schema-design-web-apis)
    
    LLM tool schema design checklist, applied to the Google Maps simple-search endpoint: a before and after schema that cuts 28 result fields to 7.
    
2.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 13 Oct 2026 Updated 10 Nov 2026 Perceptlayer 7 min read
    
    ## [What Is an MCP Server? A Working Example with Web Data](https://perceptlayer.com/blog/what-is-an-mcp-server)
    
    An MCP server exposes tools, resources and prompts to AI apps over stdio or Streamable HTTP. See a real tools/list and tools/call, and what each costs.
    
3.  [AI agents](https://perceptlayer.com/blog/category/ai-agents) 26 Sept 2026 Perceptlayer 7 min read
    
    ## [MCP Server Too Many Tools: Keeping Agent Context Small](https://perceptlayer.com/blog/mcp-too-many-tools-context)
    
    One tool per endpoint for 1,659 endpoints is about 567,000 characters of schema. A 10-step checklist to keep an MCP server's tool list small.
