Skip to main content
Glama

set_filesystem_default

Set an absolute path as the default for resolving relative paths in filesystem operations during the session. Cleared on server restart.

Instructions

Sets a default absolute path for the current session. Relative paths used in other filesystem tools (like readFile) will be resolved against this default. The default is cleared on server restart.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYesThe absolute path to set as the default for resolving relative paths during this session.

Implementation Reference

  • Core handler function that executes the tool logic: sets the default filesystem path in serverState and returns confirmation.
    export const setFilesystemDefaultLogic = async (input: SetFilesystemDefaultInput, context: RequestContext): Promise<SetFilesystemDefaultOutput> => {
      const { path: newPath } = input;
    
      // The validation (absolute check, sanitization) happens within serverState.setDefaultFilesystemPath
      serverState.setDefaultFilesystemPath(newPath, context);
    
      const currentPath = serverState.getDefaultFilesystemPath();
      return {
        message: `Default filesystem path successfully set to: ${currentPath}`,
        currentDefaultPath: currentPath,
      };
    };
  • Zod schema defining the input structure for the tool: requires an absolute path string.
    export const SetFilesystemDefaultInputSchema = z.object({
      path: z.string().min(1, 'Path cannot be empty')
        .describe('The absolute path to set as the default for resolving relative paths during this session.'),
    });
  • Registers the 'set_filesystem_default' tool on the MCP server instance, providing name, description, input schema, and an async handler that calls the core logic.
    export const registerSetFilesystemDefaultTool = async (server: McpServer): Promise<void> => {
      const registrationContext = requestContextService.createRequestContext({ operation: 'RegisterSetFilesystemDefaultTool' });
      logger.info("Attempting to register 'set_filesystem_default' tool", registrationContext);
    
      await ErrorHandler.tryCatch(
        async () => {
          server.tool(
            'set_filesystem_default', // Tool name
            'Sets a default absolute path for the current session. Relative paths used in other filesystem tools (like readFile) will be resolved against this default. The default is cleared on server restart.', // Description
            SetFilesystemDefaultInputSchema.shape, // Pass the schema shape
            async (params, extra) => {
              const typedParams = params as SetFilesystemDefaultInput;
              const callContext = requestContextService.createRequestContext({ operation: 'SetFilesystemDefaultToolExecution', parentId: registrationContext.requestId });
              logger.info(`Executing 'set_filesystem_default' tool with path: ${typedParams.path}`, callContext);
    
              // ErrorHandler will catch McpErrors thrown by the logic (e.g., non-absolute path)
              const result = await ErrorHandler.tryCatch(
                () => setFilesystemDefaultLogic(typedParams, callContext),
                {
                  operation: 'setFilesystemDefaultLogic',
                  context: callContext,
                  input: typedParams, // Input is automatically sanitized by ErrorHandler
                  errorCode: BaseErrorCode.INTERNAL_ERROR // Default error if unexpected failure
                }
              );
    
              logger.info(`Successfully executed 'set_filesystem_default'. Current default: ${result.currentDefaultPath}`, callContext);
    
              // Format the successful response
              return {
                content: [{ type: 'text', text: result.message }],
              };
            }
          );
          logger.info("'set_filesystem_default' tool registered successfully", registrationContext);
        },
        {
          operation: 'registerSetFilesystemDefaultTool',
          context: registrationContext,
          errorCode: BaseErrorCode.CONFIGURATION_ERROR,
          critical: true
        }
      );
    };
  • Top-level call to registerSetFilesystemDefaultTool as part of all filesystem tools during server initialization.
      registerReadFileTool(server),
      registerSetFilesystemDefaultTool(server),
      registerWriteFileTool(server),
      registerUpdateFileTool(server),
      registerListFilesTool(server),
      registerDeleteFileTool(server),
      registerDeleteDirectoryTool(server),
      registerCreateDirectoryTool(server),
      registerMovePathTool(server),
      registerCopyPathTool(server)
    ];
  • Index file exporting the registration function for convenient import.
    export { registerSetFilesystemDefaultTool } from './registration.js';
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden and does well by disclosing key behavioral traits: it sets a session-scoped default, affects other tools, and clears on server restart. However, it lacks details on permissions, error handling, or validation of the path.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is appropriately sized and front-loaded, with two sentences that efficiently convey purpose and behavior without wasted words, making it easy for an agent to parse quickly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's low complexity (1 parameter, no output schema, no annotations), the description is mostly complete, covering purpose, usage, and key behavior. However, it could benefit from mentioning error cases or interactions with specific sibling tools for full context.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents the 'path' parameter thoroughly. The description adds no additional meaning beyond what the schema provides, such as format examples or constraints, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Sets a default absolute path') and resource ('for the current session'), and distinguishes it from siblings by explaining its unique role in resolving relative paths for other filesystem tools like readFile.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides clear context on when to use this tool (to set a default path for resolving relative paths in other filesystem tools) and mentions the session scope, but does not explicitly state when not to use it or name specific alternatives among siblings.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/cyanheads/filesystem-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server