get_webhook
Fetch a webhook subscription's full configuration by GID to verify details before updating, deleting, or debugging delivery issues.
Instructions
Fetch a single webhook subscription's full configuration by GID — topic, endpoint, format, API version, includeFields filter, metafield namespaces, and timestamps. Use to verify subscription details before update or delete, or when debugging delivery issues.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Webhook subscription GID. |
Implementation Reference
- src/tools/webhooks.ts:233-262 (handler)Tool handler for 'get_webhook'. Fetches a single webhook subscription by GID, returns its full configuration (topic, endpoint, format, API version, includeFields, metafieldNamespaces, timestamps). Uses GET_WEBHOOK_QUERY GraphQL query.
server.tool( "get_webhook", "Fetch a single webhook subscription's full configuration by GID — topic, endpoint, format, API version, includeFields filter, metafield namespaces, and timestamps. Use to verify subscription details before update or delete, or when debugging delivery issues.", getWebhookSchema, async (args) => { const data = await client.graphql<{ webhookSubscription: WebhookSubscriptionNode | null; }>(GET_WEBHOOK_QUERY, { id: args.id }); if (!data.webhookSubscription) { return { content: [ { type: "text" as const, text: `Webhook not found: ${args.id}` }, ], }; } const w = data.webhookSubscription; return { content: [ { type: "text" as const, text: [ summarizeWebhook(w), ` Created: ${w.createdAt}`, ` Updated: ${w.updatedAt}`, ].join("\n"), }, ], }; }, ); - src/tools/webhooks.ts:135-137 (schema)Input schema for 'get_webhook': expects a string 'id' field describing the webhook subscription GID.
const getWebhookSchema = { id: z.string().describe("Webhook subscription GID."), }; - src/tools/webhooks.ts:233-262 (registration)Tool registration via server.tool('get_webhook', ...) inside registerWebhookTools(), called from src/server.ts line 66.
server.tool( "get_webhook", "Fetch a single webhook subscription's full configuration by GID — topic, endpoint, format, API version, includeFields filter, metafield namespaces, and timestamps. Use to verify subscription details before update or delete, or when debugging delivery issues.", getWebhookSchema, async (args) => { const data = await client.graphql<{ webhookSubscription: WebhookSubscriptionNode | null; }>(GET_WEBHOOK_QUERY, { id: args.id }); if (!data.webhookSubscription) { return { content: [ { type: "text" as const, text: `Webhook not found: ${args.id}` }, ], }; } const w = data.webhookSubscription; return { content: [ { type: "text" as const, text: [ summarizeWebhook(w), ` Created: ${w.createdAt}`, ` Updated: ${w.updatedAt}`, ].join("\n"), }, ], }; }, ); - src/tools/webhooks.ts:54-73 (helper)GraphQL query definition GET_WEBHOOK_QUERY used by the get_webhook handler to fetch webhook data.
const GET_WEBHOOK_QUERY = /* GraphQL */ ` query GetWebhook($id: ID!) { webhookSubscription(id: $id) { id topic format createdAt updatedAt includeFields metafieldNamespaces apiVersion { handle } endpoint { __typename ... on WebhookHttpEndpoint { callbackUrl } ... on WebhookPubSubEndpoint { pubSubProject pubSubTopic } ... on WebhookEventBridgeEndpoint { arn } } } } `; - src/tools/webhooks.ts:176-193 (helper)Helper function summarizeWebhook() used by get_webhook handler to format the webhook output text.
function summarizeWebhook(w: WebhookSubscriptionNode): string { const target = w.endpoint.callbackUrl ?? (w.endpoint.pubSubProject ? `pubsub ${w.endpoint.pubSubProject}/${w.endpoint.pubSubTopic}` : null) ?? w.endpoint.arn ?? "(unknown endpoint)"; const filters: string[] = []; if (w.includeFields?.length) { filters.push(`fields: ${w.includeFields.join(",")}`); } if (w.metafieldNamespaces?.length) { filters.push(`metafields: ${w.metafieldNamespaces.join(",")}`); } const filterStr = filters.length ? ` (${filters.join("; ")})` : ""; return ` ${w.topic} [${w.format}@${w.apiVersion.handle}] → ${target}${filterStr} — ${w.id}`; }