get-thread-subscription
Check subscription status for a GitHub notification thread to manage notification preferences.
Instructions
Get subscription status for a GitHub notification thread
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| thread_id | Yes | The ID of the notification thread to check subscription status |
Implementation Reference
- The main handler function that executes the tool logic: fetches the GitHub notification thread subscription status, formats it, and handles errors including 404 for unsubscribed threads.export async function getThreadSubscriptionHandler(args: z.infer<typeof getThreadSubscriptionSchema>) { try { // Make request to GitHub API const subscription = await githubGet<ThreadSubscription>(`/notifications/threads/${args.thread_id}/subscription`); // Format the subscription for better readability const formattedSubscription = formatSubscription(subscription); return { content: [{ type: "text", text: `Subscription status for thread ${args.thread_id}:\n\n${formattedSubscription}` }] }; } catch (error) { if (error instanceof Error && error.message.includes("404")) { return { content: [{ type: "text", text: `You are not subscribed to thread ${args.thread_id}.` }] }; } return { isError: true, content: [{ type: "text", text: formatError(`Failed to fetch subscription for thread ${args.thread_id}`, error) }] }; } }
- Zod schema defining the input parameter 'thread_id' for the tool.export const getThreadSubscriptionSchema = z.object({ thread_id: z.string().describe("The ID of the notification thread to check subscription status") });
- src/tools/get-thread-subscription.ts:56-63 (registration)Registration function that calls server.tool to register the 'get-thread-subscription' tool with name, description, schema, and handler.export function registerGetThreadSubscriptionTool(server: any) { server.tool( "get-thread-subscription", "Get subscription status for a GitHub notification thread", getThreadSubscriptionSchema.shape, getThreadSubscriptionHandler ); }
- src/server.ts:43-43 (registration)Invocation of the registration function during server startup to register the tool.registerGetThreadSubscriptionTool(server);