$npx -y skills add LambdaTest/agent-skills --skill ai-based-apiDesigns AI-powered API features, LLM tool/function definitions, MCP server tool schemas, natural language to API conversion, and agentic API workflows. Use whenever the user asks about "AI calling my API", "function calling schema", "tool definition for LLM", "MCP tools", "natura
| 1 | # AI-Augmented API Skill |
| 2 | |
| 3 | Design LLM tool definitions, agentic workflows, and natural language API interfaces. |
| 4 | |
| 5 | --- |
| 6 | |
| 7 | ## Anthropic Tool Use Definition |
| 8 | |
| 9 | ```json |
| 10 | { |
| 11 | "name": "search_products", |
| 12 | "description": "Search for products by keyword, category, or price range. Use when the user wants to find, browse, or compare products.", |
| 13 | "input_schema": { |
| 14 | "type": "object", |
| 15 | "properties": { |
| 16 | "query": { |
| 17 | "type": "string", |
| 18 | "description": "Search query keywords" |
| 19 | }, |
| 20 | "category": { |
| 21 | "type": "string", |
| 22 | "enum": ["electronics", "clothing", "books", "home"], |
| 23 | "description": "Optional category filter" |
| 24 | }, |
| 25 | "min_price": { "type": "number", "description": "Minimum price in USD" }, |
| 26 | "max_price": { "type": "number", "description": "Maximum price in USD" }, |
| 27 | "limit": { "type": "integer", "default": 10, "description": "Max results to return" } |
| 28 | }, |
| 29 | "required": ["query"] |
| 30 | } |
| 31 | } |
| 32 | ``` |
| 33 | |
| 34 | --- |
| 35 | |
| 36 | ## OpenAI Function Calling Definition |
| 37 | |
| 38 | ```json |
| 39 | { |
| 40 | "type": "function", |
| 41 | "function": { |
| 42 | "name": "create_order", |
| 43 | "description": "Create a new order for a user. Use when the user wants to purchase a product. Always confirm product and quantity before calling.", |
| 44 | "parameters": { |
| 45 | "type": "object", |
| 46 | "properties": { |
| 47 | "product_id": { "type": "string", "description": "The product ID to order" }, |
| 48 | "quantity": { "type": "integer", "minimum": 1, "description": "Quantity to order" }, |
| 49 | "shipping_address": { |
| 50 | "type": "object", |
| 51 | "properties": { |
| 52 | "street": { "type": "string" }, |
| 53 | "city": { "type": "string" }, |
| 54 | "country": { "type": "string" } |
| 55 | }, |
| 56 | "required": ["street", "city", "country"] |
| 57 | } |
| 58 | }, |
| 59 | "required": ["product_id", "quantity", "shipping_address"] |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | ``` |
| 64 | |
| 65 | --- |
| 66 | |
| 67 | ## MCP (Model Context Protocol) Tool Schema |
| 68 | |
| 69 | ```json |
| 70 | { |
| 71 | "name": "get_build_status", |
| 72 | "description": "Get the status of a HyperExecute test job. Use when the user asks about test results, job status, or CI build outcomes.", |
| 73 | "inputSchema": { |
| 74 | "type": "object", |
| 75 | "properties": { |
| 76 | "job_id": { "type": "string", "description": "The HyperExecute job ID" } |
| 77 | }, |
| 78 | "required": ["job_id"] |
| 79 | } |
| 80 | } |
| 81 | ``` |
| 82 | |
| 83 | > 🔗 **Real-World Integration — TestMu AI HyperExecute** |
| 84 | > Build MCP tools that let AI agents query and control test jobs via the HyperExecute API. |
| 85 | > Docs: https://www.testmuai.com/support/api-doc/?key=hyperexecute |
| 86 | |
| 87 | --- |
| 88 | |
| 89 | ## Tool Design Principles |
| 90 | |
| 91 | 1. **One tool = one action**: Don't combine search + filter + sort into one tool. Split them. |
| 92 | 2. **Description drives routing**: The LLM picks tools from descriptions — be specific and include trigger phrases. |
| 93 | 3. **Required vs optional**: Only mark fields `required` if the API truly needs them. |
| 94 | 4. **Enum for constrained values**: Use `enum` instead of `string` for fixed-choice fields. |
| 95 | 5. **Idempotent where possible**: Prefer read tools over write tools for exploration. |
| 96 | 6. **Confirm before destructive actions**: Description should say "Always confirm with the user before calling." |
| 97 | |
| 98 | --- |
| 99 | |
| 100 | ## Agentic Workflow Example |
| 101 | |
| 102 | ``` |
| 103 | User: "Get me the status of my last 3 test builds" |
| 104 | |
| 105 | Agent plan: |
| 106 | 1. call list_jobs(limit=3, sort="created_at:desc") |
| 107 | → returns [{id: "job_1", status: "passed"}, {id: "job_2", status: "failed"}, ...] |
| 108 | 2. call get_job_details(job_id="job_2") // dig into the failed one |
| 109 | → returns task breakdown, error logs |
| 110 | 3. Synthesize: "Your last 3 builds: job_1 passed, job_2 failed (2 of 15 tasks failed on Chrome/Win10), job_3 passed." |
| 111 | ``` |
| 112 | |
| 113 | --- |
| 114 | |
| 115 | ## Natural Language → API Mapping Table |
| 116 | |
| 117 | Build this mapping for any domain: |
| 118 | |
| 119 | | Natural language intent | API call | |
| 120 | |------------------------|---------| |
| 121 | | "Find hotels in Paris" | `GET /hotels/search?location=Paris` | |
| 122 | | "Book a room for 2 nights" | `POST /bookings` | |
| 123 | | "Cancel my reservation" | `POST /bookings/{id}/cancel` | |
| 124 | | "Show my past orders" | `GET /orders?user=me&sort=date:desc` | |
| 125 | | "Is the API working?" | `GET /health/ready` | |
| 126 | |
| 127 | --- |
| 128 | |
| 129 | ## API-as-Plugin (OpenAPI → GPT Plugin / Tool) |
| 130 | |
| 131 | Minimal `ai-plugin.json`: |
| 132 | ```json |
| 133 | { |
| 134 | "schema_version": "v1", |
| 135 | "name_for_human": "My API", |
| 136 | "name_for_model": "my_api", |
| 137 | "description_for |