w3_space_ls
List available storage spaces on the MCP IPFS server. Ensure you're logged in to view and manage your spaces effectively.
Instructions
Tool for w3_space_ls operation. NOTE: no current space and no space given or {"spaces":[]} first make sure you are logged in before using other tools.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tool_handlers.ts:35-68 (handler)The handler function for the 'w3_space_ls' tool. It validates input arguments, runs the 'w3 space ls' command, parses the stdout to extract spaces (DID, name, isCurrent), and returns a JSON response with the list of spaces.const handleW3SpaceLs: ToolHandler = async (_args) => { const parsed = Schemas.W3SpaceLsArgsSchema.safeParse(_args); if (!parsed.success) throw new Error( `Invalid arguments for w3_space_ls: ${parsed.error.message}` ); const { stdout } = await runW3Command("space ls"); const spaces: { did: string; name: string | undefined; isCurrent: boolean; }[] = []; const lines = stdout.trim().split("\n"); for (const line of lines) { let trimmedLine = line.trim(); if (!trimmedLine) continue; let isCurrent = false; if (trimmedLine.startsWith("*")) { isCurrent = true; trimmedLine = trimmedLine.substring(1).trim(); } const parts = trimmedLine.split(/\s+/); const did = parts[0]; const name = parts.length > 1 ? parts.slice(1).join(" ") : undefined; if (did && did.startsWith("did:key:")) { spaces.push({ did, name, isCurrent }); } } return { content: [{ type: "text", text: JSON.stringify({ spaces }) }], }; };
- src/schemas.ts:10-10 (schema)Zod schema for 'w3_space_ls' tool arguments. Defines an empty object since no arguments are required.export const W3SpaceLsArgsSchema = z.object({});
- src/tool_handlers.ts:946-946 (registration)Registers the 'w3_space_ls' handler in the toolHandlers map, which is used by the MCP server's CallToolRequestHandler to dispatch tool calls.w3_space_ls: handleW3SpaceLs,
- src/index.ts:42-91 (registration)The ListToolsRequestHandler dynamically generates tool metadata, including for 'w3_space_ls', by iterating over Schemas and converting Zod schemas to JSON schemas for MCP tool discovery.server.setRequestHandler(ListToolsRequestSchema, async () => { const tools = Object.entries(Schemas) .filter(([name, schema]) => { return name.endsWith("ArgsSchema") && schema instanceof z.ZodType; }) .map(([schemaName, schema]) => { const toolName = schemaName .replace(/([A-Z])/g, "_$1") .replace("_Args_Schema", "") .toLowerCase() .substring(1); let description = schema.description ?? `Tool for ${toolName} operation.`; // Special description overrides for enhanced clarity if (toolName === "w3_login") { description = "Initiates the w3 login process using the pre-configured email (W3_LOGIN_EMAIL env var). IMPORTANT: The command expects email confirmation, so before running the `w3_login` tool, emphasize ATTENTION to the user in large letters + emoji that they MUST check email to complete authentication. If the final output includes 'Agent was authorized by', the user has already clicked the link and is successfully authorized, CONTINUE using mcp-ipfs tools. 'Too Many Requests': wait a moment before requesting it again."; } if (toolName === "w3_space_info" || toolName === "w3_space_ls") { description += ' NOTE: `no current space and no space given` or `{"spaces":[]}` first make sure you are logged in before using other tools.'; } if (toolName === "w3_space_create") { description += " NOTE: `w3 space create` cannot be run via MCP due to interactive recovery key prompts. Please run this command manually in your terminal."; } if ( [ "w3_up", "w3_delegation_create", "w3_delegation_revoke", "w3_proof_add", "w3_can_blob_add", "w3_can_store_add", ].includes(toolName) ) { description += " Requires ABSOLUTE paths for file arguments."; } return { name: toolName, description: description.trim(), inputSchema: zodToJsonSchema(schema) as ToolInputSchema, }; }); return { tools }; });