w3_ls
List files and directories in IPFS storage using JSON format. Ideal for managing data and storage spaces within the MCP-IPFS server environment.
Instructions
Tool for w3_ls operation.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| json | No | Format output as newline delimited JSON (default: true). |
Implementation Reference
- src/tool_handlers.ts:120-139 (handler)The handler function that implements the core logic for the w3_ls tool. It validates input arguments using the schema, runs the corresponding w3 CLI command, parses NDJSON output if in JSON mode, and formats the response for MCP.const handleW3Ls: ToolHandler = async (args) => { const parsed = Schemas.W3LsArgsSchema.safeParse(args); if (!parsed.success) throw new Error(`Invalid arguments for w3_ls: ${parsed.error.message}`); const { json } = parsed.data; const command = json ? "ls --json" : "ls"; const { stdout } = await runW3Command(command); if (json) { const uploads = parseNdJson(stdout); return { content: [{ type: "text", text: JSON.stringify({ uploads }) }], }; } else { return { content: [ { type: "text", text: JSON.stringify({ output: stdout.trim() }) }, ], }; } };
- src/schemas.ts:47-53 (schema)Zod schema for validating the input arguments to the w3_ls tool, featuring an optional 'json' boolean flag defaulting to true.export const W3LsArgsSchema = z.object({ json: z .boolean() .optional() .default(true) .describe("Format output as newline delimited JSON (default: true)."), });
- src/tool_handlers.ts:950-950 (registration)Maps the tool name 'w3_ls' to its handler function in the exported toolHandlers object, which is used by the MCP server to dispatch tool calls.w3_ls: handleW3Ls,