set_working_directory
Define the active directory for context extraction, enabling targeted analysis and file management within the specified path for streamlined project 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 that resolves the directory path, validates it is a directory, sets this.workingDirectory, and returns a success 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:52-64 (registration)Tool registration in the ListToolsRequestSchema handler, 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 (registration)Dispatch/registration in the CallToolRequestSchema switch statement that routes to the handler.case 'set_working_directory': return await this.setWorkingDirectory(args.directory);