w3_delegation_create
Create delegations for specific capabilities on the MCP-IPFS server. Specify audience DID, capabilities, and output path to generate a CAR file or base64 identity CID.
Instructions
Tool for w3_delegation_create operation. Requires ABSOLUTE paths for file arguments.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| audienceDid | Yes | The DID of the audience receiving the delegation (e.g., did:key:...). | |
| base64 | No | Format output as base64 identity CID string instead of writing to a file. | |
| capabilities | Yes | One or more capabilities to delegate (e.g., ['space/*', 'upload/*']). | |
| name | No | Human-readable name for the audience. | |
| output | No | ABSOLUTE path of file to write the exported delegation CAR file to. | |
| type | No | Type of the audience. |
Implementation Reference
- src/tool_handlers.ts:252-286 (handler)The main handler function `handleW3DelegationCreate` that validates input arguments, constructs and executes the `w3 delegation create` CLI command using `runW3Command`, and formats the response.const handleW3DelegationCreate: ToolHandler = async (args) => { const parsed = Schemas.W3DelegationCreateArgsSchema.safeParse(args); if (!parsed.success) throw new Error( `Invalid arguments for w3_delegation_create: ${parsed.error.message}` ); const { audienceDid, capabilities, name: delName, type, output: outFile, base64, } = parsed.data; let command = `delegation create ${audienceDid}`; capabilities.forEach((cap) => { command += ` --can '${cap}'`; }); if (delName) command += ` --name "${delName}"`; if (type) command += ` --type ${type}`; if (outFile) command += ` --output "${outFile}"`; if (base64) command += ` --base64`; const { stdout } = await runW3Command(command); const message = base64 ? "Delegation created successfully (base64 output)." : `Delegation created successfully (output file: ${outFile}).`; return { content: [ { type: "text", text: JSON.stringify({ message: message, output: stdout.trim() }), }, ], }; };
- src/schemas.ts:96-126 (schema)Zod schema `W3DelegationCreateArgsSchema` defining and validating the input parameters for the tool, used in handler and dynamically for tool metadata.export const W3DelegationCreateArgsSchema = z.object({ audienceDid: z .string() .describe( "The DID of the audience receiving the delegation (e.g., did:key:...)." ), capabilities: z .array(z.string()) .min(1) .describe( "One or more capabilities to delegate (e.g., ['space/*', 'upload/*'])." ), name: z.string().optional().describe("Human-readable name for the audience."), type: z .enum(["device", "app", "service"]) .optional() .describe("Type of the audience."), output: z .string() .optional() .describe( "ABSOLUTE path of file to write the exported delegation CAR file to." ), base64: z .boolean() .optional() .default(false) .describe( "Format output as base64 identity CID string instead of writing to a file." ), });
- src/tool_handlers.ts:955-955 (registration)Registration of the `handleW3DelegationCreate` handler in the `toolHandlers` map, which is imported and used in `index.ts` to dispatch tool calls.w3_delegation_create: handleW3DelegationCreate,