{
  "openapi": "3.1.0",
  "info": {
    "title": "SecureLend",
    "summary": "OAuth, MCP, and apex discovery for SecureLend underwriting agents.",
    "description": "SecureLend publishes cited credit and IC memos via an authenticated MCP server.\nThis specification describes **only live public surfaces**:\n- MCP at https://agents.securelend.ai/mcp (OAuth required; initialize without Authorization returns 401)\n- OAuth authorize / token / register / M2M as documented at https://docs.securelend.ai/agents/authentication.md\n- Apex discovery documents (OpenAPI, llms.txt, well-known metadata).\n\nLoans REST and webhooks are documented as coming soon and are **not** listed here.\n\n## Versioning\nCurrent version: 1.0.0. Apex discovery routes are also published under `/api/v1/`.\nSend `API-Version: 1` (echoed on responses). Breaking changes increment the URL version (`/api/v2/`).\n\n## Deprecation\nDeprecated operations remain in this spec and send `Deprecation: true` plus a `Sunset` HTTP-date (RFC 8594 / RFC 9745) before removal. No operations are deprecated in 1.0.0.\n\n## Errors\nError responses use RFC 9457 `application/problem+json` with `type`, `title`, `status`, `detail`, and `code`.\n\n## Rate limits\nDiscovery routes advertise `RateLimit` / `RateLimit-Policy` headers. A 429 includes `Retry-After` (seconds). This spec does not emit synthetic 429s.",
    "version": "1.0.0",
    "contact": {
      "name": "SecureLend",
      "email": "support@securelend.ai",
      "url": "https://securelend.ai/developers"
    },
    "license": {
      "name": "Proprietary",
      "url": "https://securelend.ai/legal/terms"
    }
  },
  "servers": [
    {
      "url": "https://securelend.ai",
      "description": "SecureLend apex — discovery documents"
    },
    {
      "url": "https://securelend.ai/api/v1",
      "description": "SecureLend apex API v1 aliases"
    },
    {
      "url": "https://agents.securelend.ai",
      "description": "SecureLend agents — OAuth and MCP (canonical)"
    }
  ],
  "tags": [
    {
      "name": "Discovery",
      "description": "Apex machine-readable documents."
    },
    {
      "name": "OAuth",
      "description": "Live authorization server on agents.securelend.ai."
    },
    {
      "name": "MCP",
      "description": "Authenticated Model Context Protocol server."
    }
  ],
  "paths": {
    "/openapi.json": {
      "get": {
        "operationId": "getOpenApiDocument",
        "tags": [
          "Discovery"
        ],
        "summary": "OpenAPI 3 document",
        "description": "Return this OpenAPI 3.1 document as JSON. Also available at /api/v1/openapi.json.",
        "security": [],
        "parameters": [
          {
            "$ref": "#/components/parameters/ApiVersionHeader"
          }
        ],
        "responses": {
          "200": {
            "description": "OpenAPI 3.1 document.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    },
    "/llms.txt": {
      "get": {
        "operationId": "getLlmsTxt",
        "tags": [
          "Discovery"
        ],
        "summary": "Agent instruction file",
        "description": "Return the SecureLend llms.txt with a when-to-use section, MCP URL, OpenAPI, docs, and trial links.",
        "security": [],
        "responses": {
          "200": {
            "description": "llms.txt as text/plain.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "text/plain": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "get": {
        "operationId": "getOauthAuthorizationServerMetadata",
        "tags": [
          "Discovery",
          "OAuth"
        ],
        "summary": "OAuth 2.0 authorization server metadata",
        "description": "RFC 8414 metadata for the live agents authorization server. Same issuer and endpoints as https://agents.securelend.ai/.well-known/oauth-authorization-server. Apex does not host a second auth server.",
        "security": [],
        "responses": {
          "200": {
            "description": "Authorization server metadata.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AuthorizationServerMetadata"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource": {
      "get": {
        "operationId": "getOauthProtectedResourceMetadata",
        "tags": [
          "Discovery",
          "OAuth"
        ],
        "summary": "OAuth protected resource metadata",
        "description": "RFC 9728 metadata for the MCP resource, including scopes_supported: openid, email, profile, and the documented MCP access scope.",
        "security": [],
        "responses": {
          "200": {
            "description": "Protected resource metadata.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ProtectedResourceMetadata"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/.well-known/mcp": {
      "get": {
        "operationId": "getMcpManifest",
        "tags": [
          "Discovery",
          "MCP"
        ],
        "summary": "MCP server manifest",
        "description": "Points agents at https://agents.securelend.ai/mcp using Streamable HTTP. Authentication is required; the harness is not opened unauthenticated.",
        "security": [],
        "responses": {
          "200": {
            "description": "MCP manifest.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpManifest"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/oauth/authorize": {
      "get": {
        "operationId": "oauthAuthorize",
        "tags": [
          "OAuth"
        ],
        "summary": "OAuth 2.0 authorization endpoint",
        "description": "Authorization-code + PKCE entry for human MCP clients (ChatGPT, Claude, browsers). Lives on agents.securelend.ai. Redirects the user to sign in and return a code.",
        "servers": [
          {
            "url": "https://agents.securelend.ai"
          }
        ],
        "security": [],
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "description": "Must be code.",
            "schema": {
              "type": "string",
              "enum": [
                "code"
              ]
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "description": "OAuth client id from dynamic registration or the ChatGPT app.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "description": "Space-delimited scopes. Live AS lists openid email profile.",
            "schema": {
              "type": "string",
              "examples": [
                "openid email profile"
              ]
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": true,
            "description": "PKCE S256 challenge.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "enum": [
                "S256"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the login UI or back to redirect_uri with a code."
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          }
        }
      }
    },
    "/oauth/token": {
      "post": {
        "operationId": "oauthToken",
        "tags": [
          "OAuth"
        ],
        "summary": "OAuth 2.0 token endpoint",
        "description": "Exchange an authorization code or client credentials for a Bearer access token. Human tokens use authorization_code + PKCE. M2M tokens use client_credentials with scope https://agents.securelend.ai/mcp.access.",
        "servers": [
          {
            "url": "https://agents.securelend.ai"
          }
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "$ref": "#/components/schemas/TokenRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Access token issued.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TokenResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/oauth/register": {
      "post": {
        "operationId": "oauthRegisterClient",
        "tags": [
          "OAuth"
        ],
        "summary": "OAuth 2.0 dynamic client registration",
        "description": "RFC 7591 registration for interactive MCP clients. Documented at agents/authentication.md.",
        "servers": [
          {
            "url": "https://agents.securelend.ai"
          }
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ClientRegistrationRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Client created.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ClientRegistrationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/oauth/m2m/register": {
      "post": {
        "operationId": "oauthRegisterM2mClient",
        "tags": [
          "OAuth"
        ],
        "summary": "Self-serve machine-to-machine client registration",
        "description": "One call creates a Cognito app client and seeds a free trial quota. No browser. Production host: agents.securelend.ai. See docs for the exact JSON body and token_request_example.",
        "servers": [
          {
            "url": "https://agents.securelend.ai"
          }
        ],
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/M2mRegistrationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "M2M client and trial quota.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/M2mRegistrationResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "operationId": "mcpJsonRpc",
        "tags": [
          "MCP"
        ],
        "summary": "MCP Streamable HTTP endpoint",
        "description": "JSON-RPC 2.0 over Streamable HTTP at https://agents.securelend.ai/mcp. Requires Authorization: Bearer. initialize without a token returns 401 — do not strip auth. Supported methods include initialize, tools/list, and tools/call (pitch_deck_precheck, professional_memo_agent, and the rest of the documented tool catalog).",
        "servers": [
          {
            "url": "https://agents.securelend.ai"
          }
        ],
        "security": [
          {
            "oauth2": [
              "https://agents.securelend.ai/mcp.access"
            ]
          },
          {
            "oauth2Human": [
              "openid",
              "email",
              "profile"
            ]
          },
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/McpJsonRpcRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC result or error envelope.",
            "headers": {
              "API-Version": {
                "$ref": "#/components/headers/ApiVersion"
              },
              "RateLimit": {
                "$ref": "#/components/headers/RateLimit"
              },
              "RateLimit-Policy": {
                "$ref": "#/components/headers/RateLimitPolicy"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/McpJsonRpcResponse"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "description": "Payment required after free quota. Use initiate_payment_setup as documented.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "500": {
            "$ref": "#/components/responses/InternalError"
          }
        }
      }
    }
  },
  "components": {
    "headers": {
      "ApiVersion": {
        "description": "SecureLend API version in use.",
        "schema": {
          "type": "string",
          "examples": [
            "1"
          ]
        }
      },
      "RateLimit": {
        "description": "RFC 9331 RateLimit header (limit, remaining, reset).",
        "schema": {
          "type": "string",
          "examples": [
            "limit=120, remaining=120, reset=60"
          ]
        }
      },
      "RateLimitPolicy": {
        "description": "Rate limit policy (requests per window).",
        "schema": {
          "type": "string",
          "examples": [
            "120;w=60"
          ]
        }
      },
      "RetryAfter": {
        "description": "Seconds to wait before retrying a 429.",
        "schema": {
          "type": "integer",
          "minimum": 1
        }
      }
    },
    "parameters": {
      "ApiVersionHeader": {
        "name": "API-Version",
        "in": "header",
        "required": false,
        "description": "Optional version pin. Current value is 1. Unrecognized versions should not be sent.",
        "schema": {
          "type": "string",
          "enum": [
            "1"
          ],
          "default": "1"
        }
      }
    },
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "Machine-to-machine client-credentials flow. Scope https://agents.securelend.ai/mcp.access is required to call MCP.",
        "flows": {
          "clientCredentials": {
            "tokenUrl": "https://agents.securelend.ai/oauth/token",
            "scopes": {
              "https://agents.securelend.ai/mcp.access": "Call SecureLend AI Agents tools over MCP (machine-to-machine and human tokens)"
            }
          }
        }
      },
      "oauth2Human": {
        "type": "oauth2",
        "description": "Authorization-code + PKCE for human MCP clients. Live authorization-server scopes_supported: openid, email, profile.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://agents.securelend.ai/oauth/authorize",
            "tokenUrl": "https://agents.securelend.ai/oauth/token",
            "scopes": {
              "openid": "OpenID Connect subject identifier",
              "email": "Email address of the authenticated user",
              "profile": "Basic profile name of the authenticated user"
            }
          }
        }
      },
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Cognito JWT from /oauth/token. Required on POST /mcp."
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "type",
          "title",
          "status"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "URI identifying the problem type (RFC 9457).",
            "examples": [
              "https://securelend.ai/problems/unauthorized"
            ]
          },
          "title": {
            "type": "string",
            "description": "Short, stable problem title."
          },
          "status": {
            "type": "integer",
            "description": "HTTP status code.",
            "examples": [
              400,
              401,
              404,
              429,
              500
            ]
          },
          "detail": {
            "type": "string",
            "description": "Human-readable explanation."
          },
          "instance": {
            "type": "string",
            "format": "uri"
          },
          "code": {
            "type": "string",
            "description": "Machine-readable error code.",
            "enum": [
              "INVALID_INPUT",
              "UNAUTHORIZED",
              "FORBIDDEN",
              "NOT_FOUND",
              "RATE_LIMITED",
              "INTERNAL_ERROR"
            ]
          }
        }
      },
      "AuthorizationServerMetadata": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "issuer",
          "authorization_endpoint",
          "token_endpoint",
          "scopes_supported"
        ],
        "properties": {
          "issuer": {
            "type": "string",
            "format": "uri",
            "const": "https://agents.securelend.ai"
          },
          "authorization_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "token_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "registration_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "m2m_registration_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "token_endpoint_auth_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "openid",
                "email",
                "profile"
              ]
            }
          },
          "response_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "grant_types_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "code_challenge_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ProtectedResourceMetadata": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "resource",
          "authorization_servers",
          "scopes_supported"
        ],
        "properties": {
          "resource": {
            "type": "string",
            "format": "uri",
            "const": "https://agents.securelend.ai/mcp"
          },
          "authorization_servers": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "bearer_methods_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "scopes_supported": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "openid",
                "email",
                "profile",
                "https://agents.securelend.ai/mcp.access"
              ]
            }
          },
          "resource_documentation": {
            "type": "string",
            "format": "uri"
          },
          "resource_signing_alg_values_supported": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "McpManifest": {
        "type": "object",
        "additionalProperties": false,
        "required": [
          "name",
          "url",
          "transport"
        ],
        "properties": {
          "name": {
            "type": "string",
            "const": "SecureLend"
          },
          "description": {
            "type": "string"
          },
          "url": {
            "type": "string",
            "format": "uri",
            "const": "https://agents.securelend.ai/mcp"
          },
          "transport": {
            "type": "string",
            "const": "streamable-http"
          },
          "protocol": {
            "type": "string"
          },
          "authentication": {
            "type": "object",
            "additionalProperties": true
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          },
          "server_card": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "TokenRequest": {
        "type": "object",
        "required": [
          "grant_type"
        ],
        "properties": {
          "grant_type": {
            "type": "string",
            "enum": [
              "authorization_code",
              "refresh_token",
              "client_credentials"
            ]
          },
          "code": {
            "type": "string"
          },
          "redirect_uri": {
            "type": "string",
            "format": "uri"
          },
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string"
          },
          "code_verifier": {
            "type": "string"
          },
          "refresh_token": {
            "type": "string"
          },
          "scope": {
            "type": "string",
            "description": "For M2M, https://agents.securelend.ai/mcp.access"
          }
        }
      },
      "TokenResponse": {
        "type": "object",
        "required": [
          "access_token",
          "token_type",
          "expires_in"
        ],
        "properties": {
          "access_token": {
            "type": "string"
          },
          "token_type": {
            "type": "string",
            "enum": [
              "Bearer"
            ]
          },
          "expires_in": {
            "type": "integer",
            "examples": [
              3600
            ]
          },
          "refresh_token": {
            "type": "string"
          },
          "scope": {
            "type": "string"
          }
        }
      },
      "ClientRegistrationRequest": {
        "type": "object",
        "properties": {
          "client_name": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "response_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint_auth_method": {
            "type": "string"
          }
        }
      },
      "ClientRegistrationResponse": {
        "type": "object",
        "required": [
          "client_id"
        ],
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "redirect_uris": {
            "type": "array",
            "items": {
              "type": "string",
              "format": "uri"
            }
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "M2mRegistrationRequest": {
        "type": "object",
        "required": [
          "client_name"
        ],
        "properties": {
          "client_name": {
            "type": "string",
            "description": "Display name for the agent or pipeline.",
            "examples": [
              "My Agent"
            ]
          }
        }
      },
      "M2mRegistrationResponse": {
        "type": "object",
        "required": [
          "client_id",
          "client_secret",
          "token_endpoint",
          "mcp_endpoint",
          "scope"
        ],
        "properties": {
          "client_id": {
            "type": "string"
          },
          "client_secret": {
            "type": "string"
          },
          "client_name": {
            "type": "string"
          },
          "grant_types": {
            "type": "array",
            "items": {
              "type": "string"
            }
          },
          "token_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "mcp_endpoint": {
            "type": "string",
            "format": "uri"
          },
          "scope": {
            "type": "string",
            "const": "https://agents.securelend.ai/mcp.access"
          },
          "token_request_example": {
            "type": "string"
          },
          "free_quota": {
            "type": "object",
            "additionalProperties": {
              "type": "integer"
            }
          },
          "pricing": {
            "type": "object",
            "additionalProperties": {
              "type": "string"
            }
          },
          "note": {
            "type": "string"
          }
        }
      },
      "McpJsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              }
            ]
          },
          "method": {
            "type": "string",
            "description": "MCP JSON-RPC method.",
            "enum": [
              "initialize",
              "notifications/initialized",
              "tools/list",
              "tools/call",
              "ping"
            ]
          },
          "params": {
            "$ref": "#/components/schemas/McpJsonRpcParams"
          }
        }
      },
      "McpJsonRpcParams": {
        "type": "object",
        "description": "Method-specific params. tools/call requires name and arguments.",
        "properties": {
          "name": {
            "type": "string",
            "description": "MCP tool name for tools/call.",
            "examples": [
              "create_deal_workspace",
              "pitch_deck_precheck",
              "professional_memo_agent",
              "list_rubric_templates"
            ]
          },
          "arguments": {
            "type": "object",
            "additionalProperties": true,
            "description": "Tool arguments as documented at /agents/tools.md."
          },
          "protocolVersion": {
            "type": "string"
          },
          "capabilities": {
            "type": "object",
            "additionalProperties": true
          },
          "clientInfo": {
            "type": "object",
            "additionalProperties": true
          }
        }
      },
      "McpJsonRpcResponse": {
        "type": "object",
        "required": [
          "jsonrpc"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "oneOf": [
              {
                "type": "integer"
              },
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ]
          },
          "result": {
            "type": "object",
            "additionalProperties": true
          },
          "error": {
            "$ref": "#/components/schemas/JsonRpcError"
          }
        }
      },
      "JsonRpcError": {
        "type": "object",
        "required": [
          "code",
          "message"
        ],
        "properties": {
          "code": {
            "type": "integer"
          },
          "message": {
            "type": "string"
          },
          "data": {}
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request (RFC 9457).",
        "headers": {
          "API-Version": {
            "$ref": "#/components/headers/ApiVersion"
          },
          "RateLimit": {
            "$ref": "#/components/headers/RateLimit"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          },
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing or invalid Bearer token. MCP initialize without Authorization is 401.",
        "headers": {
          "API-Version": {
            "$ref": "#/components/headers/ApiVersion"
          },
          "RateLimit": {
            "$ref": "#/components/headers/RateLimit"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          },
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "Rate limited. Honor Retry-After (seconds) and RateLimit headers.",
        "headers": {
          "API-Version": {
            "$ref": "#/components/headers/ApiVersion"
          },
          "RateLimit": {
            "$ref": "#/components/headers/RateLimit"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      },
      "InternalError": {
        "description": "Unexpected server error.",
        "headers": {
          "API-Version": {
            "$ref": "#/components/headers/ApiVersion"
          },
          "RateLimit": {
            "$ref": "#/components/headers/RateLimit"
          },
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/problem+json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          },
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Problem"
            }
          }
        }
      }
    }
  }
}
