@civic/hub-bridge
Version:
Stdio <-> HTTP/SSE MCP bridge with Civic auth handling
54 lines • 1.9 kB
JavaScript
import { logger } from '../utils/logger.js';
import { CLIAuthProviderSingleton } from "../auth/cli-auth-provider-singleton.js";
import { ConfigManager } from "../lib/ConfigManager.js";
/**
* Tool definition for logout tool
*/
export const logoutTool = {
name: 'logout',
description: 'Logs out from Civic by clearing locally stored tokens',
inputSchema: {
type: 'object',
properties: {}
}
};
/**
* Handler for the logout tool
* Clears all locally stored tokens and returns a success/error message
*/
export const handleLogout = async () => {
logger.info(`[Tool: ${logoutTool.name}] Processing logout request`);
try {
// Get the auth provider and clear tokens
const authProvider = CLIAuthProviderSingleton.getInstance();
// Clear the stored tokens by calling clearTokens
await authProvider.clearTokens();
// Also clear the current profile selection
await ConfigManager.getInstance().clearCurrentProfile();
logger.info(`[Tool: ${logoutTool.name}] Successfully cleared local tokens and profile selection`);
// Return success in the format expected by tools/call
return {
content: [
{
type: "text",
text: "Successfully logged out from Civic. All local authentication tokens and profile selection have been cleared."
}
],
isError: false
};
}
catch (error) {
logger.error(`[Tool: ${logoutTool.name}] Error clearing tokens:`, error);
// Return error in the format expected by tools/call
return {
content: [
{
type: "text",
text: `Error logging out: ${error}`
}
],
isError: true
};
}
};
//# sourceMappingURL=logout.js.map