@civic/nexus-bridge
Version:
Stdio <-> HTTP/SSE MCP bridge with Civic auth handling
62 lines • 1.89 kB
JavaScript
/**
* logout.ts
*
* Tool for logging out from Civic by clearing locally stored tokens.
* This tool is handled locally by the nexus bridge and doesn't
* forward the request to the remote server.
*/
import { setTokens } from '../tokenStore.js';
import { logger } from '../utils/logger.js';
// Create a tool-specific logger
const toolLogger = logger;
/**
* Tool definition for bridge/logout tool
*/
export const logoutTool = {
name: 'logout',
description: 'Logs out from Civic by clearing locally stored tokens',
inputSchema: {
type: 'object',
properties: {}
}
};
/**
* Handler for the bridge/logout tool
* Clears all locally stored tokens and returns a success/error message
*/
export async function handleLogout() {
toolLogger.info(`[Tool: ${logoutTool.name}] Processing logout request`);
try {
// Clear the stored tokens
await setTokens({
id_token: undefined,
access_token: undefined,
refresh_token: undefined
});
toolLogger.info(`[Tool: ${logoutTool.name}] Successfully cleared local tokens`);
// Return success in the format expected by tools/call
return {
content: [
{
type: "text",
text: "Successfully logged out from Civic. All local authentication tokens have been cleared."
}
],
isError: false
};
}
catch (error) {
toolLogger.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