A Model Control Protocol (MCP) server that bridges AI coding assistants with JetBrains TeamCity CI/CD server, exposing TeamCity operations as MCP tools. The TeamCity MCP Server allows developers using AI-powered coding assistants (Claude Code, Cursor, Windsurf) to interact with TeamCity directly from their development environment via MCP tools. - Dev Mode (default): Safe CI/CD operations (31 tools
Add this skill
npx mdskills install Daghis/teamcity-mcpComprehensive TeamCity integration with 87 tools, dual operational modes, and excellent documentation
1# TeamCity MCP Server23[](https://github.com/Daghis/teamcity-mcp/actions/workflows/ci.yml)4[](https://github.com/Daghis/teamcity-mcp/actions/workflows/codeql.yml)5[](https://codecov.io/gh/Daghis/teamcity-mcp)6[](LICENSE)78A Model Control Protocol (MCP) server that bridges AI coding assistants with JetBrains TeamCity CI/CD server, exposing TeamCity operations as MCP tools.910<a href="https://glama.ai/mcp/servers/@Daghis/teamcity-mcp">11 <img width="380" height="200" src="https://glama.ai/mcp/servers/@Daghis/teamcity-mcp/badge" alt="TeamCity Server MCP server" />12</a>1314## Overview1516The TeamCity MCP Server allows developers using AI-powered coding assistants (Claude Code, Cursor, Windsurf) to interact with TeamCity directly from their development environment via MCP tools.1718> **Upgrading from 1.x?** Version 2.0.0 moved 15 tools from Dev to Full mode, including queue management, agent compatibility checks, and server health monitoring. If you relied on these tools in Dev mode, switch to `MCP_MODE=full` or use runtime mode switching (v2.1.0+). See [CHANGELOG.md](CHANGELOG.md) for details.1920## Features2122### π Two Operational Modes2324- **Dev Mode** (default): Safe CI/CD operations (31 tools, ~14k context tokens)25 - Trigger builds and monitor status26 - Fetch build logs and inspect test failures27 - List projects, configurations, and queue28 - Read parameters and investigate problems2930- **Full Mode**: Complete infrastructure management (87 tools, ~26k context tokens)31 - All Dev mode features, plus:32 - Create and clone build configurations33 - Manage build steps, triggers, and dependencies34 - Configure VCS roots and agents35 - Full CRUD for parameters (build config, project, and output parameters)36 - Queue management and server administration3738**Runtime Mode Switching (v2.1.0+):** Switch between modes at runtime using the `get_mcp_mode` and `set_mcp_mode` toolsβno restart required. MCP clients that support notifications will see the tool list update automatically.3940See the [Tools Mode Matrix](docs/mcp-tools-mode-matrix.md) for the complete list of 87 tools and their availability by mode.4142### π― Key Capabilities4344- Trigger and monitor builds, fetch logs, and inspect test failures45- Token-based authentication to TeamCity; sensitive values redacted in logs46- Modern architecture: simple, direct implementation with a singleton client47- Performance-conscious: fast startup with minimal overhead48- Clean codebase with clear module boundaries4950## Installation5152### Prerequisites5354- Node.js >= 20.10.0 (LTS versions 20, 22, 24 tested in CI)55- TeamCity Server 2020.1+ with REST API access56- TeamCity authentication token5758### Quick Start5960```bash61# Clone the repository62git clone https://github.com/Daghis/teamcity-mcp.git63cd teamcity-mcp6465# Install dependencies66npm install6768# Configure environment69cp .env.example .env70# Edit .env with your TeamCity URL and token7172# Run in development mode73npm run dev74```7576### npm Package7778Run the MCP server via npx (requires Node 20.x). Set your TeamCity environment variables inline or via a `.env` in the working directory.7980```bash81# One-off run (inline envs)82TEAMCITY_URL="https://teamcity.example.com" \83TEAMCITY_TOKEN="<your_token>" \84MCP_MODE=dev \85npx -y @daghis/teamcity-mcp8687# Or rely on .env in the current directory88npx -y @daghis/teamcity-mcp89```9091## Claude Code9293- Add the MCP (relying on `.env` for configuration):94 - `claude mcp add teamcity -- npx -y @daghis/teamcity-mcp`95- With env vars (if not using .env):96 - `claude mcp add teamcity -e TEAMCITY_URL="https://teamcity.example.com" -e TEAMCITY_TOKEN="tc_<your_token>" -- npx -y @daghis/teamcity-mcp`97- With CLI arguments (recommended for Windows):98 - `claude mcp add teamcity -- npx -y @daghis/teamcity-mcp --url "https://teamcity.example.com" --token "tc_<your_token>" --mode dev`99- Add `-s user` to install user-wide instead of project-scoped (default)100- Context usage (Opus 4.1, estimates):101 - Dev (default): ~14k tokens for MCP tools102 - Full (`MCP_MODE=full`): ~26k tokens for MCP tools103104### Windows Users105106On Windows, Claude Code's MCP configuration [may not properly merge environment variables](https://github.com/anthropics/claude-code/issues/1254). Use CLI arguments as a workaround:107108```json109{110 "mcpServers": {111 "teamcity": {112 "command": "npx",113 "args": ["-y", "@daghis/teamcity-mcp", "--url", "https://teamcity.example.com", "--token", "YOUR_TOKEN"]114 }115 }116}117```118119Or use a config file for better security (token not visible in process list):120121```json122{123 "mcpServers": {124 "teamcity": {125 "command": "npx",126 "args": ["-y", "@daghis/teamcity-mcp", "--config", "C:\\path\\to\\teamcity.env"]127 }128 }129}130```131132## Configuration133134Environment is validated centrally with Zod. Supported variables and defaults:135136```env137# Server Configuration138PORT=3000139NODE_ENV=development140LOG_LEVEL=info141142# TeamCity Configuration (aliases supported)143TEAMCITY_URL=https://teamcity.example.com144TEAMCITY_TOKEN=your-auth-token145# Optional aliases:146# TEAMCITY_SERVER_URL=...147# TEAMCITY_API_TOKEN=...148149# MCP Mode (dev or full)150MCP_MODE=dev151152# Optional advanced TeamCity options (defaults shown)153# Connection154# TEAMCITY_TIMEOUT=30000155# TEAMCITY_MAX_CONCURRENT=10156# TEAMCITY_KEEP_ALIVE=true157# TEAMCITY_COMPRESSION=true158159# Retry160# TEAMCITY_RETRY_ENABLED=true161# TEAMCITY_MAX_RETRIES=3162# TEAMCITY_RETRY_DELAY=1000163# TEAMCITY_MAX_RETRY_DELAY=30000164165# Pagination166# TEAMCITY_PAGE_SIZE=100167# TEAMCITY_MAX_PAGE_SIZE=1000168# TEAMCITY_AUTO_FETCH_ALL=false169170# Circuit Breaker171# TEAMCITY_CIRCUIT_BREAKER=true172# TEAMCITY_CB_FAILURE_THRESHOLD=5173# TEAMCITY_CB_RESET_TIMEOUT=60000174# TEAMCITY_CB_SUCCESS_THRESHOLD=2175```176177These values are normalized in `src/config/index.ts` and consumed by `src/teamcity/config.ts` via helper getters.178179## Usage Examples180181Once integrated with your AI coding assistant:182183```184"Build the frontend on feature branch"185"Why did last night's tests fail?"186"Deploy staging with the latest build"187"Create a new build config for the mobile app"188```189190### Tool Responses and Pagination191192- Responses: Tools now return consistent MCP content. For list/get operations, the `content[0].text` contains a JSON string. Example shape:193 `{ "items": [...], "pagination": { "page": 1, "pageSize": 100 } }` or `{ "items": [...], "pagination": { "mode": "all", "pageSize": 100, "fetched": 250 } }`.194- Pagination: Most list\_\* tools accept `pageSize`, `maxPages`, and `all`:195 - `pageSize` controls items per page.196 - `all: true` fetches multiple pages up to `maxPages`.197 - Legacy `count` on `list_builds` is kept for compatibility but `pageSize` is preferred.198199### Validation and Errors200201- Input validation: Tool inputs are validated with Zod schemas; invalid input returns a structured error payload in the response content (JSON string) with `success: false` and `error.code = VALIDATION_ERROR`.202- Error shaping: Errors are formatted consistently via a global handler. In production, messages may be sanitized; sensitive values (e.g., tokens) are redacted in logs.203204### API Usage205206```typescript207import { TeamCityAPI } from '@/api-client';208209// Get the API client instance210const api = TeamCityAPI.getInstance();211212// List projects213const projects = await api.listProjects();214215// Get build status216const build = await api.getBuild('BuildId123');217218// Trigger a new build219const newBuild = await api.triggerBuild('BuildConfigId', {220 branchName: 'main',221});222```223224> **Note:** The legacy helpers exported from `src/teamcity/index.ts` remain only for compatibility and include placeholder implementations. Prefer the MCP tools (see the reference linked above) or the `TeamCityAPI` shown here when automating workflows.225226## Development227228```bash229# Run tests230npm test231232# Run tests with coverage233npm run test:coverage234235# Lint code236npm run lint237238# Format code239npm run format240241# Type check242npm run typecheck243244# Build for production245npm run build246247# Analyze bundle for Codecov248npm run build:bundle249```250251### Bundle analysis in CI252253The CI workflow runs `npm run build:bundle` and uploads the generated `coverage/bundles` JSON using `codecov/codecov-action` with the `javascript-bundle` plugin.254255## Project Structure256257```258teamcity-mcp/259βββ src/ # Source code260β βββ tools.ts # All 87 MCP tool definitions261β βββ server.ts # MCP server setup262β βββ api-client.ts # TeamCity API singleton263β βββ config/ # Configuration with Zod validation264β βββ teamcity/ # Domain logic (build, agent, config managers)265β βββ teamcity-client/ # Auto-generated OpenAPI client266β βββ types/ # TypeScript type definitions267β βββ utils/ # Logger, MCP helpers, pagination268βββ tests/ # Unit and integration tests269βββ docs/ # Documentation270βββ scripts/ # Build and maintenance scripts271```272273## API Documentation274275The MCP server exposes tools for TeamCity operations. Each tool corresponds to specific TeamCity REST API endpoints:276277### Build Management278279- `TriggerBuild` - Queue a new build280- `GetBuildStatus` - Check build progress281- `FetchBuildLog` - Retrieve build logs282- `ListBuilds` - Search builds by criteria283284### Test Analysis285286- `ListTestFailures` - Get failing tests287- `GetTestDetails` - Detailed test information288- `AnalyzeBuildProblems` - Identify failure reasons289290### Configuration (Full Mode Only)291292- `create_build_config` - Create new TeamCity build configurations with full support for:293 - VCS roots (Git, SVN, Perforce) with authentication294 - Build steps (script, Maven, Gradle, npm, Docker, PowerShell)295 - Triggers (VCS, schedule, finish-build, maven-snapshot)296 - Parameters and template-based configurations297 - See the [MCP Tool Reference](docs/mcp-tools-reference.md) for argument details and additional options.298- `clone_build_config` - Duplicate existing configurations into any project, preserving steps, triggers, and parameters.299- `update_build_config` - Adjust names, descriptions, artifact rules, and pause state for a configuration.300- `manage_build_steps` - Add, update, remove, or reorder build steps through a single tool surface.301- `manage_build_triggers` - Add or delete build triggers with full property support.302- `create_vcs_root` & `add_vcs_root_to_build` - Define VCS roots and attach them to build configurations.303304See also: [`docs/TEAMCITY_MCP_TOOLS_GUIDE.md`](docs/TEAMCITY_MCP_TOOLS_GUIDE.md) for expanded workflows and examples that align with the current MCP implementation.305306## Contributing307308We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for details.309310## Security311312### Token Management313314- Configure `TEAMCITY_TOKEN` via environment variable or config file (see `.env.example`); never commit real tokens315- Use a token with minimal required permissions; read-only tokens work for most Dev mode operations316- Token-based authentication only; the MCP server does not support username/password317- Logs redact sensitive values including tokens318319### Mode Selection320321- Prefer **Dev mode** unless Full mode is explicitly neededβthis limits the blast radius of any misconfiguration or prompt injection322- Full mode enables destructive operations (project deletion, agent management) that cannot be easily undone323324### Network Security325326- Always use HTTPS for TeamCity connections; the server does not enforce this but strongly recommends it327- The MCP server connects only to the configured TeamCity URL; no other network calls are made328329### AI Assistant Considerations330331- AI assistants could be manipulated via prompt injection in build logs, test output, or other TeamCity data332- Dev mode's limited tool set reduces the impact of such attacks333- All actions appear in TeamCity's audit log under the token's associated user334- Build logs and test failure details may contain sensitive information (secrets, paths, internal URLs) that become visible to the AI assistant335336### Repository Security337338This repository has GitHub secret scanning and push protection enabled. See [SECURITY.md](SECURITY.md) for vulnerability reporting.339340## Support341342- GitHub Issues: [Report bugs or request features](https://github.com/Daghis/teamcity-mcp/issues)343- Documentation: See the `docs/` folder in this repository344345## Acknowledgments346347- JetBrains TeamCity for the excellent CI/CD platform348- Anthropic for the Model Control Protocol specification349- The open-source community for continuous support350- See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) for third-party licenses351352---353354Built with β€οΈ for developers who love efficient CI/CD workflows
Full transparency β inspect the skill content before installing.