Skip to main content
Glama
widjis
by widjis

ssh_get_working_directory

Retrieve the current working directory path for an active SSH connection to navigate remote file systems efficiently.

Instructions

Get the current working directory for a connection

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
connectionIdYesSSH connection ID

Implementation Reference

  • The handler function that executes the ssh_get_working_directory tool. It parses input using the schema, retrieves the connection context, fetches the current working directory either from cache or by running 'pwd' remotely, caches it, and returns the result.
    private async handleGetWorkingDirectory(args: unknown) {
      const params = GetWorkingDirectorySchema.parse(args);
      
      const context = connectionContexts.get(params.connectionId);
      if (!context) {
        throw new McpError(
          ErrorCode.InvalidParams,
          `Connection ID '${params.connectionId}' not found`
        );
      }
    
      try {
        let currentDir = context.currentWorkingDirectory;
        
        if (!currentDir) {
          // Get current directory from remote system
          const result = await context.ssh.execCommand('pwd');
          if (result.code === 0) {
            currentDir = result.stdout.trim();
            context.currentWorkingDirectory = currentDir;
          } else {
            throw new McpError(
              ErrorCode.InternalError,
              `Failed to get current directory: ${result.stderr}`
            );
          }
        }
        
        return {
          content: [
            {
              type: 'text',
              text: `Current working directory: ${currentDir}`,
            },
          ],
        };
      } catch (error) {
        if (error instanceof McpError) {
          throw error;
        }
        throw new McpError(
          ErrorCode.InternalError,
          `Failed to get working directory: ${error instanceof Error ? error.message : String(error)}`
        );
      }
  • Zod schema defining the input parameters for the ssh_get_working_directory tool: requires a connectionId string.
    const GetWorkingDirectorySchema = z.object({
      connectionId: z.string().describe('SSH connection ID')
    });
  • src/index.ts:432-441 (registration)
    Registration of the ssh_get_working_directory tool in the ListTools response, including its name, description, and input schema definition.
    {
      name: 'ssh_get_working_directory',
      description: 'Get the current working directory for a connection',
      inputSchema: {
        type: 'object',
        properties: {
          connectionId: { type: 'string', description: 'SSH connection ID' }
        },
        required: ['connectionId']
      },
  • src/index.ts:517-518 (registration)
    Dispatch case in the CallToolRequest handler that routes calls to ssh_get_working_directory to its handler function.
    case 'ssh_docker_deploy':
      return await this.handleDockerDeploy(args);
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. While 'Get' implies a read-only operation, it doesn't specify whether this requires active connection status, what happens if the connection is invalid, or what format the directory path returns. For a tool with zero annotation coverage, this leaves significant behavioral gaps.

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 communicates the core purpose without any wasted words. It's appropriately sized for a simple tool and gets straight to the point with clear subject-verb-object structure.

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

Completeness3/5

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

For a simple read operation with one well-documented parameter and no output schema, the description is minimally adequate. However, it doesn't address connection state requirements or return format, which would be helpful given the lack of annotations. The description meets basic requirements but could provide more context about the tool's behavior and output.

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 the single parameter 'connectionId' clearly documented in the schema. The description doesn't add any additional parameter context beyond what the schema already provides, so the baseline score of 3 is appropriate when the schema does the heavy lifting.

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 verb 'Get' and the resource 'current working directory for a connection', making the purpose immediately understandable. It doesn't explicitly distinguish from sibling tools like 'ssh_set_working_directory', but the 'Get' vs 'Set' distinction is implied through contrasting verbs.

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 clarify relationships with sibling tools such as 'ssh_set_working_directory' or 'ssh_execute' which might affect or depend on the working directory.

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

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