reset
Restore a session's filesystem and shell state to their initial values, enabling a clean start without creating a new session.
Instructions
Reset a session's filesystem and shell state (cwd, env vars) to their initial values. Useful to start fresh without creating a new session.
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:77-104 (registration)The MCP server registers the 'reset' tool with input schema (session_id optional string) and a handler that retrieves the Bash session and calls bash.reset().
server.registerTool( 'reset', { description: "Reset a session's filesystem and shell state (cwd, env vars) to their initial values. Useful to start fresh without creating a new session.", 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-mcp/src/index.ts:82-88 (schema)Input schema for the reset tool: optional session_id string with default 'default'.
inputSchema: { session_id: z .string() .optional() .default('default') .describe("The session to reset. Defaults to 'default'."), }, - packages/bash/src/core/bash.ts:68-71 (handler)The Bash class reset() method delegates to both filesystem.reset() and stateManager.reset() to restore initial state.
reset() { this.filesystem.reset(); this.stateManager.reset(); } - Resets the session's shell state: cwd back to '/workspace', env cleared, lastExitCode set to 0.
public reset() { this.state.cwd = '/workspace'; this.state.env = {}; this.state.lastExitCode = 0; } - Resets the session's filesystem by deleting everything and re-initializing with default directories and files.
reset() { fs.rmSync(this.workspace, { recursive: true, force: true }); this.init(); }