Skip to main content
Glama

w3_open

Access content stored in IPFS using its CID and optional path, enabling direct retrieval and navigation within the mcp-ipfs server's network.

Instructions

Tool for w3_open operation.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
cidYesThe CID of the content to open.
pathNoOptional path within the content to append to the URL.

Implementation Reference

  • The main handler function for the 'w3_open' tool. It validates input arguments using W3OpenArgsSchema, constructs a gateway URL (https://w3s.link/ipfs/{cid}/{path?}), and returns a text content block with the URL for the user to open in their browser.
    const handleW3Open: ToolHandler = async (args) => { const parsed = Schemas.W3OpenArgsSchema.safeParse(args); if (!parsed.success) throw new Error(`Invalid arguments for w3_open: ${parsed.error.message}`); const { cid, path } = parsed.data; const baseUrl = "https://w3s.link/ipfs/"; const fullPath = path ? `${cid}/${path}` : cid; const url = `${baseUrl}${fullPath}`; return { content: [ { type: "text", text: JSON.stringify({ message: `To view the content, open this URL in your browser: ${url}`, url: url, }), }, ], }; };
  • Zod schema defining the input parameters for the 'w3_open' tool: 'cid' (string, required), 'path' (string, optional).
    export const W3OpenArgsSchema = z.object({ cid: z.string().describe("The CID of the content to open."), path: z .string() .optional() .describe("Optional path within the content to append to the URL."), });
  • Maps the tool name 'w3_open' to its handler function 'handleW3Open' in the toolHandlers object exported from tool_handlers.ts, which is imported and used by the MCP server in index.ts to dispatch tool calls dynamically.
    w3_open: handleW3Open,

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