{
  "openapi": "3.1.1",
  "info": {
    "title": "Prompt-to-Tool Router API",
    "version": "1.0.0",
    "summary": "Describe your problem in plain words and get the right tools and order to use them.",
    "description": "Every endpoint performs the same calculation as the human page and returns inputs, result, units, assumptions, sources, warnings and computedAt. MCP endpoint: /mcp."
  },
  "servers": [
    {
      "url": "https://prompttotoolrouter.usefulweb.site"
    }
  ],
  "paths": {
    "/api/v1/calculate": {
      "post": {
        "operationId": "calculate",
        "summary": "Describe your problem in plain words and get the right tools and order to use them.",
        "description": "Takes a natural-language request (English or German) and ranks the usefulweb.site tools and workflows that can solve it, using transparent keyword matching (TF-IDF with synonyms), and proposes a sequence of tool calls.\n\nMethodology:\n- The request is lower-cased, split into words, stop words (EN/DE) removed, lightly stemmed and expanded with a published synonym table.\n- Each tool is indexed by name (weight 3), keywords (2.5), id (2) and tagline (1.5); score = Σ weight × ln(1 + N/df) over matched terms, +4 per exact keyword phrase.\n- If a workflow scores at least 60% of the best tool score, its steps become the plan; otherwise the top tools are planned in score order.",
        "tags": [
          "internet"
        ],
        "x-mcp-tool": "prompt_to_tool_router",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/PromptToToolRouterInput"
              },
              "examples": {
                "example1": {
                  "summary": "Moving into a new apartment",
                  "value": {
                    "request": "I'm moving into a new apartment. Can you help me plan everything and avoid unnecessary expenses? Will my sofa fit through the door?"
                  }
                },
                "example2": {
                  "summary": "Suspicious SMS",
                  "value": {
                    "request": "I got an SMS saying my parcel is held and I must pay a customs fee via a link. Is this a scam?"
                  }
                },
                "example3": {
                  "summary": "Kündigung",
                  "value": {
                    "request": "Ich möchte mein Fitnessstudio-Abo kündigen und verstehen welche Fristen gelten"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Calculation result envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PromptToToolRouterResult"
                }
              }
            }
          },
          "400": {
            "description": "Malformed JSON body.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "422": {
            "description": "Invalid input (see errors[]).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded (see Retry-After).",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/tool": {
      "get": {
        "operationId": "getToolDefinition",
        "summary": "Inputs, output schema and examples for this tool",
        "responses": {
          "200": {
            "description": "Tool definition.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "RFC 9457 problem details. 422 responses include per-field `errors`.",
        "required": [
          "type",
          "title",
          "status",
          "detail"
        ],
        "properties": {
          "type": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "status": {
            "type": "integer"
          },
          "detail": {
            "type": "string"
          },
          "code": {
            "type": "string"
          },
          "errors": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "field",
                "message"
              ],
              "properties": {
                "field": {
                  "type": "string"
                },
                "message": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "PromptToToolRouterInput": {
        "type": "object",
        "additionalProperties": false,
        "properties": {
          "request": {
            "title": "What do you want to do?",
            "type": "string",
            "maxLength": 4000
          },
          "maxResults": {
            "title": "Max tools",
            "type": "integer",
            "minimum": 1,
            "maximum": 15,
            "default": 5
          }
        },
        "required": [
          "request"
        ]
      },
      "PromptToToolRouterResult": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "schemaVersion",
          "tool",
          "computedAt",
          "inputs",
          "summary",
          "result",
          "units",
          "assumptions",
          "sources",
          "warnings",
          "presentation",
          "links"
        ],
        "properties": {
          "schemaVersion": {
            "type": "string",
            "const": "1.0"
          },
          "tool": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "id",
              "name",
              "version"
            ],
            "properties": {
              "id": {
                "type": "string"
              },
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            }
          },
          "computedAt": {
            "type": "string",
            "format": "date-time"
          },
          "inputs": {
            "type": "object",
            "description": "Normalised inputs actually used, including applied defaults."
          },
          "summary": {
            "type": "string"
          },
          "result": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "queryTerms",
              "tools",
              "workflows",
              "plan"
            ],
            "properties": {
              "queryTerms": {
                "type": "array",
                "items": {
                  "type": "string"
                }
              },
              "tools": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "name",
                    "score",
                    "matchedTerms",
                    "matchedPhrases",
                    "url"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number"
                    },
                    "matchedTerms": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "matchedPhrases": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "url": {
                      "type": "string"
                    }
                  }
                }
              },
              "workflows": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "id",
                    "name",
                    "score",
                    "steps"
                  ],
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "name": {
                      "type": "string"
                    },
                    "score": {
                      "type": "number"
                    },
                    "steps": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    }
                  }
                }
              },
              "plan": {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": false,
                  "required": [
                    "step",
                    "toolId",
                    "reason"
                  ],
                  "properties": {
                    "step": {
                      "type": "integer"
                    },
                    "toolId": {
                      "type": "string"
                    },
                    "reason": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "units": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "assumptions": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "sources": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": false,
              "required": [
                "title"
              ],
              "properties": {
                "title": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "publisher": {
                  "type": "string"
                },
                "retrievedAt": {
                  "type": "string"
                },
                "note": {
                  "type": "string"
                }
              }
            }
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "presentation": {
            "type": "array",
            "items": {
              "type": "object"
            },
            "description": "Display blocks used by the human page (same data)."
          },
          "links": {
            "type": "object",
            "additionalProperties": false,
            "required": [
              "human",
              "api",
              "openapi",
              "methodology"
            ],
            "properties": {
              "human": {
                "type": "string",
                "format": "uri"
              },
              "api": {
                "type": "string",
                "format": "uri"
              },
              "openapi": {
                "type": "string",
                "format": "uri"
              },
              "methodology": {
                "type": "string",
                "format": "uri"
              }
            }
          }
        }
      }
    }
  }
}