get_pipeline_state
Retrieve the current status and execution details of an AWS CodePipeline to monitor deployment progress and identify issues.
Instructions
Get the state of a specific pipeline
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| pipelineName | Yes | Name of the pipeline |
Implementation Reference
- src/tools/get_pipeline_state.ts:19-96 (handler)The handler function that fetches the AWS CodePipeline state for the given pipelineName, transforms the response data, and returns it as MCP content.export async function getPipelineState(codePipelineManager: CodePipelineManager, input: { pipelineName: string }) { const { pipelineName } = input; const codepipeline = codePipelineManager.getCodePipeline(); const response = await codepipeline.getPipelineState({ name: pipelineName }).promise(); // Convert AWS.CodePipeline.StageState[] to our StageState[] const stageStates = response.stageStates?.map((stage: AWS.CodePipeline.StageState) => { // Convert TransitionState const inboundTransitionState = stage.inboundTransitionState ? { enabled: stage.inboundTransitionState.enabled === undefined ? false : stage.inboundTransitionState.enabled, lastChangedBy: stage.inboundTransitionState.lastChangedBy, lastChangedAt: stage.inboundTransitionState.lastChangedAt, disabledReason: stage.inboundTransitionState.disabledReason } : undefined; // Convert StageExecution const latestExecution = stage.latestExecution ? { pipelineExecutionId: stage.latestExecution.pipelineExecutionId || '', status: stage.latestExecution.status || '' } : undefined; // Convert ActionStates const actionStates = (stage.actionStates || []).map((action: AWS.CodePipeline.ActionState) => { // Convert ActionExecution const latestExecution = action.latestExecution ? { status: action.latestExecution.status || '', summary: action.latestExecution.summary, lastStatusChange: action.latestExecution.lastStatusChange || new Date().toISOString(), token: action.latestExecution.token, externalExecutionId: action.latestExecution.externalExecutionId, externalExecutionUrl: action.latestExecution.externalExecutionUrl, errorDetails: action.latestExecution.errorDetails ? { code: action.latestExecution.errorDetails.code || '', message: action.latestExecution.errorDetails.message || '' } : undefined } : undefined; // Convert ActionRevision const currentRevision = action.currentRevision ? { revisionId: action.currentRevision.revisionId || '', revisionChangeId: action.currentRevision.revisionChangeId || '', created: action.currentRevision.created || new Date().toISOString() } : undefined; return { actionName: action.actionName || '', currentRevision, latestExecution, entityUrl: action.entityUrl }; }); return { stageName: stage.stageName || '', inboundTransitionState, actionStates, latestExecution }; }) || []; const pipelineState = { pipelineName: response.pipelineName || '', pipelineVersion: response.pipelineVersion || 0, stageStates: stageStates, created: response.created?.toISOString() || '', updated: response.updated?.toISOString() || '' }; return { content: [ { type: "text", text: JSON.stringify({ pipelineState }, null, 2), }, ], }; }
- src/tools/get_pipeline_state.ts:4-17 (schema)Schema definition for the get_pipeline_state tool, including name, description, and input schema requiring pipelineName.export const getPipelineStateSchema = { name: "get_pipeline_state", description: "Get the state of a specific pipeline", inputSchema: { type: "object", properties: { pipelineName: { type: "string", description: "Name of the pipeline" } }, required: ["pipelineName"], }, } as const;
- src/index.ts:110-128 (registration)Registration of the tool schema in the MCP server's listTools request handler.server.setRequestHandler(ListToolsRequestSchema, async () => { return { tools: [ listPipelinesSchema, getPipelineStateSchema, listPipelineExecutionsSchema, approveActionSchema, retryStageSchema, triggerPipelineSchema, getPipelineExecutionLogsSchema, stopPipelineExecutionSchema, // Add new tool schemas getPipelineDetailsSchema, tagPipelineResourceSchema, createPipelineWebhookSchema, getPipelineMetricsSchema, ], }; });
- src/index.ts:140-142 (registration)Dispatch/registration of the tool handler in the MCP server's callTool request handler switch statement.case "get_pipeline_state": { return await getPipelineState(codePipelineManager, input as { pipelineName: string }); }