MCP server scaffold for Drone CI.
mcp-drone-ci
MCP server scaffold for Drone CI.
Status
This repository currently provides:
- a TypeScript project scaffold,
- a working Drone HTTP client (read + action endpoints),
- a real MCP server entrypoint on
stdio(SDK-based), - MCP tool/resource definitions for Drone CI monitoring,
- webhook parsing and HMAC signature verification,
- optional Drone webhook HTTP receiver with in-memory build-state cache,
- basic policy/state modules,
- initial unit tests.
Still pending before production use:
- webhook event processing to store richer build metadata from payloads,
- persistence backend (DB/Redis) for state beyond process memory,
- broader integration tests against mock Drone API/webhook payloads.
Implementation Plan
See docs/implementation-plan.md.
Requirements
- Node.js 20+
- npm 10+
Quick Start
- Install dependencies:
npm install
- Review the required environment variables:
cp .env.example .env
Then export the values in your shell or pass them explicitly in your MCP client configuration. This project does not load .env automatically.
3. Build:
npm run build
- Run tests:
npm test
- Start:
npm start
Run As MCP (stdio)
npm start launches the MCP server on stdio. Configure your MCP client to spawn:
- command:
node - args:
dist/index.js - env:
DRONE_BASE_URL, optional tuning vars (andDRONE_WEBHOOK_SECRETonly if webhook is enabled)
Example MCP config:
{
"mcpServers": {
"drone-ci": {
"command": "node",
"args": ["G:\\projets\\mcp-drone-ci\\dist\\index.js"],
"env": {
"DRONE_BASE_URL": "https://drone.example.com",
"DRONE_TOKEN": "replace-with-drone-token",
"MCP_ENABLE_WRITE_ACTIONS": "false",
"MCP_WEBHOOK_PORT": "0",
"MCP_RECONCILE_INTERVAL_MS": "5000"
}
}
}
}
Windows/JetBrains/Codex note:
- do not rely on custom parent environment variables such as
DRONE_BASE_URLorDRONE_TOKENbeing inherited automatically by a local stdio MCP process, - many MCP stdio launchers only forward a safe subset of environment variables, so
DRONE_*values must usually be set explicitly in the serverenvblock, - do not set
DRONE_TOKENto a placeholder like"${DRONE_TOKEN}"in MCPenvif your client does not expand placeholders; otherwise the literal string is sent and Drone authentication fails (401).
Client compatibility note:
- MCP tool
inputSchemavalues are intentionally kept permissive to improve compatibility with clients such as JetBrains and Codex. - Strict business validation still happens in the tool handlers, so invalid empty strings or non-positive integers are rejected at execution time rather than at MCP discovery/schema time.
drone_pingis available as a minimal no-input diagnostic tool to verify that a client can discover and invoke tools correctly.
Real-time CI Tracking
To enable webhook-driven state cache:
- Set
MCP_WEBHOOK_PORTto a non-zero port (for example8080). - Set
DRONE_WEBHOOK_SECRETto the shared secret configured in Drone. - Configure Drone webhook target to:
http://<host>:<MCP_WEBHOOK_PORT><MCP_WEBHOOK_PATH>- default path is
/webhook/drone
Optional fallback polling:
- set
MCP_RECONCILE_INTERVAL_MS(for example5000) to periodically refresh active builds from Drone API.
MCP Tools
Read tools:
drone_ping: minimal diagnostic tool returning{ ok: true, server: "mcp-drone-ci" }drone_list_repos: list repositories visible to the Drone tokendrone_list_builds: list build summaries for a repositorydrone_get_build: fetch full details for one builddrone_get_build_logs: fetch one stage/step log stream, with optional truncationdrone_get_cached_build_state: inspect webhook-cached build state
Action tools (only when MCP_ENABLE_WRITE_ACTIONS=true):
drone_restart_builddrone_stop_builddrone_approve_builddrone_decline_build
Build filters supported by drone_list_builds:
ownerandrepoare always required- optional
prNumber - optional
sourceBranch - optional
targetBranch - optional
pageandlimit
Numeric inputs:
- build identifiers and pagination values are exposed as generic MCP numbers for broad client compatibility
- integer, positivity, and max-value checks are enforced by the server when the tool is executed
- filtered
drone_list_buildssearches report when the repository scan limit is hit, instead of silently returning a false negative
Example:
{
"name": "drone_list_builds",
"arguments": {
"owner": "leuzeus",
"repo": "gowire",
"prNumber": 510,
"sourceBranch": "S076-gcmp-v2-planning",
"targetBranch": "dev",
"limit": 5
}
}
Token Efficiency
This MCP is designed so agents can stay efficient if they use the tools in the intended order:
- Use
drone_list_buildsto search. - Use
drone_get_buildonly for the specific b
Tools (10)
drone_pingMinimal diagnostic tool to verify client connectivity.drone_list_reposList repositories visible to the Drone token.drone_list_buildsList build summaries for a repository.drone_get_buildFetch full details for one build.drone_get_build_logsFetch one stage/step log stream.drone_get_cached_build_stateInspect webhook-cached build state.drone_restart_buildRestart a specific build.drone_stop_buildStop a specific build.drone_approve_buildApprove a specific build.drone_decline_buildDecline a specific build.Environment Variables
DRONE_BASE_URLrequiredThe base URL of the Drone CI instance.DRONE_TOKENrequiredAuthentication token for the Drone API.MCP_ENABLE_WRITE_ACTIONSEnable action tools like restart, stop, approve, and decline.MCP_WEBHOOK_PORTPort for the optional Drone webhook HTTP receiver.DRONE_WEBHOOK_SECRETShared secret for HMAC signature verification of webhooks.MCP_RECONCILE_INTERVAL_MSInterval in milliseconds for polling build state.Configuration
{"mcpServers": {"drone-ci": {"command": "node", "args": ["G:\\projets\\mcp-drone-ci\\dist\\index.js"], "env": {"DRONE_BASE_URL": "https://drone.example.com", "DRONE_TOKEN": "replace-with-drone-token", "MCP_ENABLE_WRITE_ACTIONS": "false", "MCP_WEBHOOK_PORT": "0", "MCP_RECONCILE_INTERVAL_MS": "5000"}}}}