Skip to main content
Glama

w3_bridge_generate_tokens

Generate authentication tokens for the UCAN-HTTP bridge, enabling delegated capabilities and expiration settings for secure access to MCP IPFS server resources.

Instructions

Generates authentication tokens for using the UCAN-HTTP bridge.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
capabilitiesYesOne or more capabilities to delegate (e.g., ['space/info']).
expirationNoUnix timestamp (in seconds) for expiration. Zero means no expiration.
jsonNoOutput JSON suitable for fetch headers (default: true).

Implementation Reference

  • The primary handler function for the 'w3_bridge_generate_tokens' tool. Validates input arguments using the corresponding Zod schema, constructs the 'w3 bridge generate-tokens' CLI command based on capabilities, expiration, and json flag, executes it via runW3Command utility, handles JSON parsing, and formats the response as MCP content.
    const handleW3BridgeGenerateTokens: ToolHandler = async (args) => { const parsed = Schemas.W3BridgeGenerateTokensArgsSchema.safeParse(args); if (!parsed.success) throw new Error( `Invalid arguments for w3_bridge_generate_tokens: ${parsed.error.message}` ); const { capabilities, expiration, json } = parsed.data; let command = "bridge generate-tokens"; capabilities.forEach((cap) => { command += ` --can '${cap}'`; }); if (expiration !== undefined) command += ` --expiration ${expiration}`; if (json) command += " --json"; const { stdout } = await runW3Command(command); if (json) { try { const tokenData = JSON.parse(stdout); return { content: [ { type: "text", text: JSON.stringify({ message: "Bridge tokens generated (JSON format).", tokenData, }), }, ], }; } catch (e) { logger.warn("Failed to parse bridge tokens JSON, returning raw."); return { content: [ { type: "text", text: JSON.stringify({ message: "Bridge tokens generated (raw output).", output: stdout.trim(), }), }, ], }; } } else { return { content: [ { type: "text", text: JSON.stringify({ message: "Bridge tokens generated (raw output).", output: stdout.trim(), }), }, ], }; } };
  • Zod schema defining the input parameters for the 'w3_bridge_generate_tokens' tool, including required capabilities array, optional expiration timestamp, and json output flag with descriptions.
    export const W3BridgeGenerateTokensArgsSchema = z .object({ capabilities: z .array(z.string()) .min(1) .describe("One or more capabilities to delegate (e.g., ['space/info'])."), expiration: z .number() .int() .positive() .optional() .describe( "Unix timestamp (in seconds) for expiration. Zero means no expiration." ), json: z .boolean() .optional() .default(true) .describe("Output JSON suitable for fetch headers (default: true)."), }) .describe("Generates authentication tokens for using the UCAN-HTTP bridge.");
  • Maps the tool name 'w3_bridge_generate_tokens' to its handler function in the exported toolHandlers object, which is imported and used by the main MCP server in index.ts to dispatch tool calls.
    w3_bridge_generate_tokens: handleW3BridgeGenerateTokens,

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