start_debug_session
Start a debug session to receive logs from instrumented code via a local HTTP server. Configure the port to monitor and analyze code execution in real-time.
Instructions
Start a debug session. This starts a local HTTP server to receive logs from instrumented code.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | No | Port number for the debug server (default: 9876) |
Implementation Reference
- src/index.ts:134-147 (handler)The main handler for the 'start_debug_session' tool. It extracts the port from arguments (default 9876), starts the debug session using SessionManager, initializes the Instrumenter, and returns a success message with session details.case 'start_debug_session': { const port = (args?.port as number) || 9876; const session = await sessionManager.startSession(port); instrumenter = new Instrumenter(port); return { content: [ { type: 'text', text: `Debug session started!\n\nSession ID: ${session.id}\nServer: http://localhost:${port}\nLog file: ${session.logFile}\n\nYou can now add instruments to capture variable values.`, }, ], }; }
- src/index.ts:34-47 (schema)The schema definition for the 'start_debug_session' tool, including name, description, and input schema for the optional 'port' parameter.{ name: 'start_debug_session', description: 'Start a debug session. This starts a local HTTP server to receive logs from instrumented code.', inputSchema: { type: 'object', properties: { port: { type: 'number', description: 'Port number for the debug server (default: 9876)', default: 9876, }, }, }, },
- src/session.ts:16-41 (helper)The SessionManager.startSession method, which implements the core logic for starting the debug session: clears log file, starts DebugLogServer, and initializes the session object.async startSession(port: number = 9876): Promise<DebugSession> { if (this.session) { throw new Error('Debug session already active. Stop it first.'); } const logFile = resolve(this.workingDirectory, 'debug.log'); // Clear any existing log file if (existsSync(logFile)) { unlinkSync(logFile); } writeFileSync(logFile, ''); this.server = new DebugLogServer(port, logFile); await this.server.start(); this.session = { id: randomUUID(), port, startedAt: Date.now(), logFile, instruments: new Map() }; return this.session; }
- src/instrumenter.ts:9-11 (helper)The Instrumenter constructor, initialized with the port in the tool handler.constructor(port: number) { this.port = port; }