get_keyword_statistics
Retrieve keyword statistics including search volume, competition, and trends to analyze SEO performance and identify optimization opportunities.
Instructions
Get keyword statistics from SEO Review Tools.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"keywords": "<keywords>"
},
"name": "get_keyword_statistics"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keywords | Yes | The keywords to get statistics for. | |
| hl | No | The language for the response. | |
| location | No | The location for the keyword statistics. |
Implementation Reference
- The handler function `executeFunction` that implements the core logic: constructs and sends a POST request to the SEO Review Tools API for keyword statistics, handles response and errors.
const executeFunction = async ({ keywords, hl = 'English', location = 'United States' }) => { const baseUrl = 'https://api.seoreviewtools.com/keyword-statistics/'; const token = process.env.SEO_API_WORKSPACE_API_KEY; try { // Construct the request body const body = JSON.stringify({ keywords }); // Set up headers for the request const headers = { 'Content-Type': 'application/json', 'X-API-Key': token }; // Construct the URL with query parameters const url = new URL(baseUrl); url.searchParams.append('hl', hl); url.searchParams.append('location', location); // Perform the fetch request const response = await fetch(url.toString(), { method: 'POST', headers, body }); // Check if the response was successful if (!response.ok) { const errorData = await response.json(); throw new Error(errorData); } // Parse and return the response data const data = await response.json(); return data; } catch (error) { console.error('Error getting keyword statistics:', error); return { error: 'An error occurred while getting keyword statistics.' }; } }; - The JSON schema defining the tool's input parameters: required 'keywords' array, optional 'hl' and 'location' strings.
parameters: { type: 'object', properties: { keywords: { type: 'array', items: { type: 'string' }, description: 'The keywords to get statistics for.' }, hl: { type: 'string', description: 'The language for the response.' }, location: { type: 'string', description: 'The location for the keyword statistics.' } }, required: ['keywords'] } - The `apiTool` export containing the handler reference, tool name, description, and schema; loaded dynamically by `discoverTools()`.
const apiTool = { function: executeFunction, definition: { type: 'function', function: { name: 'get_keyword_statistics', description: 'Get keyword statistics from SEO Review Tools.', parameters: { type: 'object', properties: { keywords: { type: 'array', items: { type: 'string' }, description: 'The keywords to get statistics for.' }, hl: { type: 'string', description: 'The language for the response.' }, location: { type: 'string', description: 'The location for the keyword statistics.' } }, required: ['keywords'] } } } }; export { apiTool }; - tools/paths.js:1-10 (registration)The `toolPaths` array includes the path to this tool's module, used by `discoverTools()` to dynamically import it.
export const toolPaths = [ 'seo-api-workspace/seo-ap-is-seo-review-tools/get-website-traffic.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-authority.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-serp.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/post-bulk-website-traffic.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-backlinks.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-seo-content-score.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-keyword-statistics.js', 'seo-api-workspace/seo-ap-is-seo-review-tools/get-keyword-suggestions.js' ]; - lib/tools.js:7-16 (registration)The `discoverTools()` function dynamically imports all tools from `toolPaths`, including this one, and extracts the `apiTool` for registration in the MCP server.
export async function discoverTools() { const toolPromises = toolPaths.map(async (file) => { const module = await import(`../tools/${file}`); return { ...module.apiTool, path: file, }; }); return Promise.all(toolPromises); }