Skip to main content
Glama
hifishhe

Synology Docker MCP Server

by hifishhe

synology_docker_logs

Retrieve logs from a specific Docker container on Synology NAS. Provide container name or ID and optionally set the number of recent lines to display.

Instructions

Get logs for a specific docker container

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
container_nameYesName or ID of the container
tailNoNumber of lines to show from the end of the logs

Implementation Reference

  • Tool registration and schema definition for synology_docker_logs in the ListToolsRequestSchema handler. Defines the tool name, description, and input schema requiring container_name (string) and optional tail (number, default 100).
    {
      name: "synology_docker_logs",
      description: "Get logs for a specific docker container",
      inputSchema: {
        type: "object",
        properties: {
          container_name: { type: "string", description: "Name or ID of the container" },
          tail: { type: "number", description: "Number of lines to show from the end of the logs", default: 100 },
        },
        required: ["container_name"],
      },
  • Handler for synology_docker_logs in the CallToolRequestSchema handler. Extracts container_name and optional tail, validates with validateContainerName, clamps tail between 1-10000 (default 100), and runs 'docker logs --tail N <container>' via SSH, returning stdout or stderr as text.
    else if (name === "synology_docker_logs") {
      const { container_name } = args as { container_name: string; tail?: number };
      validateContainerName(container_name);
      const tailRaw = (args as any)?.tail;
      const tail = Number.isInteger(tailRaw) && tailRaw > 0 ? Math.min(tailRaw, 10000) : 100;
      const res = await execSshCommand(`docker logs --tail ${tail} ${shQuote(container_name)} 2>&1`);
      return { content: [{ type: "text", text: res.stdout || res.stderr }] };
    }
  • Validation helper that ensures container names contain only alphanumeric characters, underscores, dots, and hyphens, throwing an error if invalid.
    function validateContainerName(name: string): void {
      if (!/^[a-zA-Z0-9][a-zA-Z0-9_.\-]*$/.test(name)) {
        throw new Error(`Invalid container name: ${name}`);
      }
    }
  • Shell quoting helper that wraps a string in single quotes and escapes any internal single quotes, used to safely pass container names to SSH commands.
    function shQuote(s: string): string {
      return "'" + s.replace(/'/g, "'\\''") + "'";
    }
  • SSH execution helper that connects to the NAS, runs a command via sudo with password piped via printf, and returns stdout, stderr, and exit code.
    async function execSshCommand(command: string): Promise<{ stdout: string; stderr: string; code: number }> {
      return new Promise((resolve, reject) => {
        const conn = new Client();
        conn.on("ready", () => {
          // Use printf to avoid shell expansion of password contents.
          const fullCommand = `export PATH=$PATH:/usr/local/bin:/opt/bin:/bin:/usr/bin && printf '%s\\n' ${shQuote(NAS_PASSWORD!)} | sudo -S sh -c ${shQuote(command)}`;
          conn.exec(fullCommand, (err, stream) => {
            if (err) {
              conn.end();
              return reject(err);
            }
    
            let stdout = "";
            let stderr = "";
    
            stream
              .on("close", (code: number) => {
                conn.end();
                resolve({ stdout, stderr, code });
              })
              .on("data", (data: any) => {
                stdout += data;
              })
              .stderr.on("data", (data: any) => {
                stderr += data;
              });
          });
        }).on("error", (err) => {
          reject(err);
        }).connect({
          host: NAS_HOST,
          port: NAS_PORT,
          username: NAS_USER,
          password: NAS_PASSWORD,
          readyTimeout: 30000,
        });
      });
Behavior2/5

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

No annotations provided, so description must bear full burden. It states 'Get logs' (read-only implied) but does not disclose whether actions are destructive, required permissions, or output details. Minimal transparency beyond the schema.

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 single sentence, front-loaded with key action. Efficient, but arguably too short to fully inform the agent.

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 tool with two parameters and no output schema, the description is minimally adequate. Lacks mention of output format, log origin, or caveats. Sibling context is not leveraged.

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% description coverage for both parameters, so baseline is 3. The description adds no extra meaning beyond what the schema 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 'Get' and resource 'logs for a specific docker container'. It distinguishes from sibling tools like synology_docker_manage (manage containers) and synology_docker_ps (list containers).

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. Does not mention that synology_docker_ps lists containers or that synology_docker_manage handles container lifecycle. Implied usage only.

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