set_working_directory
Specify a directory path to establish the active working location for context extraction and analysis operations.
Instructions
Set the working directory for context extraction
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| directory | Yes | Path to the directory to analyze |
Implementation Reference
- server.js:839-861 (handler)The handler function for 'set_working_directory' that validates the directory path, updates the server's working directory, and returns a confirmation message.async setWorkingDirectory(directory) { try { const resolvedPath = path.resolve(directory); const stats = await fs.stat(resolvedPath); if (!stats.isDirectory()) { throw new Error('Path is not a directory'); } this.workingDirectory = resolvedPath; return { content: [ { type: 'text', text: `Working directory set to: ${this.workingDirectory}`, }, ], }; } catch (error) { throw new McpError(ErrorCode.InvalidParams, `Invalid directory: ${error.message}`); } }
- server.js:54-63 (schema)Input schema definition for the 'set_working_directory' tool, specifying a required 'directory' string parameter.inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Path to the directory to analyze', }, }, required: ['directory'], },
- server.js:52-64 (registration)Tool registration entry in the listTools response, including name, description, and input schema.name: 'set_working_directory', description: 'Set the working directory for context extraction', inputSchema: { type: 'object', properties: { directory: { type: 'string', description: 'Path to the directory to analyze', }, }, required: ['directory'], }, },
- server.js:454-455 (handler)Dispatch case in the main CallToolRequestSchema handler that invokes the setWorkingDirectory method.case 'set_working_directory': return await this.setWorkingDirectory(args.directory);