Skip to content

Commit 63295d4

Browse files
committed
Added logout working
1 parent 02795f6 commit 63295d4

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

src/extension.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,14 @@ export function activate(context: vscode.ExtensionContext) {
8484
console.dir("Logged out of PearAI:")
8585
context.secrets.delete("pearai-token")
8686
context.secrets.delete("pearai-refresh")
87+
// Clear MCP server token
88+
const provider = await ClineProvider.getInstance()
89+
if (provider) {
90+
const mcpHub = provider.getMcpHub()
91+
if (mcpHub) {
92+
await mcpHub.clearPearAiApiKey()
93+
}
94+
}
8795
}),
8896
)
8997

src/services/mcp/McpHub.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,29 @@ export class McpHub {
505505
})
506506
}
507507

508+
public async clearPearAiApiKey(): Promise<void> {
509+
try {
510+
const settingsPath = await this.getMcpSettingsFilePath()
511+
const content = await fs.readFile(settingsPath, "utf-8")
512+
const config = JSON.parse(content)
513+
514+
if (config.mcpServers?.pearai) {
515+
config.mcpServers.pearai = {
516+
...config.mcpServers.pearai,
517+
args: ["pearai-mcp", "<PEARAI_API_KEY>"],
518+
}
519+
520+
await fs.writeFile(settingsPath, JSON.stringify(config, null, 2))
521+
await this.updateServerConnections(config.mcpServers)
522+
vscode.window.showInformationMessage("PearAI API key cleared successfully")
523+
}
524+
} catch (error) {
525+
console.error("Failed to clear PearAI API key:", error)
526+
vscode.window.showErrorMessage("Failed to clear PearAI API key")
527+
throw error
528+
}
529+
}
530+
508531
public async updatePearAiApiKey(apiKey: string): Promise<void> {
509532
try {
510533
const settingsPath = await this.getMcpSettingsFilePath()

0 commit comments

Comments
 (0)