Skip to main content
Glama

remove_instruments

Remove debug instrumentation from code files to clean up after debugging sessions. Specify a file path or clear all instrumented files.

Instructions

Remove debug instruments from files.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
fileNoPath to file to remove instruments from. If not specified, removes from all instrumented files.

Implementation Reference

  • Main execution logic for the remove_instruments tool. Handles removal from a specific file or all files by coordinating with Instrumenter and SessionManager.
    case 'remove_instruments': { if (!sessionManager.isActive() || !instrumenter) { return { content: [{ type: 'text', text: 'No active debug session.' }], isError: true, }; } const file = args?.file as string | undefined; if (file) { // Remove from specific file const instruments = sessionManager.getInstrumentsByFile(file); for (const instrument of instruments) { instrumenter.removeInstrument(instrument); sessionManager.removeInstrument(instrument.id); } return { content: [ { type: 'text', text: `Removed ${instruments.length} instrument(s) from ${file}`, }, ], }; } else { // Remove from all files const instruments = sessionManager.getInstruments(); for (const instrument of instruments) { instrumenter.removeInstrument(instrument); } sessionManager.clearInstruments(); return { content: [ { type: 'text', text: `Removed ${instruments.length} instrument(s) from all files`, }, ], }; } }
  • Input schema definition for the remove_instruments tool, defining the optional 'file' parameter.
    { name: 'remove_instruments', description: 'Remove debug instruments from files.', inputSchema: { type: 'object', properties: { file: { type: 'string', description: 'Path to file to remove instruments from. If not specified, removes from all instrumented files.', }, }, }, },
  • Instrumenter.removeInstrument: Core logic to remove the instrumentation code block from the target file using region-based regex removal.
    removeInstrument(instrument: Instrument): boolean { if (!existsSync(instrument.file)) { return false; } const content = readFileSync(instrument.file, 'utf-8'); const regionId = `${REGION_PREFIX}-${instrument.id}`; const newContent = this.removeRegion(content, regionId, instrument.language); if (newContent !== content) { writeFileSync(instrument.file, newContent); return true; } return false; }
  • SessionManager.removeInstrument: Removes instrument tracking entry from the session's internal instruments Map.
    removeInstrument(id: string): boolean { if (!this.session) { throw new Error('No active debug session'); } return this.session.instruments.delete(id); }
  • SessionManager.clearInstruments: Clears all instrument tracking from the session.
    clearInstruments(): void { if (this.session) { this.session.instruments.clear(); } }

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/iarmankhan/agentic-debugger'

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