Skip to main content
Glama
YawLabs

SSH MCP Server

by YawLabs

ssh_write_file

Write content to a remote file via SFTP, creating or overwriting the file securely.

Instructions

Write content to a file on a remote host via SFTP. Creates or overwrites the file.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
hostYesSSH hostname or IP address
portNoSSH port (default: 22)
usernameNoSSH username (default: current user)
privateKeyPathNoPath to SSH private key
passwordNoSSH password. STRONGLY prefer key-based auth (privateKeyPath or ssh-agent). Passwords pass through MCP protocol frames as plaintext and may be logged by the transport or host process.
pathYesAbsolute path to the remote file
contentYesFile content to write

Implementation Reference

  • src/tools.ts:74-88 (registration)
    Registration of the 'ssh_write_file' tool on the MCP server. Uses server.tool() with Zod schema for path and content parameters.
    server.tool(
      "ssh_write_file",
      "Write content to a file on a remote host via SFTP. Creates or overwrites the file.",
      {
        ...connectionParams,
        path: z.string().describe("Absolute path to the remote file"),
        content: z.string().describe("File content to write"),
      },
      async ({ path, content, ...conn }) => {
        return connectionPool.withConnection(conn, async (client) => {
          await writeFile(client, path, content);
          return { content: [{ type: "text", text: `Wrote ${content.length} bytes to ${path}` }] };
        });
      },
    );
  • Handler function for ssh_write_file. Receives path, content, and connection params, then calls writeFile() helper and returns a success message with byte count.
    async ({ path, content, ...conn }) => {
      return connectionPool.withConnection(conn, async (client) => {
        await writeFile(client, path, content);
        return { content: [{ type: "text", text: `Wrote ${content.length} bytes to ${path}` }] };
      });
    },
  • Input schema for ssh_write_file. Extends connectionParams with 'path' (string) and 'content' (string) fields described with Zod.
    {
      ...connectionParams,
      path: z.string().describe("Absolute path to the remote file"),
      content: z.string().describe("File content to write"),
    },
  • The writeFile helper function that performs the actual SFTP write. Opens an SFTP session from the SSH client and calls sftp.writeFile() to write content to the remote path.
    export async function writeFile(client: Client, remotePath: string, content: string): Promise<void> {
      const sftp = await getSftp(client);
      try {
        await new Promise<void>((resolve, reject) => {
          sftp.writeFile(remotePath, content, (err) => {
            if (err) return reject(err);
            resolve();
          });
        });
      } finally {
        sftp.end();
      }
    }
Behavior3/5

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

Discloses write and overwrite behavior, but lacks details on permissions, error handling, or directory existence. No annotations provided, so description carries the full burden.

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

Conciseness4/5

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

Very concise (one sentence, 12 words). Front-loads the purpose. Could include a bit more usage context without harming brevity.

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?

Brief description omits prerequisites, security considerations, and operational conditions. For a write operation with 7 parameters, more context is needed for safe and correct usage.

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 has 100% parameter description coverage, so description adds no extra meaning. It does not repeat schema info, which is appropriate, but contributes no additional context.

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?

Explicitly states the action 'Write content to a file on a remote host via SFTP' and clarifies it creates or overwrites. Clearly distinguishes from siblings like ssh_read_file or ssh_exec.

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?

No guidance on when to use this tool versus alternatives (e.g., ssh_upload, ssh_exec). No when-not scenarios or prerequisites mentioned.

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

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