Skip to main content
Glama

ssh_set_working_directory

Change the current working directory for an SSH connection to navigate remote file systems efficiently during operations.

Instructions

Set the current working directory for a connection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesSSH connection ID
workingDirectoryYesWorking directory path to set as current

Implementation Reference

  • Implements the core logic for the ssh_set_working_directory tool: parses input using schema, retrieves connection context, verifies directory existence via SSH command, updates currentWorkingDirectory in context, and returns success message.
    private async handleSetWorkingDirectory(args: unknown) {
      const params = SetWorkingDirectorySchema.parse(args);
      
      const context = connectionContexts.get(params.connectionId);
      if (!context) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Connection ID '${params.connectionId}' not found`
        );
      }
    
      try {
        // Verify the directory exists
        const result = await context.ssh.execCommand(`test -d "${params.workingDirectory}" && echo "exists"`);
        if (result.code !== 0) {
          throw new McpError(
            ErrorCode.InvalidParams,
            `Directory '${params.workingDirectory}' does not exist or is not accessible`
          );
        }
    
        // Set the working directory
        context.currentWorkingDirectory = params.workingDirectory;
        
        return {
          content: [
            {
              type: 'text',
              text: `Working directory set to: ${params.workingDirectory}`,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to set working directory: ${error instanceof Error ? error.message : String(error)}`
        );
      }
    }
  • Zod schema defining input parameters for ssh_set_working_directory: connectionId (string) and workingDirectory (string). Used for validation in the handler.
    const SetWorkingDirectorySchema = z.object({
      connectionId: z.string().describe('SSH connection ID'),
      workingDirectory: z.string().describe('Working directory path to set as current')
    });
  • src/index.ts:420-431 (registration)
    Tool metadata registration in ListToolsRequestSchema handler, specifying name, description, and inputSchema advertised to clients.
    {
      name: 'ssh_set_working_directory',
      description: 'Set the current working directory for a connection',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'SSH connection ID' },
          workingDirectory: { type: 'string', description: 'Working directory path to set as current' }
        },
        required: ['connectionId', 'workingDirectory']
      },
    },
  • src/index.ts:513-514 (registration)
    Dispatch registration in CallToolRequestSchema switch statement, routing calls to the handler function.
    case 'ssh_set_working_directory':
      return await this.handleSetWorkingDirectory(args);
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool sets a working directory but lacks critical details: whether this requires specific permissions, if the change is persistent across sessions, what happens on invalid paths, or if it affects all users on the connection. For a mutation tool with zero annotation coverage, this is a significant gap in transparency.

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 a single, efficient sentence that directly states the tool's function without unnecessary words. It's front-loaded with the core action and resource, making it easy to parse quickly. Every part of the sentence earns its place by conveying essential information.

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

Completeness2/5

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

Given the tool's mutation nature, lack of annotations, and absence of an output schema, the description is incomplete. It doesn't explain what happens after setting the directory (e.g., success confirmation, error handling, or effects on other operations). For a tool that modifies state in an SSH context, more context about behavioral outcomes is needed to be fully helpful.

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%, with both parameters ('connectionId' and 'workingDirectory') clearly documented in the schema. The description adds no additional semantic context beyond implying these parameters are used to set the directory. Since the schema does the heavy lifting, the baseline score of 3 is appropriate, as the description doesn't compensate with extra details like path format examples or connection state requirements.

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

Purpose4/5

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

The description clearly states the action ('Set') and target ('current working directory for a connection'), making the purpose immediately understandable. It distinguishes from siblings like 'ssh_get_working_directory' by specifying the set operation rather than retrieval. However, it doesn't explicitly mention the SSH context beyond the tool name, which slightly limits specificity.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It doesn't mention prerequisites like needing an established SSH connection, nor does it differentiate from similar operations in sibling tools. For example, it doesn't clarify if this affects subsequent 'ssh_execute' commands or how it relates to 'ssh_start_interactive_shell'.

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

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/mahathirmuh/mcp-ssh-server'

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