create_pipeline_webhook
Create a webhook for an AWS CodePipeline to enable automatic pipeline triggering based on external events, with configurable authentication and event filters.
Instructions
Create a webhook for a pipeline to enable automatic triggering
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pipelineName | Yes | Name of the pipeline | |
| webhookName | Yes | Name for the webhook | |
| targetAction | Yes | The name of the action in the pipeline that processes the webhook | |
| authentication | Yes | Authentication method for the webhook | |
| authenticationConfiguration | No | Authentication configuration based on the authentication type | |
| filters | No | Event filters for the webhook |
Implementation Reference
- The main handler function that implements the create_pipeline_webhook tool logic, creating and registering a webhook for an AWS CodePipeline using the AWS SDK.export async function createPipelineWebhook( codePipelineManager: CodePipelineManager, input: { pipelineName: string; webhookName: string; targetAction: string; authentication: string; authenticationConfiguration?: { SecretToken?: string; AllowedIpRange?: string; }; filters?: Array<{ jsonPath: string; matchEquals?: string; }>; } ) { const { pipelineName, webhookName, targetAction, authentication, authenticationConfiguration = {}, filters = [] } = input; const codepipeline = codePipelineManager.getCodePipeline(); // Create the webhook const response = await codepipeline.putWebhook({ webhook: { name: webhookName, targetPipeline: pipelineName, targetAction: targetAction, filters: filters.map(filter => ({ jsonPath: filter.jsonPath, matchEquals: filter.matchEquals })), authentication, authenticationConfiguration } }).promise(); // Register the webhook await codepipeline.registerWebhookWithThirdParty({ webhookName }).promise(); // Extract webhook details safely const webhookDetails = { name: webhookName, url: response.webhook ? String(response.webhook.url) : undefined, targetPipeline: pipelineName, targetAction: targetAction }; return { content: [ { type: "text", text: JSON.stringify({ message: "Pipeline webhook created and registered successfully", webhookDetails }, null, 2), }, ], }; }
- The input schema and metadata definition for the create_pipeline_webhook tool, specifying parameters like pipelineName, webhookName, targetAction, authentication, etc.export const createPipelineWebhookSchema = { name: "create_pipeline_webhook", description: "Create a webhook for a pipeline to enable automatic triggering", inputSchema: { type: "object", properties: { pipelineName: { type: "string", description: "Name of the pipeline" }, webhookName: { type: "string", description: "Name for the webhook" }, targetAction: { type: "string", description: "The name of the action in the pipeline that processes the webhook" }, authentication: { type: "string", description: "Authentication method for the webhook", enum: ["GITHUB_HMAC", "IP", "UNAUTHENTICATED"] }, authenticationConfiguration: { type: "object", description: "Authentication configuration based on the authentication type", properties: { SecretToken: { type: "string", description: "Secret token for GITHUB_HMAC authentication" }, AllowedIpRange: { type: "string", description: "Allowed IP range for IP authentication" } } }, filters: { type: "array", description: "Event filters for the webhook", items: { type: "object", properties: { jsonPath: { type: "string", description: "JSON path to filter events" }, matchEquals: { type: "string", description: "Value to match in the JSON path" } }, required: ["jsonPath"] } } }, required: ["pipelineName", "webhookName", "targetAction", "authentication"], }, } as const;
- src/index.ts:202-217 (registration)Registration of the create_pipeline_webhook tool in the MCP server's CallToolRequestHandler switch statement, dispatching calls to the handler function.case "create_pipeline_webhook": { return await createPipelineWebhook(codePipelineManager, input as { pipelineName: string; webhookName: string; targetAction: string; authentication: string; authenticationConfiguration?: { SecretToken?: string; AllowedIpRange?: string; }; filters?: Array<{ jsonPath: string; matchEquals?: string; }>; }); }
- src/index.ts:61-63 (registration)Import statement for the create_pipeline_webhook handler and schema.createPipelineWebhook, createPipelineWebhookSchema } from "./tools/create_pipeline_webhook.js";
- src/index.ts:124-124 (registration)Inclusion of the createPipelineWebhookSchema in the list of tools returned by ListToolsRequestHandler.createPipelineWebhookSchema,