How to use MCP tools in an agent

developer2026-12-04

On this page

To use MCP tools, point an MCP client at an MCP server, then let the model list the available tools and call them by name. The client sends JSON-RPC requests, the server runs the tool, and the result returns to the model as structured JSON.

How an MCP tool call works

An MCP client, such as a desktop assistant or a coding agent, talks to an MCP server over JSON-RPC. The client asks the server which tools it offers, then calls one tool at a time with arguments. The server returns the result, and the model reads that result on its next turn.

  • Initialize: the client and server agree on a protocol version and exchange capabilities.
  • List tools: the client requests each tool name, its description, and its input schema.
  • Call tool: the client sends a tool name and arguments, and the server returns the output.

Each step runs in a fixed order. A client that skips the list step has to guess tool names, and most guesses fail.

Connect your client to a server

Start with a gateway key. Copy the endpoint and key from your APIbase dashboard, then add them to the MCP configuration file that your client reads. Most clients accept a server name, a transport type, a URL, and a set of headers.

Restart the client after you edit the file. The client should show the server and its tools in the tool panel. If the list stays empty, the client has not loaded the file, so check the file path and the JSON syntax first.

Keep one server entry per gateway. Two entries that point at the same endpoint make the tool list harder to read and make errors harder to trace.

Set up keys and environment variables

Store keys in environment variables or a secrets manager. The client reads the variable at launch, so the key never appears in the config file you share with teammates.

Give each agent its own key. A separate key shows which agent made which call, and you can revoke one agent without breaking the others.

Rotate a key when a team member leaves or when a key appears in a log file. Rotation takes a minute, and it closes the exposure.

Call a tool from your agent code

Your agent does not need to know a tool in advance. It reads the list, picks a tool whose description fits the task, and fills the arguments from the input schema.

Write clear tool descriptions when you build your own server. The model chooses tools from those words, so a vague description produces wrong calls.

Pass arguments that match the schema exactly. Missing required fields and wrong types cause the server to reject the call before any work runs.

Read the result and handle errors

A successful call returns content blocks. Text blocks carry the answer, and structured content carries JSON that the agent can parse. An error result sets a flag and includes a message that the model can read.

Handle three common failures in your agent loop:

  • Retry transient network failures with a short backoff.
  • Stop on authentication errors and fix the key before you retry.
  • Log the tool name and arguments so you can replay a failed call.

Test a tool before you build on it

Call the tool once by hand with a small, safe input. Check the output shape, the response time, and the error messages.

Write the agent prompt around the fields you actually saw. The description promises fields, but the output is what your code must parse.

Record the result from that first call. A later change to the tool then shows up as a difference, not as a surprise in production.

Pricing and payment for tool calls

Each tool sets its own price. Across the catalog, per-call prices range from None to None USD. Check the price on the tool page before you run a paid call.

Some tools settle in USDC through x402 or MPP. Your agent needs a funded wallet before it calls those tools. Free tools need only a gateway key.

Use MCP tools outside a chat client

You can call the same server from a script. Open a session, send the initialize request, call the list method, then send a tool call. A script skips the chat loop. That makes it a good fit for batch jobs, such as enriching a list of company names.

A command line client works the same way. Pass a tool name and JSON arguments to the client, then parse the output in your shell.

Common mistakes to avoid

  • Pasting a key into a public repository instead of an environment variable.
  • Mixing transport types, such as sending local process settings to a remote HTTP endpoint.
  • Skipping the list step and guessing tool names.

Each mistake looks like a tool failure at first. Check the configuration and the list output before you change the tool code.

Live pricing — developer

Price per call, developer tools Horizontal bar chart of the price per call and the cache-hit price, in US dollars, for 8 developer tools. The same values are in the table below the chart. Price per call Cache-hit price $0.0 $0.5 $1.0 Usage Time SeriesUsage Time Series $0.0 $0.0 Per-Tool Usage BreakdownPer-Tool Usage Breakdown $0.0 $0.0 Usage SummaryUsage Summary $0.0 $0.0 Call ToolCall Tool $0.0 $0.0 List Tool CategoriesList Tool Categories $0.0 $0.0 Describe ToolDescribe Tool $0.0 $0.0 Discover ToolsDiscover Tools $0.0 $0.0 Global VIN DecodeGlobal VIN Decode $0.0 $0.0 US dollars per call
Price per call for developer tools, cheapest first.

Data source: live tool catalog snapshot, fetched 2026-12-04.

Chart data as a table
ToolPrice per callCache-hit price
Usage Time Series$0.0$0.0
Per-Tool Usage Breakdown$0.0$0.0
Usage Summary$0.0$0.0
Call Tool$0.0$0.0
List Tool Categories$0.0$0.0
Describe Tool$0.0$0.0
Discover Tools$0.0$0.0
Global VIN Decode$0.0$0.0
ToolProviderPrice/callCache-hit
Usage Time Series$None$None
Per-Tool Usage Breakdown$None$None
Usage Summary$None$None
Call Tool$None$None
List Tool Categories$None$None
Describe Tool$None$None
Discover Tools$None$None
Global VIN Decode$None$None

Connect via MCP

How a tool call worksAn AI agent sends a tool call to the APIbase gateway. The gateway checks payment, calls the provider API, and returns the JSON result to the agent.Your agentAPIbase gatewayProvider API1. tool call2. paid call3. JSON result flows back to the agent
Diagram: the path of one tool call.

Data source: gateway design, no measured values.

$ curl -X POST https://apibase.pro/api/v1/tools/account.timeseries/call \
  -H "Content-Type: application/json" -d '{"params": {}}'

FAQ

How do I start using MCP tools in an agent?

Add an MCP server to your client configuration, restart the client, and confirm that the tools appear in the tool list. Then give the agent a task that needs one of those tools.

Do I need to write code to use MCP tools?

No. A desktop or coding client can call tools from a configuration file alone. Code helps when you run batch jobs or build your own agent loop.

What does a tool call cost?

Each tool sets its own price, between None and None USD per call. Free tools need only a gateway key.

Which transport should I choose?

Use the transport the server documents. Remote servers usually run over HTTP, and local servers usually run over standard input and output.

  1. STEP 1/2 Connect your MCP client
  2. STEP 2/2 Browse the full catalog

Written with AI assistance from APIbase's published documentation and public data; checked automatically against them. Corrections: https://apibase.pro/

Published: 2026-12-04Source: live apibase.pro catalog snapshot