{
  "openapi": "3.1.0",
  "info": {
    "title": "MCP Test Server",
    "version": "1.0",
    "description": "A deterministic Model Context Protocol server over Streamable HTTP: initialize, tools (with structured output and deliberate failures), resources, resource templates and prompts — plus a token-protected variant for 401 handling."
  },
  "servers": [
    {
      "url": "https://funapi.dev/api/mcp/v1"
    }
  ],
  "tags": [
    {
      "name": "server",
      "description": "JSON-RPC endpoint"
    },
    {
      "name": "auth",
      "description": "Bearer-protected variant"
    }
  ],
  "paths": {
    "/info": {
      "get": {
        "tags": [
          "server"
        ],
        "summary": "How to connect, and what this server exposes",
        "operationId": "mcp-info",
        "responses": {
          "200": {
            "description": "Server description",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string"
                    },
                    "transport": {
                      "type": "string"
                    },
                    "url": {
                      "type": "string"
                    },
                    "secureUrl": {
                      "type": "string"
                    },
                    "secureToken": {
                      "type": "string"
                    },
                    "protocolVersions": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "tools": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "resources": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "prompts": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "inspector": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "post": {
        "tags": [
          "server"
        ],
        "summary": "Streamable HTTP endpoint (JSON responses): initialize, tools, resources, prompts, ping",
        "operationId": "mcp-rpc",
        "responses": {
          "200": {
            "description": "JSON-RPC response (errors are JSON-RPC errors in a 200)",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jsonrpc": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "protocolVersion": {
                          "type": "string"
                        },
                        "capabilities": {
                          "type": "object",
                          "properties": {
                            "tools": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "resources": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                },
                                "subscribe": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "prompts": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "logging": {
                              "type": "object",
                              "properties": {}
                            }
                          }
                        },
                        "serverInfo": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "version": {
                              "type": "string"
                            }
                          }
                        },
                        "instructions": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "202": {
            "description": "Notification accepted, no body",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            }
          },
          "400": {
            "description": "Unsupported MCP-Protocol-Version or invalid JSON",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "405": {
            "description": "GET/DELETE: no server-initiated stream on this server",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": false,
            "description": "Returned by initialize; optional on later calls.",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "MCP-Protocol-Version",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "2025-06-18"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string"
                  },
                  "id": {
                    "type": "number"
                  },
                  "method": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object",
                    "properties": {
                      "protocolVersion": {
                        "type": "string"
                      },
                      "capabilities": {
                        "type": "object",
                        "properties": {}
                      },
                      "clientInfo": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "initialize",
                "params": {
                  "protocolVersion": "2025-06-18",
                  "capabilities": {},
                  "clientInfo": {
                    "name": "my-test-client",
                    "version": "1.0.0"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/secure/mcp": {
      "post": {
        "tags": [
          "auth"
        ],
        "summary": "Same server behind a Bearer token (mcp-test-token) — test 401 handling",
        "operationId": "mcp-secure",
        "responses": {
          "200": {
            "description": "JSON-RPC response",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "jsonrpc": {
                      "type": "string"
                    },
                    "id": {
                      "type": "number"
                    },
                    "result": {
                      "type": "object",
                      "properties": {
                        "protocolVersion": {
                          "type": "string"
                        },
                        "capabilities": {
                          "type": "object",
                          "properties": {
                            "tools": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "resources": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                },
                                "subscribe": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "prompts": {
                              "type": "object",
                              "properties": {
                                "listChanged": {
                                  "type": "boolean"
                                }
                              }
                            },
                            "logging": {
                              "type": "object",
                              "properties": {}
                            }
                          }
                        },
                        "serverInfo": {
                          "type": "object",
                          "properties": {
                            "name": {
                              "type": "string"
                            },
                            "title": {
                              "type": "string"
                            },
                            "version": {
                              "type": "string"
                            }
                          }
                        },
                        "instructions": {
                          "type": "string"
                        }
                      }
                    }
                  }
                }
              }
            }
          },
          "401": {
            "description": "Missing or wrong token, with WWW-Authenticate",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          },
          "429": {
            "description": "Global rate limit exceeded (300 requests a minute per IP) — wait for Retry-After",
            "headers": {
              "Retry-After": {
                "schema": {
                  "type": "integer"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                }
              }
            }
          }
        },
        "parameters": [
          {
            "name": "Authorization",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "Bearer mcp-test-token"
          },
          {
            "name": "Mcp-Session-Id",
            "in": "header",
            "required": false,
            "description": "Returned by initialize; optional on later calls.",
            "schema": {
              "type": "string"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "jsonrpc": {
                    "type": "string"
                  },
                  "id": {
                    "type": "number"
                  },
                  "method": {
                    "type": "string"
                  },
                  "params": {
                    "type": "object",
                    "properties": {
                      "protocolVersion": {
                        "type": "string"
                      },
                      "capabilities": {
                        "type": "object",
                        "properties": {}
                      },
                      "clientInfo": {
                        "type": "object",
                        "properties": {
                          "name": {
                            "type": "string"
                          },
                          "version": {
                            "type": "string"
                          }
                        }
                      }
                    }
                  }
                }
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "initialize",
                "params": {
                  "protocolVersion": "2025-06-18",
                  "capabilities": {},
                  "clientInfo": {
                    "name": "my-test-client",
                    "version": "1.0.0"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "JWT",
        "description": "Use qa-admin-token / qa-viewer-token, or a JWT from POST /auth/v1/login."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "X-API-Key",
        "description": "Cargo demo key: cargo-key-123."
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error",
          "message"
        ],
        "properties": {
          "error": {
            "type": "string"
          },
          "message": {
            "type": "string"
          },
          "requestId": {
            "type": "string"
          }
        },
        "additionalProperties": true
      }
    }
  }
}
