Execute API calls with schema validation
The agent retrieves the input schema for a specific API SKU, validates user-provided parameters against it, and executes the request via the MCP server to fetch normalized data while tracking costs.
How it works
The agent first uses the get_api tool to retrieve the JSON schema for the target API SKU. It then checks the user's input against the declared inputSchema fields, ensuring no guessed fields like 'limit' or 'cursor' are added unless explicitly declared. Finally, it executes the run_api tool with the validated parameters. The agent should check the response for 'invalid_input' errors and compare the request against the schema if they occur, rather than retrying with guessed names.
Prompt
Paste this into an agent that has the servers below connected. Adjust the names and dates to your own.
I need to fetch data from the Ahrefs API. First, get the API schema for the Ahrefs SKU. Then, validate my input parameters against that schema. Finally, execute the API call using the run_api tool. Ensure you only use fields declared in the inputSchema.MCP servers it needs
Source
The vendor page this playbook is drawn from, and the passage that supports it.
Use only the fields declared in inputSchema . Input fields are SKU-specific, so do not add names such as limit , cursor , page , or sort unless that schema declares them.Introduction - AnyAPI