{
  "openapi": "3.1.0",
  "info": {
    "title": "Fonara Search MCP",
    "version": "0.1.0",
    "summary": "One query, three independent search backends (Brave, Exa, Tavily), merged with cross-provider agreement and provenance.",
    "description": "Fonara runs one query across three independent search backends, merges the results, and returns per-result cross-engine agreement and provenance — plus a private measurement receipt for every keyed run. Four tools: search, extract, similar, status. Tools are invoked as JSON-RPC 2.0 tools/call messages on POST /mcp; POST /v1/{key}/mcp is the same endpoint for clients that cannot set headers; GET /r/{run_id} reads a run receipt. Each tool has a typed contract in x-mcp-tools; the transport operations are under paths. The response and receipt schemas are generated from the zod definitions in src/types.ts and src/receipt.ts by scripts/gen-openapi.ts — the search response has no by-engine block (schema v1.3), and receipts carry measurement only, never result content.",
    "license": {
      "name": "MIT",
      "url": "https://searchmcp.fonaralabs.dev/LICENSE"
    }
  },
  "servers": [
    {
      "url": "https://searchmcp.fonaralabs.dev",
      "description": "Hosted deployment — one Fonara key, three backends behind it. Self-hosting is npx-installable over stdio with your own backend keys (BYOK); response payloads are identical."
    }
  ],
  "x-mcp-tools": {
    "search": {
      "operationId": "search",
      "summary": "One query, every enabled backend in parallel, merged with agreement and provenance.",
      "description": "Per-backend timeout 8 s — a backend that misses the deadline is reported as timed_out, never silently dropped. Merged order: best rank across engines, then agreement_count, then mean rank, publisher recency, URL. agreement_count is out of the engines that actually answered. One search consumes one credit from your tier; a cache hit and a failure consume nothing. provider_cost_usd reports upstream provider spend for router audit — not your bill.",
      "inputSchema": {
        "$ref": "#/components/schemas/SearchParams"
      },
      "outputSchema": {
        "$ref": "#/components/schemas/SearchResponse"
      }
    },
    "extract": {
      "operationId": "extract",
      "summary": "One URL to pruned markdown or plain text; separate call, never implied by search.",
      "description": "Pipeline: 7-day cache → firecrawl → exa contents. Boilerplate is pruned before metering and before returning. Failure is free ({ ok: false, reason }). Draws from the extract allowance; a cache hit and a failure consume nothing.",
      "inputSchema": {
        "$ref": "#/components/schemas/ExtractParams"
      },
      "outputSchema": {
        "$ref": "#/components/schemas/ExtractOutcome"
      }
    },
    "similar": {
      "operationId": "similar",
      "summary": "Pages like the seed URL — Exa findSimilar, single-backend by nature and labelled as such.",
      "description": "agreements is null (not zeroed) and every row is agreement_count 1 naming exa. Text snippets ride the same request (up to 300 characters); failures consume nothing. Draws from the extract allowance; a failure consumes nothing.",
      "inputSchema": {
        "$ref": "#/components/schemas/SimilarParams"
      },
      "outputSchema": {
        "$ref": "#/components/schemas/SearchResponse"
      }
    },
    "status": {
      "operationId": "status",
      "summary": "The backend registry told straight — every backend, enabled or not, with the reason.",
      "description": "Also returns schema_version and server_version. p50_ms and last_error are null: the runtime is stateless and keeps no per-instance metrics. Consumes nothing — never metered, never gated.",
      "inputSchema": {
        "$ref": "#/components/schemas/StatusParams"
      },
      "outputSchema": {
        "$ref": "#/components/schemas/StatusResponse"
      }
    }
  },
  "paths": {
    "/mcp": {
      "post": {
        "operationId": "callMcp",
        "summary": "Send one JSON-RPC 2.0 message over MCP streamable HTTP.",
        "description": "MCP streamable HTTP, stateless, POST-only. initialize and tools/list answer with no credential; tools/call search and status answer with no credential; extract/similar return 429 with reason identity unless one is present. Hosted responses and self-hosted (BYOK) responses are byte-identical payloads — only the auth path differs. search and similar responses are cached 15 minutes; a cache hit returns the original run_id with cache_status \"hit\".",
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              },
              "examples": {
                "initialize": {
                  "summary": "Handshake — no credential needed",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 0,
                    "method": "initialize",
                    "params": {
                      "protocolVersion": "2025-06-18",
                      "capabilities": {},
                      "clientInfo": {
                        "name": "example-client",
                        "version": "0.0.0"
                      }
                    }
                  }
                },
                "tools-list": {
                  "summary": "Inspect the four tools before you have a key — no credential needed",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 1,
                    "method": "tools/list"
                  }
                },
                "tools-call-search": {
                  "summary": "search — requires a credential",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 2,
                    "method": "tools/call",
                    "params": {
                      "name": "search",
                      "arguments": {
                        "query": "example query",
                        "count": 10,
                        "locale": "en"
                      }
                    }
                  }
                },
                "tools-call-extract": {
                  "summary": "extract — requires a credential",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 3,
                    "method": "tools/call",
                    "params": {
                      "name": "extract",
                      "arguments": {
                        "url": "https://example.com/page",
                        "format": "markdown"
                      }
                    }
                  }
                },
                "tools-call-similar": {
                  "summary": "similar — requires a credential",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 4,
                    "method": "tools/call",
                    "params": {
                      "name": "similar",
                      "arguments": {
                        "url": "https://example.com/page",
                        "count": 10
                      }
                    }
                  }
                },
                "tools-call-status": {
                  "summary": "status — requires a credential",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 5,
                    "method": "tools/call",
                    "params": {
                      "name": "status",
                      "arguments": {}
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC response. For tools/call the result is the tool payload typed in x-mcp-tools (search example below; extract → ExtractOutcome, similar → SearchResponse with agreements null, status → StatusResponse).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                },
                "examples": {
                  "tools-call-search-result": {
                    "summary": "search result (schema-shaped placeholder content)",
                    "value": {
                      "jsonrpc": "2.0",
                      "id": 2,
                      "result": {
                        "content": [
                          {
                            "type": "text",
                            "text": "<stringified SearchResponse — see x-mcp-tools.search>"
                          }
                        ]
                      }
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Accepted — the request contained only notifications; there is no response body."
          },
          "400": {
            "description": "Invalid JSON or an invalid JSON-RPC envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "tools/call without a credential (keyless mode covers initialize and tools/list only), or an invalid key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "Bearer"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "404": {
            "description": "Unknown path. A /v1/* near-miss (wrong case, trailing slash, missing /mcp) is 404 in every mode.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "405": {
            "description": "The transport is POST-only; any other method is rejected.",
            "headers": {
              "Allow": {
                "description": "Allowed methods.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "POST"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MethodNotAllowedError"
                }
              }
            }
          },
          "429": {
            "description": "A rate or quota limit was hit — never a silent drop.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until the caller may retry.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/{key}/mcp": {
      "post": {
        "operationId": "callMcpKeyInPath",
        "summary": "The MCP endpoint for clients that cannot set headers — the key rides the path.",
        "description": "MCP streamable HTTP, stateless, POST-only. initialize and tools/list answer with no credential; tools/call search and status answer with no credential; extract/similar return 429 with reason identity unless one is present. Hosted responses and self-hosted (BYOK) responses are byte-identical payloads — only the auth path differs. search and similar responses are cached 15 minutes; a cache hit returns the original run_id with cache_status \"hit\". The path key and a header key must agree when both are present. Treat these URLs as credentials: the key is in the path, so do not log or share request URLs.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "key",
            "in": "path",
            "required": true,
            "description": "A Fonara API key. Same validation, same tiers, same payloads as the bearer header.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              },
              "examples": {
                "tools-call-search": {
                  "summary": "search via the key-in-path route",
                  "value": {
                    "jsonrpc": "2.0",
                    "id": 2,
                    "method": "tools/call",
                    "params": {
                      "name": "search",
                      "arguments": {
                        "query": "example query",
                        "count": 10
                      }
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The JSON-RPC response. For tools/call the result is the tool payload typed in x-mcp-tools — identical to the bearer-header route.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid JSON or an invalid JSON-RPC envelope.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/BadRequestError"
                }
              }
            }
          },
          "401": {
            "description": "Unknown or revoked key.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "Bearer"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "404": {
            "description": "Anything in the versioned namespace that is not exactly /v1/<key>/mcp.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "405": {
            "description": "The transport is POST-only; any other method is rejected.",
            "headers": {
              "Allow": {
                "description": "Allowed methods.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "POST"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MethodNotAllowedError"
                }
              }
            }
          },
          "429": {
            "description": "A rate or quota limit was hit — never a silent drop.",
            "headers": {
              "Retry-After": {
                "description": "Seconds until the caller may retry.",
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/RateLimitError"
                }
              }
            }
          }
        }
      }
    },
    "/r/{run_id}": {
      "get": {
        "operationId": "readReceipt",
        "summary": "Read one run's measurement receipt — private to the credential that ran it.",
        "description": "The receipt is a statement about the call (engines, latencies, counts, agreement arithmetic, usage) — never result content, never the query. It is written once and served verbatim forever; on the free tier it is readable for 7 days from created_at, on paid tiers permanently. An unknown run_id and someone else's run_id are indistinguishable: both 404. Paid tiers add divergence trend and drift alerts over time — measurement only.",
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "run_id",
            "in": "path",
            "required": true,
            "description": "The run whose receipt to read — the id from the response, also embedded in snapshot_url.",
            "schema": {
              "type": "string",
              "examples": [
                "run_01JZEXAMPL000000000000000"
              ]
            }
          }
        ],
        "responses": {
          "200": {
            "description": "The stored receipt bytes, verbatim. Byte identity is the contract: the receipt is evidence.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Receipt"
                }
              }
            }
          },
          "401": {
            "description": "No Authorization: Bearer header, or a malformed one.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "Bearer"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UnauthorizedError"
                }
              }
            }
          },
          "404": {
            "description": "Not found — no such run, a corrupt receipt, or a receipt that belongs to another credential. Missing and not-yours are deliberately indistinguishable.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/NotFoundError"
                }
              }
            }
          },
          "405": {
            "description": "Receipts are read-only; any method other than GET is rejected.",
            "headers": {
              "Allow": {
                "description": "Allowed methods.",
                "schema": {
                  "type": "string",
                  "examples": [
                    "GET"
                  ]
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/MethodNotAllowedError"
                }
              }
            }
          },
          "410": {
            "description": "A free-tier receipt past its 7-day retention window. The upgrade pointer says where retention is permanent — never a bare 404 for an expired receipt.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ReceiptExpiredError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "One Fonara key — one balance, one bill, three backends behind it. The same key works in the Authorization header and in the /v1/{key}/mcp path. tools/list and initialize are keyless."
      }
    },
    "schemas": {
      "JsonRpcRequest": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "const": "2.0",
            "description": "JSON-RPC version — always \"2.0\"."
          },
          "id": {
            "description": "Caller-supplied request id. Notifications (no response expected) omit it.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "method": {
            "type": "string",
            "description": "'initialize', 'notifications/initialized', 'tools/list', or 'tools/call'. tools/list answers without a credential; tools/call search and status work without a credential; extract/similar return 429 identity without one."
          },
          "params": {
            "type": "object",
            "description": "Method parameters. For tools/call: { name, arguments }."
          }
        },
        "required": [
          "jsonrpc",
          "method"
        ],
        "additionalProperties": true
      },
      "JsonRpcError": {
        "type": "object",
        "properties": {
          "code": {
            "type": "integer",
            "description": "JSON-RPC error code (e.g. -32700 parse, -32600 invalid request)."
          },
          "message": {
            "type": "string"
          },
          "data": {
            "description": "Optional structured detail."
          }
        },
        "required": [
          "code",
          "message"
        ],
        "additionalProperties": false
      },
      "JsonRpcResponse": {
        "type": "object",
        "properties": {
          "jsonrpc": {
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ]
          },
          "result": {
            "description": "The method result. For tools/call the tool result is wrapped in the MCP content envelope: { content: [{ type: 'text', text: <stringified tool payload> }], isError?: boolean }. The payload itself is the typed schema linked from x-mcp-tools.",
            "oneOf": [
              {
                "$ref": "#/components/schemas/SearchResponse"
              },
              {
                "$ref": "#/components/schemas/ExtractOutcome"
              },
              {
                "$ref": "#/components/schemas/StatusResponse"
              },
              {
                "$ref": "#/components/schemas/InitializeResult"
              },
              {
                "$ref": "#/components/schemas/ToolsListResult"
              },
              {
                "type": "object"
              }
            ]
          },
          "error": {
            "$ref": "#/components/schemas/JsonRpcError"
          }
        },
        "required": [
          "jsonrpc",
          "id"
        ],
        "additionalProperties": true
      },
      "SearchParams": {
        "type": "object",
        "description": "search — one query fanned out to every enabled backend in parallel.",
        "properties": {
          "query": {
            "type": "string",
            "description": "Required. Trimmed; longer than 512 characters is truncated with a warning[], never rejected."
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 10,
            "description": "Results requested per backend; clamped into 1..20 with a warning. Merged depth: top 10 per backend."
          },
          "locale": {
            "type": "string",
            "default": "en",
            "description": "Locale hint; defaults to \"en\"."
          },
          "sort": {
            "type": "string",
            "enum": [
              "default",
              "agreement"
            ],
            "default": "default",
            "description": "'default' orders the merged list by best rank across engines (agreement is a tiebreak); 'agreement' re-orders by agreement_count, then best rank."
          }
        },
        "required": [
          "query"
        ],
        "additionalProperties": false
      },
      "ExtractParams": {
        "type": "object",
        "description": "extract — one URL to pruned page content. A separate call; never implied by search.",
        "properties": {
          "url": {
            "type": "string",
            "description": "Required. Absolute page URL. Empty url is an error with no charge."
          },
          "format": {
            "type": "string",
            "enum": [
              "markdown",
              "text"
            ],
            "default": "markdown",
            "description": "'markdown' returns the pruned extractor output as-is; 'text' renders it as plain text."
          }
        },
        "required": [
          "url"
        ],
        "additionalProperties": false
      },
      "SimilarParams": {
        "type": "object",
        "description": "similar — pages like the seed URL (Exa findSimilar; single-backend by nature).",
        "properties": {
          "url": {
            "type": "string",
            "description": "Required. The seed page; the tool answers with pages like this one."
          },
          "count": {
            "type": "integer",
            "minimum": 1,
            "maximum": 20,
            "default": 10,
            "description": "Neighbors to ask for; clamped into 1..20 with a warning. No row cap is applied to the answer."
          }
        },
        "required": [
          "url"
        ],
        "additionalProperties": false
      },
      "StatusParams": {
        "type": "object",
        "description": "status — no parameters. Every backend, enabled or not, with the reason.",
        "properties": {},
        "additionalProperties": false
      },
      "SearchResponse": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string",
            "description": "ULID, monotonic."
          },
          "snapshot_url": {
            "description": "Permanent, private to the calling credential, immutable — resolves to that run's measurement receipt. Null on keyless runs: the answer without the record.",
            "type": [
              "string",
              "null"
            ]
          },
          "schema_version": {
            "type": "string"
          },
          "query": {
            "type": "string"
          },
          "locale": {
            "type": "string"
          },
          "engines": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/EngineReport"
            },
            "description": "Per-backend report — engines[].status exposes which engines actually answered."
          },
          "backends_succeeded": {
            "type": "number",
            "description": "Number of engines that answered ok for this run."
          },
          "agreements": {
            "anyOf": [
              {
                "$ref": "#/components/schemas/Agreements"
              },
              {
                "type": "null"
              }
            ],
            "description": "Counts over the merged result set. Null for `similar` queries — no cross-engine agreement block."
          },
          "results": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/MergedResult"
            },
            "description": "Merged, ordered."
          },
          "usage": {
            "type": "object",
            "properties": {
              "search_calls": {
                "type": "number",
                "description": "Backend search calls made for this run."
              },
              "credits": {
                "type": "number",
                "description": "Credits consumed by this call: one per search; extract and similar draw from the extract allowance. A cache hit returns the original run’s credits and consumes nothing new; a failure and status consume nothing. Billing is in credits, not dollars."
              },
              "provider_cost_usd": {
                "type": "number",
                "description": "Upstream provider cost of this call in USD — what the search engines charged, absorbed by Fonara on hosted. Zero on a cache hit and on failure. Not the amount charged to you: billing is in credits."
              }
            },
            "required": [
              "search_calls",
              "credits",
              "provider_cost_usd"
            ],
            "additionalProperties": false,
            "description": "Metered usage — meter what bills; never meter agreement/provenance/merge/schema."
          },
          "warnings": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Pruned params, fallbacks, schema notes."
          },
          "cache_status": {
            "description": "'hit' when the run was served from the 15-min cache with the original run_id; 'miss' on a fresh run; absent when unknown.",
            "type": "string",
            "enum": [
              "hit",
              "miss"
            ]
          }
        },
        "required": [
          "run_id",
          "snapshot_url",
          "schema_version",
          "query",
          "locale",
          "engines",
          "backends_succeeded",
          "agreements",
          "results",
          "usage",
          "warnings"
        ],
        "additionalProperties": false,
        "title": "SearchResponse"
      },
      "EngineReport": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "ok",
              "error",
              "timed_out",
              "disabled"
            ]
          },
          "ms": {
            "type": "number"
          },
          "returned": {
            "type": "number"
          },
          "error": {
            "type": "string"
          }
        },
        "required": [
          "name",
          "status",
          "ms",
          "returned"
        ],
        "additionalProperties": false,
        "title": "EngineReport"
      },
      "Agreements": {
        "type": "object",
        "properties": {
          "returned_by_3": {
            "type": "number"
          },
          "returned_by_2": {
            "type": "number"
          },
          "returned_by_1": {
            "type": "number"
          },
          "total_distinct": {
            "type": "number"
          },
          "agreement_rate": {
            "type": "number",
            "description": "(3of3 + 2of3) / total_distinct."
          }
        },
        "required": [
          "returned_by_3",
          "returned_by_2",
          "returned_by_1",
          "total_distinct",
          "agreement_rate"
        ],
        "additionalProperties": false,
        "title": "Agreements"
      },
      "MergedResult": {
        "type": "object",
        "properties": {
          "position": {
            "type": "number"
          },
          "url": {
            "type": "string"
          },
          "title": {
            "type": "string"
          },
          "snippet": {
            "description": "Null when no snippet text exists — never a fabricated empty string; the engine decides, the schema does not.",
            "type": [
              "string",
              "null"
            ]
          },
          "agreement_count": {
            "type": "number",
            "description": "Of the engines that actually answered, not out of three — a 2-of-2 is not the same evidence as a 2-of-3."
          },
          "engines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "rank": {
                  "type": "number"
                }
              },
              "required": [
                "name",
                "rank"
              ],
              "additionalProperties": false
            },
            "description": "Provenance, per result — every merged row names its sources; a merged row that cannot name its source is a bug."
          },
          "provenance": {
            "$ref": "#/components/schemas/Provenance"
          }
        },
        "required": [
          "position",
          "url",
          "title",
          "snippet",
          "agreement_count",
          "engines",
          "provenance"
        ],
        "additionalProperties": false,
        "title": "MergedResult"
      },
      "Provenance": {
        "type": "object",
        "properties": {
          "host_tier": {
            "type": "string",
            "enum": [
              "first_party",
              "registry",
              "aggregator",
              "blog",
              "forum",
              "unknown"
            ],
            "description": "first_party | registry | aggregator | blog | forum | unknown."
          },
          "is_own_site": {
            "description": "Only when a caller supplies a domain; null when undetermined — never a fabricated guess.",
            "type": [
              "string",
              "null"
            ]
          },
          "published_date": {
            "description": "Null when undetermined — never a fabricated guess.",
            "type": [
              "string",
              "null"
            ]
          },
          "recency_days": {
            "description": "Age of the document in days; null when undetermined — never a fabricated guess.",
            "type": [
              "number",
              "null"
            ]
          }
        },
        "required": [
          "host_tier",
          "is_own_site",
          "published_date",
          "recency_days"
        ],
        "additionalProperties": false,
        "title": "Provenance"
      },
      "Receipt": {
        "type": "object",
        "properties": {
          "run_id": {
            "type": "string"
          },
          "schema_version": {
            "type": "string"
          },
          "created_at": {
            "type": "string",
            "format": "date-time",
            "pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:Z))$"
          },
          "engines": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "ok",
                    "error",
                    "timed_out",
                    "disabled"
                  ]
                },
                "ms": {
                  "type": "number"
                },
                "returned": {
                  "type": "number"
                }
              },
              "required": [
                "name",
                "status",
                "ms",
                "returned"
              ],
              "additionalProperties": false
            }
          },
          "backends_succeeded": {
            "type": "number"
          },
          "agreements": {
            "anyOf": [
              {
                "type": "object",
                "properties": {
                  "returned_by_3": {
                    "type": "number"
                  },
                  "returned_by_2": {
                    "type": "number"
                  },
                  "returned_by_1": {
                    "type": "number"
                  },
                  "total_distinct": {
                    "type": "number"
                  },
                  "agreement_rate": {
                    "type": "number"
                  }
                },
                "required": [
                  "returned_by_3",
                  "returned_by_2",
                  "returned_by_1",
                  "total_distinct",
                  "agreement_rate"
                ],
                "additionalProperties": false
              },
              {
                "type": "null"
              }
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "search_calls": {
                "type": "number"
              },
              "credits": {
                "type": "number",
                "description": "Credits consumed by this call: one per search; extract and similar draw from the extract allowance. A cache hit returns the original run’s credits and consumes nothing new; a failure and status consume nothing. Billing is in credits, not dollars."
              },
              "provider_cost_usd": {
                "type": "number",
                "description": "Upstream provider cost of this call in USD — what the search engines charged, absorbed by Fonara on hosted. Zero on a cache hit and on failure. Not the amount charged to you: billing is in credits."
              }
            },
            "required": [
              "search_calls",
              "credits",
              "provider_cost_usd"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "run_id",
          "schema_version",
          "created_at",
          "engines",
          "backends_succeeded",
          "agreements",
          "usage"
        ],
        "additionalProperties": false,
        "title": "Receipt"
      },
      "ExtractOutcome": {
        "type": "object",
        "description": "One per-URL extraction outcome. Failure is free: ok false, reason set, provider_cost_usd 0.",
        "properties": {
          "ok": {
            "type": "boolean"
          },
          "url": {
            "type": "string"
          },
          "format": {
            "type": "string",
            "enum": [
              "markdown",
              "text"
            ]
          },
          "content": {
            "type": "string",
            "description": "Pruned content; empty string on failure."
          },
          "metadata": {
            "type": "object",
            "additionalProperties": true,
            "description": "Page metadata from the extractor."
          },
          "extractor_tried": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Extractor names in the order tried: cache → firecrawl → exa. [] on a cache hit."
          },
          "provider_cost_usd": {
            "type": "number",
            "description": "Upstream provider cost of this call in USD — what the search engines charged, absorbed by Fonara on hosted. Zero on a cache hit and on failure. Not the amount charged to you: billing is in credits."
          },
          "cache_status": {
            "type": "string",
            "enum": [
              "hit",
              "miss"
            ]
          },
          "reason": {
            "type": "string",
            "description": "Present only when ok is false: every extractor failure, joined."
          }
        },
        "required": [
          "ok",
          "url",
          "format",
          "content",
          "metadata",
          "extractor_tried",
          "provider_cost_usd",
          "cache_status"
        ],
        "additionalProperties": false
      },
      "BackendStatus": {
        "type": "object",
        "description": "One backend as status() reports it — the registry told straight, never pretending.",
        "properties": {
          "name": {
            "type": "string",
            "description": "brave | exa | tavily."
          },
          "enabled": {
            "type": "boolean",
            "description": "Whether the backend is wired in for this deployment."
          },
          "reason": {
            "type": "string",
            "description": "'ok', '<ENVKEY> not set', or 'disabled by ENABLE_TAVILY flag'."
          },
          "version": {
            "type": "string"
          },
          "bestFor": {
            "type": "string",
            "description": "The backend type of query it is strongest at — its own published line."
          },
          "costPerCallUsd": {
            "type": "number"
          },
          "p50_ms": {
            "type": [
              "integer",
              "null"
            ],
            "description": "Null: the runtime is stateless and keeps no per-instance metrics."
          },
          "last_error": {
            "type": [
              "string",
              "null"
            ],
            "description": "Null for the same reason — the hosted logs own history."
          }
        },
        "required": [
          "name",
          "enabled",
          "reason",
          "version",
          "bestFor",
          "costPerCallUsd",
          "p50_ms",
          "last_error"
        ],
        "additionalProperties": false
      },
      "StatusResponse": {
        "type": "object",
        "description": "The status tool result: the launch trio, its honest state, plus version stamps.",
        "properties": {
          "schema_version": {
            "type": "string"
          },
          "server_version": {
            "type": "string"
          },
          "backends": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/BackendStatus"
            }
          }
        },
        "required": [
          "schema_version",
          "server_version",
          "backends"
        ],
        "additionalProperties": false
      },
      "InitializeResult": {
        "type": "object",
        "description": "MCP initialize result. Answered without a credential.",
        "properties": {
          "protocolVersion": {
            "type": "string"
          },
          "capabilities": {
            "type": "object",
            "description": "This server advertises tools only."
          },
          "serverInfo": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "version": {
                "type": "string"
              }
            },
            "required": [
              "name",
              "version"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "protocolVersion",
          "capabilities",
          "serverInfo"
        ],
        "additionalProperties": false
      },
      "ToolsListResult": {
        "type": "object",
        "description": "MCP tools/list result. Answered without a credential — inspect before you have a key.",
        "properties": {
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "description": "search | extract | similar | status."
                },
                "description": {
                  "type": "string"
                },
                "inputSchema": {
                  "type": "object",
                  "description": "JSON Schema for the tool arguments."
                }
              },
              "required": [
                "name",
                "description",
                "inputSchema"
              ],
              "additionalProperties": false
            }
          }
        },
        "required": [
          "tools"
        ],
        "additionalProperties": false
      },
      "BadRequestError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "e.g. \"invalid JSON-RPC envelope\"."
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "UnauthorizedError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "missing or invalid API key"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "NotFoundError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "not found"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "MethodNotAllowedError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "method not allowed"
          }
        },
        "required": [
          "error"
        ],
        "additionalProperties": false
      },
      "ReceiptExpiredError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "receipt expired"
          },
          "upgrade": {
            "type": "string",
            "description": "Where an expired receipt points its owner. https://fonaralabs.dev/searchmcp/pricing"
          }
        },
        "required": [
          "error",
          "upgrade"
        ],
        "additionalProperties": false
      },
      "RateLimitError": {
        "type": "object",
        "properties": {
          "error": {
            "type": "string",
            "description": "rate limit exceeded — never a silent drop."
          },
          "retry_after": {
            "type": "integer",
            "description": "Seconds until the caller may retry."
          },
          "upgrade": {
            "type": "string",
            "description": "The priced destination for this denial. https://fonaralabs.dev/searchmcp/pricing"
          }
        },
        "required": [
          "error",
          "retry_after",
          "upgrade"
        ],
        "additionalProperties": false
      }
    }
  },
  "tags": [
    {
      "name": "mcp",
      "description": "The JSON-RPC-over-HTTP MCP endpoint (stateless, POST-only)."
    },
    {
      "name": "tools",
      "description": "The four tool contracts, typed in x-mcp-tools."
    },
    {
      "name": "receipts",
      "description": "Private measurement receipts for individual runs."
    }
  ]
}
