- A language model has no live view of the web's links or search demand, so asked for a domain's authority or a keyword's volume it can only produce a plausible-looking number. Tool calling fixes that by letting it ask your code for the real figure.
- Claude and OpenAI models use the same idea: you describe a tool with a name, a description and a JSON Schema; the model returns a call; your server runs it and sends the result back.
- With MrKeyword's Data API,
/domains/overviewcosts 3 credits and/keywords/metrics1 credit per keyword; difficulty and intent cost 1 credit per 10 keywords, so batching matters. - Keep the
mkd_key on your server, never in a prompt, a browser or the model's output, and cache results by theirasOfdate. - Use the Data API to build on MrKeyword's index for many users. Use the MCP server (
mk_tokens) when one person wants their own Search Console, ranking and audit data inside Claude or Cursor.
Why do LLMs get SEO metrics wrong?
Language models get SEO metrics wrong because the numbers are not in the model: authority scores, backlink counts and search volumes live in vendors' databases, change every month, and differ between vendors, so a model asked for one fills the gap with a plausible guess. The guess often looks right, which is the problem.
Three things make SEO numbers especially hard for a model on its own:
- They are proprietary scales. "Domain authority" means Moz DA, Ahrefs DR, Semrush Authority Score or MrKeyword Link Authority, each a different model over a different index (see What is domain authority?). A model cannot compute any of them.
- They move. Links are gained and lost, volumes shift with seasons, and anything a model saw in training is out of date by the time someone asks.
- Most domains and keywords were never written about. For a small business site or a long-tail keyword, there is nothing to remember, so any figure is invented.
The fix is not a better prompt. It is giving the model a way to fetch the figure from a source, with the source's date and label attached, and telling it to quote only what the tool returned.
How does tool calling give an AI agent real SEO data?
Tool calling lets the model ask your application to run a function: you declare the function with a JSON Schema, the model replies with a structured call instead of an answer, your server runs it, and you send the result back so the model can answer from it. Anthropic and OpenAI document the same loop with different field names.
-
Declare the tools
Send the tool definitions with the request. Anthropic's Define tools page lists
name,descriptionandinput_schema; OpenAI's function calling guide usestype: "function",name,description,parametersandstrict. -
The model returns a call
Claude stops with
stop_reason: "tool_use"and atool_useblock naming the tool and its input. An OpenAI model returns afunction_callitem with acall_id, the name and JSON-encoded arguments. Either may ask for several calls at once. -
Your server runs it
Your code calls the SEO API with your key. The model never sees the key and never makes the HTTP request itself.
-
Send the result back
Return it as a
tool_resultblock with the matchingtool_use_id(Claude) or afunction_call_outputitem with the matchingcall_id(OpenAI). The model then answers, or asks for another call.
Anthropic's tool use overview notes that with the default auto setting, Claude calls a tool when the request maps to the tool's described capability and the answer is not already in context. That is exactly the behaviour you want for metrics: the description is what tells the model "numbers come from here".
What does an SEO tool definition look like?
An SEO tool definition is a name, a description that says what the tool returns and when to use it, and a JSON Schema for its inputs; the same schema works for Claude, OpenAI models and most other function-calling models. Here are two tools over MrKeyword's Data API, one for a domain and one for a list of keywords.
Two generic tool definitions (JSON Schema)
[
{
"name": "seo_domain_overview",
"description": "Returns SEO data for one domain from MrKeyword's own index: link authority (0-100), estimated monthly organic clicks with a low-high range, referring domains, backlinks and top anchors, indexed pages, registration date and hosting. Use it whenever the user asks about a website's authority, backlinks or traffic. Every figure has a label (Measured, Derived, Estimated, Predicted or Not available), an asOf date and a source: repeat the label and date in your answer. If a value is null, say it is not available and give the reason; never estimate it yourself. It does not return live Google rankings.",
"input_schema": {
"type": "object",
"properties": {
"domain": { "type": "string", "description": "A bare domain such as example.com, without https:// or a path." }
},
"required": ["domain"],
"additionalProperties": false
}
},
{
"name": "seo_keyword_metrics",
"description": "Returns monthly search volume (Google Ads Keyword Planner, looked up live when not yet stored), CPC range, competition, difficulty (0-100, estimated) and search intent for up to 100 keywords in one market. Use it whenever the user asks how many people search for something or how hard a keyword is. Send all keywords in one call rather than one call per keyword. Keywords not in MrKeyword's database come back with found: false; say so rather than guessing a volume.",
"input_schema": {
"type": "object",
"properties": {
"keywords": { "type": "array", "items": { "type": "string" }, "maxItems": 100, "description": "The keywords, lower case." },
"market": { "type": "string", "enum": ["US", "CA", "IN", "GB", "AU"], "description": "Country market for volume and difficulty." }
},
"required": ["keywords", "market"],
"additionalProperties": false
}
}
]
The descriptions do most of the work. Anthropic's guidance calls detailed descriptions "by far the most important factor in tool performance" and suggests saying what the tool does, when to use it and what it does not return. OpenAI's guide makes the same point and recommends enums to rule out invalid inputs, which is why market is an enum. Both also advise keeping the tool count small: two or three well-described SEO tools beat a tool per endpoint.
How does the server run the tool call?
Your server maps each tool name to one fixed API request, adds the key from an environment variable, and returns the JSON (or an error the model can read). Here is a minimal handler in JavaScript using MrKeyword's base URL https://app.mrkeyword.io/api/v1.
A minimal tool handler (Node.js 18+)
const BASE = "https://app.mrkeyword.io/api/v1";
const headers = {
"Authorization": "Bearer " + process.env.MRKEYWORD_API_KEY, // mkd_... kept on the server
"content-type": "application/json",
};
async function runSeoTool(name, input) {
let res;
if (name === "seo_domain_overview") {
res = await fetch(BASE + "/domains/overview?domain=" + encodeURIComponent(input.domain), { headers });
} else if (name === "seo_keyword_metrics") {
res = await fetch(BASE + "/keywords/metrics", {
method: "POST", headers,
body: JSON.stringify({ keywords: input.keywords, market: input.market }),
});
} else {
return { error: "Unknown tool" };
}
const body = await res.json();
if (!res.ok) return { error: body.error, status: res.status }; // 402 credits, 429 rate limit
return body.data; // keep meta (credits) for your own logs, not for the model
}
Every successful response is { data, meta }. Give the model data, and keep meta.creditsCharged and meta.creditsRemaining for your own usage tracking. Anthropic recommends tool responses that return only high-signal information, so consider trimming each figure to its value, label, asOf and source before sending it back. Long backlink lists waste context; summarise or cap them.
Add one line to your system prompt as well, in your own words: SEO figures must come from the tools, with their label and date, and anything the tools do not return is "not available". This is our practice rather than a vendor rule, but it stops the model from padding an answer with remembered numbers.
Get a key with 500 free creditsCreate a MrKeyword workspace, open Data API, create an mkd_ key and plug it into the handler above. The Developer plan needs no card.
Which SEO endpoints should an AI agent use?
Map each kind of user question to one endpoint, and prefer the cheapest endpoint that answers it. These are the MrKeyword endpoints an assistant usually needs, with their price per call.
User questions mapped to Data API endpoints
| The user asks | Endpoint | Credits |
|---|---|---|
| "Tell me about this website" | GET /domains/overview | 3 |
| "Which of these 40 domains are strongest?" | POST /domains/authority (up to 100) | 1 per domain |
| "How much traffic does this site get?" | GET /domains/traffic | 1 |
| "How many people search for these?" | POST /keywords/metrics (up to 100) | 1 per keyword |
| "How hard are these keywords?" | POST /keywords/difficulty (up to 500) | 1 per 10 |
| "Group these keywords into topics" | POST /keywords/cluster (up to 500) | 1 per 10 |
| "What does a competitor rank for?" | GET /domains/organic-keywords | 3 |
| "Who links to this site?" | GET /domains/referring-domains | 2 |
GET /api/v1/catalog without a key. Competitor keywords are labelled Predicted, traffic Estimated.How do you save credits with batching and caching?
Batch every list into one call, because MrKeyword charges difficulty, intent and clustering at 1 credit per 10 keywords, and cache results by domain or keyword so repeat questions cost nothing. Agents are chatty: without both, the same lookup is often paid for several times in one conversation.
- Batch. 100 keywords' difficulty is 10 credits in one POST, but 100 credits as 100 single calls (each call is charged at least 1). Tell the model in the tool description to send all keywords at once, and accept arrays in the schema.
- Cache. Key a cache on endpoint plus input, and reuse the result within a conversation and across users. The data is computed from MrKeyword's index and carries an
asOfdate, so a cache of a few hours to a day for authority and traffic keeps answers current enough for most assistants. - Pick the cheap endpoint. If the user only asked about authority,
/domains/authorityat 1 credit beats/domains/overviewat 3. - Watch the balance.
GET /api/v1/usagecosts 0 credits. A 402 means the balance is spent; a 429 carriesRetry-After; a 500 is not charged.
Worked example: an assistant that handles 1,000 conversations a month, each running one domain overview (3 credits) and metrics for 10 keywords (10 credits), uses 13,000 credits. That fits API Starter at $29 a month (20,000 credits). The free Developer plan's 500 credits a month covers building and testing. API Growth is $99 for 100,000 credits, API Scale $299 for 400,000, and a $20 pack adds 10,000 credits that last 12 months. For a breakdown of tool-builder costs, see SEO API: how to build your own keyword or domain tool.
How do you keep SEO API keys safe in an AI app?
Keep the key in a server environment variable and make every API call from your backend; never put it in a prompt, a tool result, client-side code or anything the model can repeat. A model can be talked into printing its context, so anything in the context should be safe to leak.
- Server only. MrKeyword's API allows cross-origin requests, but its documentation says keys belong on a server, not in a browser.
- Fixed endpoints. Let the model choose a tool and its inputs, never a URL. Text the model reads from a web page or a user could otherwise steer requests.
- One key per environment. Workspace owners and admins can create up to 20 live keys, each with an optional expiry, and revoke one on the Data API screen; it stops working on the next call.
- Per-user limits. Your app pays for every call, so cap tool calls per user and per conversation in your own code.
Data API or MCP server: which one do you need?
Use the Data API when you are building your own app for many users on MrKeyword's index; use the MCP server when a person wants their own MrKeyword workspace, with its Search Console, ranking and audit data, inside an AI assistant such as Claude or Cursor. They use different keys and answer different questions.
MrKeyword Data API compared with the MrKeyword MCP server
| Data API | MCP server | |
|---|---|---|
| Data | MrKeyword's index: any domain's authority, traffic estimate, backlinks; keyword metrics; predicted rankings | One workspace's own sites: Search Console and Bing data, tracked rankings, site audits, reports, opportunities |
| Endpoint | REST at https://app.mrkeyword.io/api/v1 | JSON-RPC 2.0 over POST at https://app.mrkeyword.io/mcp |
| Credential | mkd_ key, created under Data API | mk_ token, created under Settings → Connections → API & MCP Tokens, bound to one workspace |
| Surface | 16 endpoints, priced in credits | 25 tools (20 read, 5 action; actions need a token with the actions scope), 120 calls a minute per token |
| Best for | Your own AI product, GPT-style app or agent serving many users | A person or team asking Claude Code, Claude Desktop or Cursor about their own sites |
The Model Context Protocol is an open standard for connecting AI applications to external systems, so an MCP-capable client discovers MrKeyword's tools itself and you write no handler. For setup, see connecting Claude to an SEO MCP server. If the question is instead whether AI assistants mention your brand, that is a different job, covered by AI visibility tracking.
What MrKeyword does not do
MrKeyword's Data API gives an agent MrKeyword's own, labelled data; it does not give it live Google results, a complete web backlink index, or volume for every keyword. Tell your model these limits in the tool descriptions so it can tell users.
- No live SERPs. Nothing is scraped from Google.
/serp/predictedand/domains/organic-keywordsare labelledPredictedfrom MrKeyword's public page index. - Own index coverage. Backlinks and referring domains are those MrKeyword's crawler and the Common Crawl web graph have found, so counts are lower than the largest commercial indexes.
- Estimates are labelled. Traffic and difficulty are
Estimated; a domain MrKeyword has not seen returns nulls with areason. - Five markets, with a daily live-lookup allowance. Volumes are Google Ads Keyword Planner figures for US, CA, IN, GB and AU. A keyword MrKeyword has not stored is looked up live and saved, up to the API plan's daily allowance of live lookups; a keyword with no volume answers
found: falseand is not charged. - No model included. MrKeyword sells the data, not the language model; you bring Claude, an OpenAI model or another.
Questions and answers
SEO data for AI agents questions
Why does ChatGPT or Claude make up SEO metrics?
Authority scores, backlink counts and search volumes live in SEO vendors' databases and change monthly, so they are not in the model. Asked for one, a model produces a plausible guess. Giving it a tool that fetches the figure from an SEO data API fixes that.
How do I give my AI agent real SEO data?
Define a tool with a name, a description and a JSON Schema for its inputs, let the model return a call, run the call on your server against an SEO data API such as MrKeyword's /api/v1/domains/overview, and send the JSON result back as a tool_result (Claude) or function_call_output (OpenAI).
Does the same tool definition work with Claude and OpenAI?
The JSON Schema does. Claude takes name, description and input_schema; OpenAI takes type: function, name, description and parameters, with optional strict mode. Rename the schema field and the definition carries over.
How many credits does an AI SEO assistant use?
On MrKeyword's Data API, a domain overview is 3 credits and keyword metrics 1 credit per keyword. An assistant running one overview and 10 keyword lookups in each of 1,000 conversations a month uses 13,000 credits, which fits API Starter at $29 a month (20,000 credits).
Can I call the SEO API from the browser?
MrKeyword's API allows cross-origin requests, but keys belong on a server. Put the mkd_ key in a server environment variable, make the calls from your backend, and never place the key in a prompt or tool result.
What is the difference between MrKeyword's Data API and its MCP server?
The Data API (mkd_ keys, https://app.mrkeyword.io/api/v1) sells MrKeyword's index data for your own product. The MCP server (mk_ tokens, https://app.mrkeyword.io/mcp) gives an assistant like Claude or Cursor one workspace's own Search Console, ranking and audit data.
Sources
- Tool use with Claude — Anthropic, on client tools, stop_reason tool_use, tool_result and when Claude calls tools
- Define tools — Anthropic, on tool definition fields and writing detailed descriptions
- Function calling — OpenAI, on function tool definitions, call_id, function_call_output, strict mode and best practices
- What is the Model Context Protocol (MCP)? — The MCP project's definition of the protocol

