local_ydb_container_logs
Read recent Docker logs from local-ydb containers to diagnose bootstrap, restart, or readiness failures. Target the static or primary dynamic node and control log tail length.
Instructions
Read recent Docker logs from the configured static or primary dynamic local-ydb container. Use when bootstrap, restart, or readiness checks fail; target selects the container role and lines controls the tail length.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| profile | No | Named profile from local-ydb.config.json. Defaults to config.defaultProfile. | |
| configPath | No | Explicit local-ydb config file path to load for this tool call. Useful when the MCP server should pick up a different config without restart. | |
| target | Yes | Container role to read logs from: static node or primary dynamic tenant node. | |
| lines | No | Number of recent log lines to read. Defaults to 200. |
Implementation Reference
- The core handler function `containerLogs` that executes the tool logic. It runs `docker logs` for the targeted container (static or dynamic) with a configurable line count, returning stdout/stderr.
export async function containerLogs( ctx: ToolkitContext, options: { target: "static" | "dynamic"; lines?: number } ) { const container = options.target === "dynamic" ? ctx.profile.dynamicContainer : ctx.profile.staticContainer; const lines = options.lines ?? 200; const result = await ctx.client.run({ command: "docker", args: ["logs", "--tail", String(lines), container], allowFailure: true, description: `Read ${options.target} container logs` }); return { summary: result.ok ? `Read ${options.target} container logs.` : `Failed to read ${options.target} container logs.`, ok: result.ok, container, command: result.command, stdout: result.stdout, stderr: result.stderr }; } - The `logsSchema` function defines the JSON Schema input schema for the tool: required 'target' (static/dynamic) and optional 'lines' (integer, min 1).
export function logsSchema(): Tool["inputSchema"] { return { type: "object", required: ["target"], properties: { profile: profileProperty(), configPath: configPathProperty(), target: { type: "string", enum: ["static", "dynamic"], description: "Container role to read logs from: static node or primary dynamic tenant node.", }, lines: { type: "integer", minimum: 1, description: "Number of recent log lines to read. Defaults to 200.", }, }, additionalProperties: false, }; } - The `LogsArgs` Zod schema (extends ProfileArgs) that validates parsed arguments: target enum and optional positive integer lines.
export const LogsArgs = ProfileArgs.extend({ target: z.enum(["static", "dynamic"]), lines: z.number().int().positive().optional(), }); - packages/mcp-server/src/tools/registry.ts:177-187 (registration)Registration of the 'local_ydb_container_logs' tool in the registry, mapping name, description, inputSchema (from logsSchema()), and handler (withContext wrapping containerLogs).
defineTool({ group: "checks", name: "local_ydb_container_logs", description: "Read recent Docker logs from the configured static or primary dynamic local-ydb container. Use when bootstrap, restart, or readiness checks fail; target selects the container role and lines controls the tail length.", inputSchema: logsSchema(), annotations: readOnlyAnnotations(), handler: withContext(LogsArgs, (context, parsed) => containerLogs(context, parsed), ), }), - The return object shape from containerLogs, including summary, ok flag, container name, command, stdout, and stderr.
return { summary: result.ok ? `Read ${options.target} container logs.` : `Failed to read ${options.target} container logs.`, ok: result.ok, container, command: result.command, stdout: result.stdout, stderr: result.stderr };