fix: cache openapi registry, make oauth optional, reset preset auto-select on new preset

This commit is contained in:
Ishaan Jaffer 2026-03-10 11:08:31 -07:00
parent 691ecc685b
commit a2537d2ed2
3 changed files with 13 additions and 1 deletions

View file

@ -15,6 +15,7 @@ Endpoints here:
"""
import functools
import importlib
import json
import os
@ -1370,6 +1371,7 @@ if MCP_AVAILABLE:
"openapi_registry.json",
)
@functools.lru_cache(maxsize=1)
def _load_openapi_registry() -> Dict[str, Any]:
try:
with open(_OPENAPI_REGISTRY_PATH, "r") as f:

View file

@ -13,7 +13,7 @@ export interface OpenAPIRegistryEntry {
description: string;
icon_url: string;
spec_url: string;
oauth: {
oauth?: {
authorization_url: string;
token_url: string;
pkce: boolean;

View file

@ -152,6 +152,7 @@ const MCPToolConfiguration: React.FC<MCPToolConfigurationProps> = ({
const previousToolsRef = useRef<ToolEntry[]>([]);
const [toolSearchTerm, setToolSearchTerm] = useState("");
const hasInitializedRef = useRef(false);
const previousSuggestedToolNamesRef = useRef<string>("");
const [expandedTools, setExpandedTools] = useState<Set<string>>(new Set());
const { tools, isLoadingTools, toolsError, canFetchTools } = useTestMCPConnection({
@ -223,6 +224,15 @@ const MCPToolConfiguration: React.FC<MCPToolConfigurationProps> = ({
const previousToolNames = previousToolsRef.current.map((tool) => tool.name).sort().join(",");
const toolsListChanged = currentToolNames !== previousToolNames;
// Reset initialization when a new preset is selected (suggestedTools fingerprint changes)
const currentSuggestedNames = suggestedTools.map((t) => t.name).sort().join(",");
if (currentSuggestedNames !== previousSuggestedToolNamesRef.current) {
previousSuggestedToolNamesRef.current = currentSuggestedNames;
if (currentSuggestedNames !== "") {
hasInitializedRef.current = false;
}
}
if (tools.length > 0 && toolsListChanged) {
const availableToolNames = tools.map((tool) => tool.name);