🔧 refactor: Remove unused server reinitialization logic from MCPPanel

- Removed the `handleReinitializeServer` function.
- Removed the `ServerConfigWithVars` interface.
This commit is contained in:
Dustin Healy 2025-07-21 08:17:19 -07:00
parent ba8b661dba
commit 7f35aacebb

View file

@ -20,13 +20,6 @@ import {
type ConfigFieldDetail, type ConfigFieldDetail,
} from '~/components/ui/MCP'; } from '~/components/ui/MCP';
interface ServerConfigWithVars {
serverName: string;
config: {
customUserVars: Record<string, { title: string; description: string }>;
};
}
export default function MCPPanel() { export default function MCPPanel() {
const localize = useLocalize(); const localize = useLocalize();
const { showToast } = useToastContext(); const { showToast } = useToastContext();
@ -116,87 +109,6 @@ export default function MCPPanel() {
setSelectedServerNameForEditing(null); setSelectedServerNameForEditing(null);
}; };
const handleReinitializeServer = useCallback(
async (serverName: string) => {
try {
const response = await reinitializeMCPMutation.mutateAsync(serverName);
// Check if OAuth is required
if (response.oauthRequired) {
if (response.authURL) {
// Show OAuth URL to user
showToast({
message: `OAuth required for ${serverName}. Please visit the authorization URL.`,
status: 'info',
});
// Open OAuth URL in new window/tab
window.open(response.authURL, '_blank', 'noopener,noreferrer');
// Show a more detailed message with the URL
setTimeout(() => {
showToast({
message: `OAuth URL opened for ${serverName}. Complete authentication and try reinitializing again.`,
status: 'info',
});
}, 1000);
} else {
showToast({
message: `OAuth authentication required for ${serverName}. Please configure OAuth credentials.`,
status: 'warning',
});
}
} else if (response.oauthCompleted) {
showToast({
message:
response.message ||
`MCP server '${serverName}' reinitialized successfully after OAuth`,
status: 'success',
});
} else {
showToast({
message: response.message || `MCP server '${serverName}' reinitialized successfully`,
status: 'success',
});
}
} catch (error) {
console.error('Error reinitializing MCP server:', error);
// Check if the error response contains OAuth information
if ((error as any)?.response?.data?.oauthRequired) {
const errorData = (error as any).response.data;
if (errorData.authURL) {
showToast({
message: `OAuth required for ${serverName}. Please visit the authorization URL.`,
status: 'info',
});
// Open OAuth URL in new window/tab
window.open(errorData.authURL, '_blank', 'noopener,noreferrer');
setTimeout(() => {
showToast({
message: `OAuth URL opened for ${serverName}. Complete authentication and try reinitializing again.`,
status: 'info',
});
}, 1000);
} else {
showToast({
message: errorData.message || `OAuth authentication required for ${serverName}`,
status: 'warning',
});
}
} else {
showToast({
message: 'Failed to reinitialize MCP server',
status: 'error',
});
}
}
},
[showToast, reinitializeMCPMutation],
);
// Create save and revoke handlers with latest state // Create save and revoke handlers with latest state
const handleSave = useCallback( const handleSave = useCallback(
(updatedValues: Record<string, string>) => { (updatedValues: Record<string, string>) => {