get_serp
Retrieve search engine results page data to analyze keyword performance and competitive rankings for SEO strategy development.
Instructions
Get SERP data 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": {
"keyword": "<keyword>",
"hl": "<hl>",
"location": "<location>"
},
"name": "get_serp"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | The keyword to search for. | |
| hl | Yes | The language for the search results. | |
| location | Yes | The location for the search results. |
Implementation Reference
- The handler function `executeFunction` that fetches SERP data from the SEO Review Tools API using the provided keyword, language (hl), and location parameters.
const executeFunction = async ({ keyword, hl, location }) => { const baseUrl = 'https://api.seoreviewtools.com'; const apiKey = process.env.SEO_API_WORKSPACE_API_KEY; try { // Construct the URL with query parameters const url = new URL(`${baseUrl}/rankings/`); url.searchParams.append('keyword', keyword); url.searchParams.append('hl', hl); url.searchParams.append('location', location); url.searchParams.append('key', apiKey); // Perform the fetch request const response = await fetch(url.toString(), { method: 'GET', headers: { 'Content-Type': 'application/json' } }); // 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 SERP data:', error); return { error: 'An error occurred while getting SERP data.' }; } }; - The input schema definition for the 'get_serp' tool, specifying parameters keyword, hl, and location as required strings.
name: 'get_serp', description: 'Get SERP data from SEO Review Tools.', parameters: { type: 'object', properties: { keyword: { type: 'string', description: 'The keyword to search for.' }, hl: { type: 'string', description: 'The language for the search results.' }, location: { type: 'string', description: 'The location for the search results.' } }, required: ['keyword', 'hl', 'location'] } } } - lib/tools.js:7-16 (registration)Dynamic registration/discovery of all tools via `discoverTools()`, which imports `apiTool` from each file in `toolPaths`, including get-serp.js.
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); } - tools/paths.js:1-10 (registration)Configuration listing paths to tool files, including 'seo-api-workspace/seo-ap-is-seo-review-tools/get-serp.js' at line 4, used for dynamic tool discovery.
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' ];