w3_up
Generates and uploads data securely using ed25519 key pairs to IPFS. Requires absolute paths for file arguments, ensuring precise and controlled data management on the MCP server.
Instructions
Generates and prints a new ed25519 key pair. Does not automatically use it for the agent. Requires ABSOLUTE paths for file arguments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| hidden | No | Include paths starting with '.'. | |
| noWrap | No | Don't wrap input files with a directory. | |
| paths | Yes | Array of one or more ABSOLUTE paths to files or directories to upload. |
Implementation Reference
- src/tool_handlers.ts:97-118 (handler)The handler function that implements the core logic for the 'w3_up' tool. It validates input arguments using the W3UpArgsSchema, constructs the appropriate 'up' CLI command with paths and optional flags, executes it via runW3Command, and returns a structured response with success message and command output.const handleW3Up: ToolHandler = async (args) => { const parsed = Schemas.W3UpArgsSchema.safeParse(args); if (!parsed.success) throw new Error(`Invalid arguments for w3_up: ${parsed.error.message}`); const { paths, noWrap, hidden } = parsed.data; const quotedPaths = paths.map((p) => `"${p}"`).join(" "); let command = `up ${quotedPaths}`; if (noWrap) command += " --no-wrap"; if (hidden) command += " --hidden"; const { stdout } = await runW3Command(command); return { content: [ { type: "text", text: JSON.stringify({ message: "Upload successful.", output: stdout.trim(), }), }, ], }; };
- src/schemas.ts:25-46 (schema)Zod schema defining the input arguments for the w3_up tool: required array of absolute paths, optional noWrap and hidden booleans.export const W3UpArgsSchema = z .object({ paths: z .array(z.string()) .min(1) .describe( "Array of one or more ABSOLUTE paths to files or directories to upload." ), noWrap: z .boolean() .optional() .default(false) .describe("Don't wrap input files with a directory."), hidden: z .boolean() .optional() .default(false) .describe("Include paths starting with '.'."), }) .describe( "Generates and prints a new ed25519 key pair. Does not automatically use it for the agent." );
- src/tool_handlers.ts:944-980 (registration)The toolHandlers object maps tool names to their handler functions, registering 'w3_up' to handleW3Up. This map is used by the MCP server to route CallTool requests to the correct handler.export const toolHandlers: Record<string, ToolHandler> = { w3_login: handleW3Login, w3_space_ls: handleW3SpaceLs, w3_space_use: handleW3SpaceUse, w3_space_create: handleW3SpaceCreate, w3_up: handleW3Up, w3_ls: handleW3Ls, w3_rm: handleW3Rm, w3_open: handleW3Open, w3_space_info: handleW3SpaceInfo, w3_space_add: handleW3SpaceAdd, w3_delegation_create: handleW3DelegationCreate, w3_delegation_ls: handleW3DelegationLs, w3_delegation_revoke: handleW3DelegationRevoke, w3_proof_add: handleW3ProofAdd, w3_proof_ls: handleW3ProofLs, w3_key_create: handleW3KeyCreate, w3_bridge_generate_tokens: handleW3BridgeGenerateTokens, w3_can_blob_add: handleW3CanBlobAdd, w3_can_blob_ls: handleW3CanBlobLs, w3_can_blob_rm: handleW3CanBlobRm, w3_can_index_add: handleW3CanIndexAdd, w3_can_upload_add: handleW3CanUploadAdd, w3_can_upload_ls: handleW3CanUploadLs, w3_can_upload_rm: handleW3CanUploadRm, w3_plan_get: handleW3PlanGet, w3_account_ls: handleW3AccountLs, w3_space_provision: handleW3SpaceProvision, w3_coupon_create: handleW3CouponCreate, w3_usage_report: handleW3UsageReport, w3_can_access_claim: handleW3CanAccessClaim, w3_can_store_add: handleW3CanStoreAdd, w3_can_store_ls: handleW3CanStoreLs, w3_can_store_rm: handleW3CanStoreRm, w3_can_filecoin_info: handleW3CanFilecoinInfo, w3_reset: handleW3Reset, };