reset
Restore the sandboxed filesystem, environment variables, and current working directory to their initial values for a specified session.
Instructions
Reset the sandboxed filesystem and shell state (cwd, env vars) for a session back to their initial values.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | No | The session to reset. Defaults to 'default'. | default |
Implementation Reference
- packages/bash-mcp/src/index.ts:80-93 (handler)The MCP tool handler for 'reset'. Calls bash.reset() and returns a JSON response with ok: true.
async ({ session_id }) => { const bash = getSession(session_id ?? 'default'); bash.reset(); return { content: [ { type: 'text', text: JSON.stringify({ ok: true, session_id: session_id ?? 'default' }), }, ], }; }, - packages/bash-mcp/src/index.ts:69-78 (schema)The schema/registration metadata for the 'reset' tool, describing its input (optional session_id).
{ description: 'Reset the sandboxed filesystem and shell state (cwd, env vars) for a session back to their initial values.', inputSchema: { session_id: z .string() .optional() .default('default') .describe("The session to reset. Defaults to 'default'."), }, - packages/bash-mcp/src/index.ts:67-94 (registration)Registration of the 'reset' tool via server.registerTool().
server.registerTool( 'reset', { description: 'Reset the sandboxed filesystem and shell state (cwd, env vars) for a session back to their initial values.', inputSchema: { session_id: z .string() .optional() .default('default') .describe("The session to reset. Defaults to 'default'."), }, }, async ({ session_id }) => { const bash = getSession(session_id ?? 'default'); bash.reset(); return { content: [ { type: 'text', text: JSON.stringify({ ok: true, session_id: session_id ?? 'default' }), }, ], }; }, ); - packages/bash/src/core/bash.ts:68-71 (helper)Bash class reset() method - delegates to both filesystem.reset() and stateManager.reset().
reset() { this.filesystem.reset(); this.stateManager.reset(); } - Filesystem.reset() - wipes the sandbox directory and re-initializes it (deletes all files, recreates directory structure and default files).
reset() { fs.rmSync(this.workspace, { recursive: true, force: true }); this.init(); } - StateManager.reset() - resets cwd to '/workspace', clears env, and sets lastExitCode to 0.
public reset() { this.state.cwd = '/workspace'; this.state.env = {}; this.state.lastExitCode = 0; }