Skip to main content
Glama
stefanskiasan

Azure DevOps MCP Server for Cline

trigger.ts1.82 kB
import { ErrorCode, McpError } from '@modelcontextprotocol/sdk/types.js'; import { AzureDevOpsConnection } from '../../api/connection.js'; import { AzureDevOpsConfig } from '../../config/environment.js'; interface TriggerPipelineArgs { pipelineId: number; branch?: string; variables?: Record<string, string>; } export async function triggerPipeline(args: TriggerPipelineArgs, config: AzureDevOpsConfig) { if (!args.pipelineId) { throw new McpError(ErrorCode.InvalidParams, 'Pipeline ID is required'); } AzureDevOpsConnection.initialize(config); const connection = AzureDevOpsConnection.getInstance(); const pipelineApi = await connection.getBuildApi(); try { // Get pipeline definition first const definition = await pipelineApi.getDefinition( config.project, args.pipelineId ); if (!definition) { throw new McpError( ErrorCode.InvalidParams, `Pipeline with ID ${args.pipelineId} not found` ); } // Create build parameters const build = { definition: { id: args.pipelineId, }, project: definition.project, sourceBranch: args.branch || definition.repository?.defaultBranch || 'main', parameters: args.variables ? JSON.stringify(args.variables) : undefined, }; // Queue new build const queuedBuild = await pipelineApi.queueBuild(build, config.project); return { content: [ { type: 'text', text: JSON.stringify(queuedBuild, null, 2), }, ], }; } catch (error: unknown) { if (error instanceof McpError) throw error; const errorMessage = error instanceof Error ? error.message : 'Unknown error'; throw new McpError( ErrorCode.InternalError, `Failed to trigger pipeline: ${errorMessage}` ); } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/stefanskiasan/azure-devops-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server