setWorkspace
Set the active workspace directory to define the context for file and terminal operations.
Instructions
Set workspace
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| workspacePath | Yes |
Implementation Reference
- src/mcp/server.js:148-155 (handler)The handler logic for the setWorkspace tool. It checks if the provided workspacePath exists on disk, then updates the workspaceRoot variable and allowedDirectories[0] to the new path.
case 'setWorkspace': if (args.workspacePath && fs.existsSync(args.workspacePath)) { workspaceRoot = args.workspacePath; allowedDirectories[0] = workspaceRoot; logger.info(`Workspace root set to: ${workspaceRoot}`); data = { success: true, message: `Workspace set to ${workspaceRoot}` }; } else { data = { success:false, message:`Invalid or non-existent workspace path: ${args.workspacePath}` }; } break; - src/mcp/server.js:66-66 (schema)The tool registration schema for setWorkspace, defining its inputSchema with a required workspacePath string parameter.
{ name:'setWorkspace', description:'Set workspace', inputSchema:{ type:'object', properties:{ workspacePath:{ type:'string' } }, required:['workspacePath'] } }, - src/mcp/server.js:66-66 (registration)The tool is registered as part of the tools/list handler's tools array in src/mcp/server.js.
{ name:'setWorkspace', description:'Set workspace', inputSchema:{ type:'object', properties:{ workspacePath:{ type:'string' } }, required:['workspacePath'] } }, - scripts/run-mcp-scenario.js:86-87 (helper)A test/usage example of setWorkspace in the MCP scenario runner script.
console.log('[MCP] setWorkspace'); console.log(unwrapCall(await req('tools/call', { name: 'setWorkspace', arguments: { workspacePath: WORKSPACE } }))); - Usage of setWorkspace in the SWE-bench integration test script.
workspace_result = await acf_client.call_tool("setWorkspace", { "workspacePath": f"/tmp/swebench_test/{instance_id}" })