| 78 | MCP_TAG = "mcp" |
| 79 | |
| 80 | def get_schema( |
| 81 | self, request: Request | None = None, public: bool = False |
| 82 | ) -> dict[str, Any]: |
| 83 | oauth = OAuthConfig.from_settings() |
| 84 | schema = super().get_schema(request, public) |
| 85 | schema["paths"] = self._filter_paths(schema.get("paths", {})) |
| 86 | schema = self._update_security_for_mcp(schema, oauth) |
| 87 | schema.pop("$schema", None) |
| 88 | info = schema.pop("info").copy() |
| 89 | info["title"] = "mcp_openapi" |
| 90 | return { |
| 91 | "openapi": schema.pop("openapi"), |
| 92 | "info": info, |
| 93 | "servers": [{"url": oauth.api_url}], |
| 94 | **schema, |
| 95 | } |
| 96 | |
| 97 | def _filter_paths(self, paths: dict[str, Any]) -> dict[str, Any]: |
| 98 | """Filter paths to only include operations tagged with 'mcp'.""" |