Skip to main content
Glama
+server.ts998 B
import { json, error } from '@sveltejs/kit' import { exec } from 'child_process' import { promisify } from 'util' import { homedir } from 'os' import { join } from 'path' import type { RequestHandler } from './$types' const execAsync = promisify(exec) export const POST: RequestHandler = async ({ request }) => { const body = await request.json() let filePath: string if (body.filePath) { // Direct file path (for Read tool) filePath = body.filePath } else if (body.sessionId && body.backupFileName) { // Backup file path: ~/.claude/file-history/{sessionId}/{backupFileName} filePath = join(homedir(), '.claude', 'file-history', body.sessionId, body.backupFileName) } else { throw error(400, 'filePath or (sessionId and backupFileName) required') } try { // Open the file in VS Code using the code command await execAsync(`code "${filePath}"`) return json({ success: true }) } catch (e) { throw error(500, `Failed to open file: ${e}`) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/DrumRobot/claude-sessions-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server