Fix bugs in MCP user-fields deep linking

- Remove unused hasAnyUserFields export from userFields.ts
- Preserve existing query params when building user-fields deep-link URL
  in UserFieldsModal so the link still routes via ?page=mcp-servers
- Only clear ?openUserFields from the URL after the target server is
  found, so the deep link can be re-applied when the list later loads

Co-authored-by: Yassin Kortam <yassin@berri.ai>
This commit is contained in:
Cursor Agent 2026-05-19 05:50:37 +00:00
parent 677809ad18
commit 2d11f40707
No known key found for this signature in database
3 changed files with 16 additions and 10 deletions

View file

@ -61,13 +61,23 @@ const UserFieldsModal: React.FC<UserFieldsModalProps> = ({
};
const serverDisplayName = server.server_name || server.alias || server.server_id;
const buildDeepLinkUrl = (): string => {
if (typeof window === "undefined") {
return `<dashboard-url>?openUserFields=${server.server_id}`;
}
const params = new URLSearchParams(window.location.search);
params.set("openUserFields", server.server_id);
return `${window.location.origin}${window.location.pathname}?${params.toString()}`;
};
const errorPreview = `Error: MCP server "${serverDisplayName}" requires user configuration before use.
${missing.length > 0 ? `Missing field${missing.length === 1 ? "" : "s"}:` : "All fields configured."}
${missing.map((f) => ` • ${f.label || f.name}${f.description ? ` — ${f.description}` : ""}`).join("\n")}
Please configure your fields at:
${typeof window !== "undefined" ? `${window.location.origin}${window.location.pathname}?openUserFields=${server.server_id}` : `<dashboard-url>?openUserFields=${server.server_id}`}
${buildDeepLinkUrl()}
Once configured, retry your request.`;

View file

@ -103,12 +103,12 @@ const MCPServers: React.FC<MCPServerProps> = ({ accessToken, userRole, userID })
const target = serversWithHealth.find((s) => s.server_id === targetId);
if (target) {
setUserFieldsServer(target);
params.delete("openUserFields");
const remaining = params.toString();
const newUrl =
window.location.pathname + (remaining ? `?${remaining}` : "") + window.location.hash;
window.history.replaceState({}, "", newUrl);
}
params.delete("openUserFields");
const remaining = params.toString();
const newUrl =
window.location.pathname + (remaining ? `?${remaining}` : "") + window.location.hash;
window.history.replaceState({}, "", newUrl);
}, [serversWithHealth]);
// Servers with one or more missing user fields for the current user (prototype)

View file

@ -79,7 +79,3 @@ export function getMissingUserFields(
values[f.name].trim() === "",
);
}
export function hasAnyUserFields(serverId: string): boolean {
return getUserFieldDefs(serverId).length > 0;
}