Skip to content

Commit 8fa741f

Browse files
committed
add logout
1 parent a2bd71d commit 8fa741f

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

src/mcp/server.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { runStartScan } from '../commands/scans/start-scan.js';
1313
import { runReviewHeadless } from '../reviewHeadless.js';
1414
import * as scm from '../scm/index.js';
1515
import { isAlreadyLoggedIn, runLoginFlow } from '../utils/loginFlow.js';
16-
import { getConfigValue } from '../utils/config.js';
16+
import { getConfigValue, setConfigValue } from '../utils/config.js';
1717

1818
const require = createRequire(import.meta.url);
1919
const pkg = require('../../package.json');
@@ -409,6 +409,24 @@ export async function startMcpServer() {
409409
}
410410
);
411411

412+
server.registerTool(
413+
'codeant_logout',
414+
{
415+
title: 'Sign out of CodeAnt AI',
416+
description: 'Clears the saved API token from ~/.codeant/config.json and unsets CODEANT_API_TOKEN on the running MCP process. Returns { wasLoggedIn: false } immediately if no token was configured.',
417+
inputSchema: {},
418+
annotations: { ...WRITE_NON_DESTRUCTIVE, idempotentHint: true },
419+
},
420+
async () => {
421+
try {
422+
const wasLoggedIn = !!(process.env.CODEANT_API_TOKEN?.trim() || getConfigValue('apiKeyV2'));
423+
setConfigValue('apiKeyV2', null);
424+
delete process.env.CODEANT_API_TOKEN;
425+
return ok({ wasLoggedIn, status: wasLoggedIn ? 'logged_out' : 'not_logged_in' });
426+
} catch (err) { return fail(err); }
427+
}
428+
);
429+
412430
// ─── Write-side tools (gated behind CODEANT_READ_ONLY=0) ─────────────────
413431
if (!readOnly) {
414432
server.registerTool(

0 commit comments

Comments
 (0)