unsubscribe
Cancel blockchain event subscriptions to stop receiving updates and manage notification preferences in the Alchemy MCP Plugin.
Instructions
Unsubscribe from blockchain events
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| subscriptionId | Yes | The ID of the subscription to cancel |
Implementation Reference
- index.ts:1137-1155 (handler)The main handler function for the 'unsubscribe' tool. It validates the input parameters, retrieves the subscription from the activeSubscriptions map, calls unsubscribe on it, removes it from the map, and returns success.private async handleUnsubscribe(args: Record<string, unknown>) { const params = this.validateAndCastParams<UnsubscribeParams>( args, isValidUnsubscribeParams, "Invalid unsubscribe parameters" ); const subscription = this.activeSubscriptions.get(params.subscriptionId); if (!subscription) { throw new McpError( ErrorCode.InvalidParams, `Subscription not found: ${params.subscriptionId}` ); } subscription.unsubscribe(); this.activeSubscriptions.delete(params.subscriptionId); return { success: true }; }
- index.ts:962-975 (registration)Registration of the 'unsubscribe' tool in the ListTools response, defining its name, description, and input schema.{ name: "unsubscribe", description: "Unsubscribe from blockchain events", inputSchema: { type: "object", properties: { subscriptionId: { type: "string", description: "The ID of the subscription to cancel", }, }, required: ["subscriptionId"], }, },
- index.ts:98-100 (schema)TypeScript type definition for the input parameters of the unsubscribe tool.type UnsubscribeParams = { subscriptionId: string; };
- index.ts:360-366 (helper)Validation helper function to check if arguments match UnsubscribeParams type.const isValidUnsubscribeParams = (args: any): args is UnsubscribeParams => { return ( typeof args === "object" && args !== null && typeof args.subscriptionId === "string" ); };
- index.ts:1002-1003 (helper)Dispatch case in the CallToolRequest handler that routes to the unsubscribe handler.case "unsubscribe": result = await this.handleUnsubscribe(request.params.arguments);