keywords_for_site
Retrieve keywords a domain ranks for in a specific location. Includes rank positions and search volume to analyze local SEO performance.
Instructions
Get keywords a domain currently ranks for. Returns keywords with rank positions and search volume. Costs 3 credits.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domain | Yes | Domain to analyze (e.g. "example.com") | |
| location | Yes | Geographic location (e.g. "Orchard Park, NY") | |
| limit | No | Max results. Default: 50, max: 1000 |
Implementation Reference
- src/tools/keywords.ts:75-92 (handler)The handler for the 'keywords_for_site' tool. It calls /v1/keywords/for-site API with domain, location, and optional limit parameters, then formats the result.
server.tool( "keywords_for_site", "Get keywords a domain currently ranks for. Returns keywords with rank positions and search volume. Costs 3 credits.", { domain: z.string().min(1).describe('Domain to analyze (e.g. "example.com")'), location: z.string().min(1).describe('Geographic location (e.g. "Orchard Park, NY")'), limit: z.number().int().min(1).max(1000).optional().describe("Max results. Default: 50, max: 1000"), }, READ_ONLY, withErrorHandling(async ({ domain, location, limit }) => { const result = await callApi( "/v1/keywords/for-site", { domain, location, ...(limit && { limit }) }, getAuth() ); return { content: [{ type: "text" as const, text: formatResult(result.data, result) }] }; }) ); - src/tools/keywords.ts:78-82 (schema)Zod schema defining the input parameters: domain (required string), location (required string), and limit (optional integer, 1-1000).
{ domain: z.string().min(1).describe('Domain to analyze (e.g. "example.com")'), location: z.string().min(1).describe('Geographic location (e.g. "Orchard Park, NY")'), limit: z.number().int().min(1).max(1000).optional().describe("Max results. Default: 50, max: 1000"), }, - src/server.ts:42-42 (registration)Registration of all keyword tools (including keywords_for_site) on the MCP server.
registerKeywordTools(server, getAuth); - src/server.ts:10-11 (registration)Import of the registerKeywordTools function from keywords.ts.
import { registerKeywordTools } from "./tools/keywords.js"; import { registerBacklinkTools } from "./tools/backlinks.js"; - src/api-client.ts:143-158 (helper)Helper wrapper that catches errors from the handler and returns them as MCP error content.
export function withErrorHandling<T>( fn: (args: T) => Promise<ToolResult> ): (args: T) => Promise<ToolResult> { return async (args) => { try { return await fn(args); } catch (err) { const message = err instanceof Error ? err.message : String(err); console.error(`[mcp] Tool error: ${message}`); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } }; }