Skip to main content
Glama

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
NameRequiredDescriptionDefault
jsonNoFormat output as newline delimited JSON (default: true).

Implementation Reference

  • 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() }) }, ], }; } };
  • 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)."), });
  • 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,

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/alexbakers/mcp-ipfs'

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