Skip to main content
Glama
hifishhe

Synology Docker MCP Server

by hifishhe

synology_write_file

Write or update Docker configuration files directly on Synology NAS within /volume1/docker.

Instructions

Write or update a configuration file on the NAS (restricted to /volume1/docker)

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filepathYesAbsolute path to the file on the NAS (must be within /volume1/docker)
contentYesFile content to write

Implementation Reference

  • src/index.ts:177-188 (registration)
    Registration of the synology_write_file tool in the ListToolsRequestSchema handler, including its inputSchema with required 'filepath' and 'content' parameters.
    {
      name: "synology_write_file",
      description: `Write or update a configuration file on the NAS (restricted to ${NAS_DOCKER_DIR})`,
      inputSchema: {
        type: "object",
        properties: {
          filepath: { type: "string", description: `Absolute path to the file on the NAS (must be within ${NAS_DOCKER_DIR})` },
          content: { type: "string", description: "File content to write" },
        },
        required: ["filepath", "content"],
      },
    },
  • Handler for synology_write_file tool. Extracts filepath and content from args, validates the path, base64-encodes the content to avoid shell escaping issues, then writes via SSH using printf and base64 -d redirection.
    else if (name === "synology_write_file") {
      const { filepath, content } = args as { filepath: string; content: string };
      validateRestrictedPath(filepath);
      const base64Content = Buffer.from(content).toString("base64");
      // base64 output is [A-Za-z0-9+/=], safe to single-quote directly.
      const res = await execSshCommand(`printf '%s' ${shQuote(base64Content)} | base64 -d > ${shQuote(filepath)}`);
      if (res.code !== 0) {
        return { content: [{ type: "text", text: `Error writing file: ${res.stderr}` }] };
      }
      return { content: [{ type: "text", text: `File ${filepath} successfully written.` }] };
    }
  • Helper function validateRestrictedPath used by the handler to ensure the filepath is absolute, prevents path traversal (..), and restricts writes to NAS_DOCKER_DIR.
    function validateRestrictedPath(filepath: string): void {
      if (!filepath.startsWith("/")) {
        throw new Error("Path must be absolute");
      }
      if (filepath.split("/").some((p) => p === "..")) {
        throw new Error("Path traversal not allowed");
      }
      const base = NAS_DOCKER_DIR.replace(/\/$/, "");
      if (!filepath.startsWith(base + "/")) {
        throw new Error(`Path must be within ${NAS_DOCKER_DIR}`);
      }
    }
  • Helper function shQuote used to safely single-quote strings for shell commands, used when passing base64Content and filepath to the SSH command.
    function shQuote(s: string): string {
      return "'" + s.replace(/'/g, "'\\''") + "'";
    }
Behavior2/5

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

No annotations are provided, and the description only says 'Write or update' without disclosing whether it overwrites, appends, creates, or any permissions or error behavior. The description fails to add value beyond the basic action.

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 sentence that is concise, front-loaded, and contains no fluff. Every word earns its place.

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 simplicity of the tool (2 parameters, no output schema), the description is fairly complete. It could mention whether it overwrites or appends, but the current level is adequate for a configuration file write.

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 sufficiently documents both parameters. The description adds no additional semantics beyond what the schema already provides.

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 verb (Write or update), the resource (configuration file), and the scope (restricted to /volume1/docker). It distinguishes from sibling tools like synology_read_file.

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 implies use for configuration files within a restricted path, providing clear context. However, it does not explicitly state when to use or not use this tool versus alternatives.

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/hifishhe/Synology-Docker-MCP'

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