CI/CD Integration
Integrating devtool-mcp into continuous integration and deployment pipelines.
Overview
devtool-mcp can enhance CI/CD pipelines by:
- Detecting project types automatically
- Running builds and tests with detailed output
- Capturing debugging information on failures
- Providing consistent interface across project types
GitHub Actions
Basic Integration
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24'
- name: Install devtool-mcp
run: go install github.com/devtool-mcp/devtool-mcp@latest
- name: Detect Project
id: detect
run: |
DETECT_OUTPUT=$(devtool-mcp detect)
echo "type=$(echo $DETECT_OUTPUT | jq -r '.type')" >> $GITHUB_OUTPUT
echo "scripts=$(echo $DETECT_OUTPUT | jq -r '.scripts | join(",")')" >> $GITHUB_OUTPUT
- name: Install Dependencies
run: |
case "${{ steps.detect.outputs.type }}" in
node) npm ci ;;
go) go mod download ;;
python) pip install -r requirements.txt ;;
esac
- name: Run Tests
run: devtool-mcp run --script test --mode foreground-raw
Matrix Testing
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
package: [core, api, web]
steps:
- uses: actions/checkout@v4
- name: Test Package
run: |
devtool-mcp run \
--script test \
--path ./packages/${{ matrix.package }} \
--id test-${{ matrix.package }} \
--mode foreground
With Debugging on Failure
- name: Run Tests
id: test
continue-on-error: true
run: devtool-mcp run --script test --mode foreground
- name: Debug on Failure
if: steps.test.outcome == 'failure'
run: |
# Get test output
devtool-mcp proc --action output --process-id test --grep "FAIL"
# Get detailed failures
devtool-mcp proc --action output --process-id test --tail 100
- name: Fail if Tests Failed
if: steps.test.outcome == 'failure'
run: exit 1
GitLab CI
Basic Pipeline
stages:
- detect
- test
- build
detect:
stage: detect
script:
- go install github.com/devtool-mcp/devtool-mcp@latest
- devtool-mcp detect > detect.json
artifacts:
paths:
- detect.json
test:
stage: test
script:
- devtool-mcp run --script test --mode foreground-raw
dependencies:
- detect
build:
stage: build
script:
- devtool-mcp run --script build --mode foreground
artifacts:
paths:
- dist/
Jenkins Pipeline
pipeline {
agent any
stages {
stage('Install') {
steps {
sh 'go install github.com/devtool-mcp/devtool-mcp@latest'
}
}
stage('Detect') {
steps {
script {
def detect = sh(
script: 'devtool-mcp detect',
returnStdout: true
).trim()
env.PROJECT_TYPE = readJSON(text: detect).type
}
}
}
stage('Test') {
steps {
sh 'devtool-mcp run --script test --mode foreground'
}
}
stage('Build') {
steps {
sh 'devtool-mcp run --script build --mode foreground'
}
}
}
post {
failure {
sh 'devtool-mcp proc --action output --process-id test --grep FAIL'
}
}
}
Monorepo Support
Detect and Test Each Package
name: Monorepo CI
on: [push, pull_request]
jobs:
detect-packages:
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.find.outputs.packages }}
steps:
- uses: actions/checkout@v4
- id: find
run: |
PACKAGES=$(ls -d packages/*/ | jq -R -s -c 'split("\n")[:-1]')
echo "packages=$PACKAGES" >> $GITHUB_OUTPUT
test-packages:
needs: detect-packages
runs-on: ubuntu-latest
strategy:
matrix:
package: ${{ fromJson(needs.detect-packages.outputs.packages) }}
steps:
- uses: actions/checkout@v4
- name: Detect Package Type
id: detect
run: |
cd ${{ matrix.package }}
devtool-mcp detect
- name: Test Package
run: |
devtool-mcp run \
--script test \
--path ${{ matrix.package }} \
--mode foreground-raw
Port Cleanup in CI
- name: Clean Up Ports
run: |
# Ensure ports are available before starting services
devtool-mcp proc --action cleanup_port --port 3000
devtool-mcp proc --action cleanup_port --port 8080
E2E Testing with Proxy
e2e:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Start App
run: |
devtool-mcp run --script dev --id app &
sleep 10 # Wait for app to start
- name: Start Proxy
run: |
devtool-mcp proxy \
--action start \
--id e2e \
--target-url http://localhost:3000 \
--port 8080 &
- name: Run E2E Tests
run: |
npx playwright test --base-url http://localhost:8080
- name: Collect Logs on Failure
if: failure()
run: |
# Get captured traffic
devtool-mcp proxylog --proxy-id e2e --types http,error
# Get app output
devtool-mcp proc --action output --process-id app --tail 100
Parallel Testing
test:
runs-on: ubuntu-latest
steps:
- name: Run All Tests in Parallel
run: |
# Start all tests
devtool-mcp run --script test:unit --id unit &
devtool-mcp run --script test:integration --id integration &
devtool-mcp run --script test:e2e --id e2e &
# Wait and collect results
wait
# Check results
devtool-mcp proc --action list
Build Matrix
build:
strategy:
matrix:
include:
- script: build:dev
env: development
- script: build:staging
env: staging
- script: build:prod
env: production
steps:
- name: Build for ${{ matrix.env }}
run: |
devtool-mcp run \
--script ${{ matrix.script }} \
--id build-${{ matrix.env }} \
--mode foreground
Caching
- name: Cache Go modules
uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-${{ hashFiles('**/go.sum') }}
- name: Cache devtool-mcp
uses: actions/cache@v4
with:
path: ~/go/bin/devtool-mcp
key: devtool-mcp-${{ runner.os }}
Notifications
- name: Notify on Failure
if: failure()
run: |
FAILURES=$(devtool-mcp proc --action output --process-id test --grep FAIL | head -20)
curl -X POST $SLACK_WEBHOOK \
-H 'Content-Type: application/json' \
-d "{\"text\": \"Test failures:\n$FAILURES\"}"
Best Practices
- Use foreground mode - Ensures proper exit codes
- Capture output on failure - Debug faster
- Clean up ports - Avoid conflicts in shared runners
- Cache devtool-mcp - Faster CI runs
- Use unique IDs - Parallel job clarity
- Leverage detection - Consistent cross-project scripts
Exit Codes
| Code | Meaning |
|---|---|
| 0 | Success |
| 1 | Test/build failure |
| 2 | Configuration error |
| 3 | Process error |