get_serp
Retrieve real-time SERP data for specific keywords, languages, and locations to analyze search engine rankings and optimize SEO strategies.
Instructions
Get SERP data from SEO Review Tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hl | Yes | The language for the search results. | |
| keyword | Yes | The keyword to search for. | |
| location | Yes | The location for the search results. |
Implementation Reference
- The core handler function `executeFunction` that makes an API request to SEO Review Tools to retrieve SERP rankings data based on keyword, language (hl), and location.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 defining the required parameters: keyword (string), hl (language, string), location (string).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)The `discoverTools` function dynamically imports tool modules (including get-serp.js via paths.js) and extracts the `apiTool` object containing the handler and definition for registration in the MCP system.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 (helper)List of all tool file paths used by discoverTools to load tools, including the path to get-serp.js.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' ];