{
  "openapi": "3.1.0",
  "info": {
    "title": "Planner API",
    "version": "1.0.0",
    "summary": "Public, read-only API for Planner (severnplanner.com), plus the HTTP endpoints of its MCP server.",
    "description": "Planner (Severn Planner) is a free school planner for students. This API serves public information only, so it needs no account and no API key:\nthe changelog of Planner updates and the final grade calculator's math. It never returns student data.\n\nA student's own study stats are only available through the read-only MCP server at https://mcp.severnplanner.com/mcp,\nafter the student turns on AI assistants in Planner and signs in with OAuth (scope `stats`). Its HTTP endpoints are described here too.\n\nErrors from /api are RFC 9457 problem details (`application/problem+json`) with a `code` and a `hint`.\nErrors from the MCP server are OAuth 2.0 style JSON (`error`, `error_description`).",
    "contact": {
      "name": "Planner",
      "email": "jeremy@severnplanner.com",
      "url": "https://www.severnplanner.com/contact"
    },
    "termsOfService": "https://www.severnplanner.com/terms"
  },
  "externalDocs": {
    "description": "Planner API docs",
    "url": "https://www.severnplanner.com/developers"
  },
  "servers": [
    {
      "url": "https://www.severnplanner.com",
      "description": "Public API"
    }
  ],
  "tags": [
    {
      "name": "Public API",
      "description": "Public, read-only endpoints on www.severnplanner.com. No authentication."
    },
    {
      "name": "MCP server",
      "description": "The read-only MCP server for a student's own AI assistant. See https://www.severnplanner.com/mcp-server"
    },
    {
      "name": "OAuth",
      "description": "MCP authorization: OAuth 2.1 with PKCE (S256) and dynamic client registration."
    }
  ],
  "paths": {
    "/api/v1": {
      "get": {
        "tags": [
          "Public API"
        ],
        "operationId": "getApiIndex",
        "summary": "List the API's endpoints",
        "security": [],
        "responses": {
          "200": {
            "description": "The API index.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ApiIndex"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/changelog": {
      "get": {
        "tags": [
          "Public API"
        ],
        "operationId": "listChangelog",
        "summary": "List Planner updates, newest first",
        "description": "Every update to Planner, as shown on https://www.severnplanner.com/changelog and in the app's What's New list.",
        "security": [],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "description": "How many updates to return.",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 200,
              "default": 20
            }
          },
          {
            "name": "since",
            "in": "query",
            "required": false,
            "description": "Only updates on or after this date (YYYY-MM-DD).",
            "schema": {
              "type": "string",
              "format": "date"
            },
            "example": "2026-11-01"
          }
        ],
        "responses": {
          "200": {
            "description": "The updates.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Changelog"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is not valid.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/final-grade": {
      "get": {
        "tags": [
          "Public API"
        ],
        "operationId": "calculateFinalGrade",
        "summary": "Work out the score needed on a final exam",
        "description": "The math of https://www.severnplanner.com/tools/final-grade-calculator: the grade so far counts for the share of the class the final leaves over. Give `goal` for the score needed on the final, `final_score` for the class grade a final score would give, or both. Letters use the General 4.0 scale (A is 93 and up, A- 90 and up, and so on, rounded to the nearest whole number). Nothing is stored.",
        "security": [],
        "parameters": [
          {
            "name": "current",
            "in": "query",
            "required": true,
            "description": "Class grade now, in percent.",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 150
            },
            "example": 86
          },
          {
            "name": "final_weight",
            "in": "query",
            "required": true,
            "description": "Share of the class grade the final is worth, in percent.",
            "schema": {
              "type": "number",
              "exclusiveMinimum": 0,
              "maximum": 100
            },
            "example": 25
          },
          {
            "name": "goal",
            "in": "query",
            "required": false,
            "description": "Class grade wanted, in percent.",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 150
            },
            "example": 88
          },
          {
            "name": "final_score",
            "in": "query",
            "required": false,
            "description": "A score on the final to try, in percent.",
            "schema": {
              "type": "number",
              "minimum": 0,
              "maximum": 150
            },
            "example": 90
          }
        ],
        "responses": {
          "200": {
            "description": "The result.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/FinalGrade"
                }
              }
            }
          },
          "400": {
            "description": "A parameter is missing or not valid.",
            "content": {
              "application/problem+json": {
                "schema": {
                  "$ref": "#/components/schemas/Problem"
                }
              }
            }
          }
        }
      }
    },
    "/api/openapi.json": {
      "get": {
        "tags": [
          "Public API"
        ],
        "operationId": "getOpenApi",
        "summary": "This OpenAPI document",
        "description": "The same document is at https://www.severnplanner.com/openapi.json.",
        "security": [],
        "responses": {
          "200": {
            "description": "The OpenAPI document.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/mcp": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "post": {
        "tags": [
          "MCP server"
        ],
        "operationId": "mcp",
        "summary": "MCP endpoint (Streamable HTTP, JSON-RPC 2.0)",
        "description": "The Model Context Protocol endpoint. Send JSON-RPC 2.0 requests: initialize, tools/list, tools/call, resources/list, resources/read, ping. Seven read-only tools return the student's Streak & Stats: get_overview, get_study_time, get_grades, get_estimate_accuracy, get_test_prep, get_plan_follow_through, get_goals. Use an MCP client rather than calling this directly. Only POST is accepted.",
        "security": [
          {
            "oauth2": [
              "stats"
            ]
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/JsonRpcRequest"
              },
              "example": {
                "jsonrpc": "2.0",
                "id": 1,
                "method": "tools/list"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "JSON-RPC response (or an array of them for a batch).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "202": {
            "description": "Accepted: the request held only notifications."
          },
          "400": {
            "description": "Body is not JSON (JSON-RPC parse error -32700).",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/JsonRpcResponse"
                }
              }
            }
          },
          "401": {
            "description": "No bearer token, or it is invalid or was revoked. The WWW-Authenticate header points to the protected resource metadata.",
            "headers": {
              "WWW-Authenticate": {
                "description": "Bearer challenge with resource_metadata (RFC 9728).",
                "schema": {
                  "type": "string"
                }
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    },
    "/mcp/server-card": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "get": {
        "tags": [
          "MCP server"
        ],
        "operationId": "getServerCard",
        "summary": "MCP Server Card",
        "description": "The server's name, URL, transport and protocol versions, for MCP clients that discover servers by domain.",
        "security": [],
        "responses": {
          "200": {
            "description": "The Server Card.",
            "content": {
              "application/mcp-server-card+json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-protected-resource": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "get": {
        "tags": [
          "OAuth"
        ],
        "operationId": "getProtectedResourceMetadata",
        "summary": "Protected resource metadata (RFC 9728)",
        "security": [],
        "responses": {
          "200": {
            "description": "The metadata, with scopes_supported.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/.well-known/oauth-authorization-server": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "get": {
        "tags": [
          "OAuth"
        ],
        "operationId": "getAuthorizationServerMetadata",
        "summary": "Authorization server metadata (RFC 8414)",
        "security": [],
        "responses": {
          "200": {
            "description": "The metadata.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          }
        }
      }
    },
    "/register": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "post": {
        "tags": [
          "OAuth"
        ],
        "operationId": "registerClient",
        "summary": "Dynamic client registration (RFC 7591)",
        "description": "Registers a public client (no secret). redirect_uris must be https, or http on localhost.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "redirect_uris"
                ],
                "properties": {
                  "redirect_uris": {
                    "type": "array",
                    "items": {
                      "type": "string",
                      "format": "uri"
                    },
                    "minItems": 1,
                    "maxItems": 10
                  },
                  "client_name": {
                    "type": "string",
                    "maxLength": 80
                  }
                }
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "The registered client.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "client_id"
                  ],
                  "properties": {
                    "client_id": {
                      "type": "string"
                    },
                    "client_id_issued_at": {
                      "type": "integer"
                    },
                    "client_name": {
                      "type": "string"
                    },
                    "redirect_uris": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "token_endpoint_auth_method": {
                      "type": "string",
                      "const": "none"
                    },
                    "grant_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "response_types": {
                      "type": "array",
                      "items": {
                        "type": "string"
                      }
                    },
                    "scope": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The client metadata is not valid.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    },
    "/authorize": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "get": {
        "tags": [
          "OAuth"
        ],
        "operationId": "authorize",
        "summary": "Authorization endpoint",
        "description": "Starts sign-in. The student is sent to Planner to sign in and allow the app, then back to redirect_uri with a code. PKCE with S256 is required.",
        "security": [],
        "parameters": [
          {
            "name": "response_type",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "const": "code"
            }
          },
          {
            "name": "client_id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "redirect_uri",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string",
              "format": "uri"
            }
          },
          {
            "name": "code_challenge",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "pattern": "^[A-Za-z0-9_-]{43,128}$"
            }
          },
          {
            "name": "code_challenge_method",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string",
              "const": "S256"
            }
          },
          {
            "name": "state",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to Planner to sign in, or back to redirect_uri with an error."
          },
          "400": {
            "description": "Unknown client or redirect_uri (an HTML page, since there is nowhere safe to redirect)."
          }
        }
      }
    },
    "/token": {
      "servers": [
        {
          "url": "https://mcp.severnplanner.com",
          "description": "Planner MCP server"
        }
      ],
      "post": {
        "tags": [
          "OAuth"
        ],
        "operationId": "token",
        "summary": "Token endpoint",
        "description": "Exchanges an authorization code (with code_verifier) or a refresh token for tokens. Access tokens last 1 hour; refresh tokens last 60 days and renew each time they are used.",
        "security": [],
        "requestBody": {
          "required": true,
          "content": {
            "application/x-www-form-urlencoded": {
              "schema": {
                "type": "object",
                "required": [
                  "grant_type"
                ],
                "properties": {
                  "grant_type": {
                    "type": "string",
                    "enum": [
                      "authorization_code",
                      "refresh_token"
                    ]
                  },
                  "code": {
                    "type": "string"
                  },
                  "code_verifier": {
                    "type": "string"
                  },
                  "redirect_uri": {
                    "type": "string"
                  },
                  "refresh_token": {
                    "type": "string"
                  },
                  "client_id": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Tokens.",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "required": [
                    "access_token",
                    "token_type"
                  ],
                  "properties": {
                    "access_token": {
                      "type": "string"
                    },
                    "token_type": {
                      "type": "string",
                      "const": "Bearer"
                    },
                    "expires_in": {
                      "type": "integer"
                    },
                    "refresh_token": {
                      "type": "string"
                    },
                    "scope": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "The grant is invalid or expired, or the grant type is not supported.",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/OAuthError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "oauth2": {
        "type": "oauth2",
        "description": "MCP authorization for the MCP server only. Public clients with PKCE (S256); register at https://mcp.severnplanner.com/register.",
        "flows": {
          "authorizationCode": {
            "authorizationUrl": "https://mcp.severnplanner.com/authorize",
            "tokenUrl": "https://mcp.severnplanner.com/token",
            "refreshUrl": "https://mcp.severnplanner.com/token",
            "scopes": {
              "stats": "Read the student's Streak & Stats summary. Read-only.",
              "offline_access": "Get a refresh token so the app stays connected."
            }
          }
        }
      }
    },
    "schemas": {
      "Problem": {
        "type": "object",
        "description": "An error, as RFC 9457 problem details with a machine-readable code and a hint on how to fix the request.",
        "required": [
          "type",
          "title",
          "status",
          "detail",
          "code"
        ],
        "properties": {
          "type": {
            "type": "string",
            "format": "uri",
            "description": "Link to the documentation for this kind of error."
          },
          "title": {
            "type": "string",
            "description": "Short summary of the kind of error."
          },
          "status": {
            "type": "integer",
            "description": "The HTTP status code."
          },
          "detail": {
            "type": "string",
            "description": "What went wrong with this request."
          },
          "instance": {
            "type": "string",
            "description": "The path that was requested."
          },
          "code": {
            "type": "string",
            "enum": [
              "not_found",
              "method_not_allowed",
              "missing_parameter",
              "invalid_parameter"
            ],
            "description": "Stable error code to branch on."
          },
          "hint": {
            "type": "string",
            "description": "How to fix the request."
          },
          "parameter": {
            "type": "string",
            "description": "For parameter errors, the parameter at fault."
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          }
        },
        "example": {
          "type": "https://www.severnplanner.com/developers#errors",
          "title": "Invalid parameter",
          "status": 400,
          "detail": "final_weight must be more than 0 and at most 100.",
          "instance": "/api/v1/final-grade",
          "code": "invalid_parameter",
          "parameter": "final_weight",
          "hint": "Give final_weight as a plain number, like 25.",
          "documentation": "https://www.severnplanner.com/developers#errors"
        }
      },
      "OAuthError": {
        "type": "object",
        "description": "OAuth 2.0 error (RFC 6749 section 5.2) or a JSON error from the MCP server.",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "string",
            "example": "invalid_grant"
          },
          "error_description": {
            "type": "string"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Grade": {
        "type": "object",
        "required": [
          "percent",
          "letter"
        ],
        "properties": {
          "percent": {
            "type": "number",
            "description": "Class grade in percent, rounded to one decimal."
          },
          "letter": {
            "type": "string",
            "description": "Letter on the General 4.0 scale."
          }
        }
      },
      "ApiIndex": {
        "type": "object",
        "required": [
          "name",
          "version",
          "endpoints"
        ],
        "properties": {
          "name": {
            "type": "string"
          },
          "version": {
            "type": "string"
          },
          "description": {
            "type": "string"
          },
          "documentation": {
            "type": "string",
            "format": "uri"
          },
          "openapi": {
            "type": "string",
            "format": "uri"
          },
          "endpoints": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "method",
                "path",
                "summary"
              ],
              "properties": {
                "method": {
                  "type": "string"
                },
                "path": {
                  "type": "string"
                },
                "summary": {
                  "type": "string"
                }
              }
            }
          },
          "mcp_server": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "Changelog": {
        "type": "object",
        "required": [
          "entries",
          "count",
          "total"
        ],
        "properties": {
          "entries": {
            "type": "array",
            "items": {
              "type": "object",
              "required": [
                "id",
                "date",
                "url",
                "items"
              ],
              "properties": {
                "id": {
                  "type": "string",
                  "example": "2026-11-12a"
                },
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "url": {
                  "type": "string",
                  "format": "uri"
                },
                "items": {
                  "type": "array",
                  "items": {
                    "type": "object",
                    "required": [
                      "title",
                      "body"
                    ],
                    "properties": {
                      "title": {
                        "type": "string"
                      },
                      "body": {
                        "type": "string"
                      }
                    }
                  }
                }
              }
            }
          },
          "count": {
            "type": "integer",
            "description": "Updates in this response."
          },
          "total": {
            "type": "integer",
            "description": "Updates that match, before limit."
          },
          "html": {
            "type": "string",
            "format": "uri"
          }
        }
      },
      "FinalGrade": {
        "type": "object",
        "required": [
          "inputs",
          "scale",
          "current",
          "with_perfect_final",
          "with_zero_final",
          "letters"
        ],
        "properties": {
          "inputs": {
            "type": "object",
            "properties": {
              "current": {
                "type": "number"
              },
              "final_weight": {
                "type": "number"
              },
              "goal": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "final_score": {
                "type": [
                  "number",
                  "null"
                ]
              }
            }
          },
          "scale": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "rounding": {
                "type": "string"
              }
            }
          },
          "current": {
            "$ref": "#/components/schemas/Grade"
          },
          "with_perfect_final": {
            "$ref": "#/components/schemas/Grade"
          },
          "with_zero_final": {
            "$ref": "#/components/schemas/Grade"
          },
          "goal": {
            "type": "object",
            "description": "Present when goal was given.",
            "required": [
              "percent",
              "status",
              "needed_on_final"
            ],
            "properties": {
              "percent": {
                "type": "number"
              },
              "status": {
                "type": "string",
                "enum": [
                  "needed",
                  "locked_in",
                  "out_of_reach"
                ],
                "description": "locked_in: reached even with 0% on the final. out_of_reach: not reached even with 100%."
              },
              "needed_on_final": {
                "type": [
                  "number",
                  "null"
                ],
                "description": "Score needed on the final in percent, rounded up to one decimal. 0 when locked in, null when out of reach."
              }
            }
          },
          "final_score": {
            "type": "object",
            "description": "Present when final_score was given.",
            "required": [
              "score",
              "class_grade",
              "change"
            ],
            "properties": {
              "score": {
                "type": "number"
              },
              "class_grade": {
                "$ref": "#/components/schemas/Grade"
              },
              "change": {
                "type": "number",
                "description": "Points up (+) or down (-) from the grade now."
              }
            }
          },
          "letters": {
            "type": "array",
            "description": "For each letter from A to C-, the lowest percent that counts as it and what the final needs for it.",
            "items": {
              "type": "object",
              "required": [
                "letter",
                "min_percent",
                "status",
                "needed_on_final"
              ],
              "properties": {
                "letter": {
                  "type": "string"
                },
                "min_percent": {
                  "type": "number"
                },
                "status": {
                  "type": "string",
                  "enum": [
                    "needed",
                    "locked_in",
                    "out_of_reach"
                  ]
                },
                "needed_on_final": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "JsonRpcRequest": {
        "type": "object",
        "required": [
          "jsonrpc",
          "method"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "method": {
            "type": "string"
          },
          "params": {
            "type": "object"
          }
        }
      },
      "JsonRpcResponse": {
        "type": "object",
        "required": [
          "jsonrpc"
        ],
        "properties": {
          "jsonrpc": {
            "type": "string",
            "const": "2.0"
          },
          "id": {
            "type": [
              "string",
              "integer",
              "null"
            ]
          },
          "result": {
            "type": "object"
          },
          "error": {
            "type": "object",
            "required": [
              "code",
              "message"
            ],
            "properties": {
              "code": {
                "type": "integer"
              },
              "message": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}
