@daghis/teamcity-mcp

中文文档
2.12.15发布于 2026/11/07MITTypeScriptCommonJS构建来源已验证近 30 天下载 1万

Model Control Protocol server for TeamCity CI/CD integration with AI coding assistants

原始使用文档
文档目录32 节
  1. Overview
  2. Features
  3. 🚀 Two Operational Modes
  4. 🎯 Key Capabilities
  5. How this compares to JetBrains' official tooling
  6. Installation
  7. Prerequisites
  8. Quick Start
  9. npm Package
  10. Claude Code
  11. Windows Users
  12. Configuration
  13. Usage Examples
  14. Tool Responses and Pagination
  15. Validation and Errors
  16. API Usage
  17. Development
  18. Bundle analysis in CI
  19. Project Structure
  20. API Documentation
  21. Build Management
  22. Test Analysis
  23. Configuration (Full Mode Only)
  24. Contributing
  25. Security
  26. Token Management
  27. Mode Selection
  28. Network Security
  29. AI Assistant Considerations
  30. Repository Security
  31. Support
  32. Acknowledgments

TeamCity MCP Server

CI CodeQL codecov License: MIT

A Model Control Protocol (MCP) server that bridges AI coding assistants with JetBrains TeamCity CI/CD server, exposing TeamCity operations as MCP tools.

TeamCity Server MCP server

[!NOTE] Project status (October 2026): stable, low-key maintenance. This does what it set out to do and is no longer under active development. It still works and stays installable; issues and PRs may get slow or no response, and security fixes are best-effort.

JetBrains now ships official AI integration for TeamCity — an MCP server built into TeamCity 2026.1+ and the TeamCity CLI with an installable agent skill — which is the better default for most workflows. See How this compares to JetBrains' official tooling below before adopting.

Overview

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.

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 for details.

Features

🚀 Two Operational Modes

  • Dev Mode (default): Safe CI/CD operations (31 tools, ~14k context tokens)

    • Trigger builds and monitor status
    • Fetch build logs and inspect test failures
    • List projects, configurations, and queue
    • Read parameters and investigate problems
  • Full Mode: Complete infrastructure management (87 tools, ~26k context tokens)

    • All Dev mode features, plus:
    • Create and clone build configurations
    • Manage build steps, triggers, and dependencies
    • Configure VCS roots and agents
    • Full CRUD for parameters (build config, project, and output parameters)
    • Queue management and server administration

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.

See the Tools Mode Matrix for the complete list of 87 tools and their availability by mode.

🎯 Key Capabilities

  • Trigger and monitor builds, fetch logs, and inspect test failures
  • Token-based authentication to TeamCity; sensitive values redacted in logs
  • Modern architecture: simple, direct implementation with a singleton client
  • Performance-conscious: fast startup with minimal overhead
  • Clean codebase with clear module boundaries

How this compares to JetBrains' official tooling

As of October 2026 (TeamCity 2026.2, TeamCity CLI 1.6), JetBrains ships two first-party paths for AI agents, both generally available and officially supported:

  • Built-in MCP server — every TeamCity 2026.1+ server (Cloud and On-Premises) exposes an MCP endpoint at <server-url>/app/mcp, so there's nothing to install. It's a deliberately small toolset: build logs, generic REST API GET/POST passthrough tools, and (since 2026.2) pipeline tools. By default it runs in a safe mode where the agent can read and queue personal builds; an opt-in "brave mode" lets it send arbitrary REST POST requests and edit or delete pipelines. Since 2026.2 you can also sign in with OAuth instead of pasting an access token.
  • TeamCity CLI — an open-source teamcity command (TeamCity 2020.1+) with an installable agent skill (teamcity skill install) for Claude Code, Cursor, and other agents. It covers runs, logs, tests, the queue, agents, pools, projects, VCS roots, parameters, and pipelines, falls back to raw REST access via teamcity api, and has a read-only mode (TEAMCITY_RO=1). JetBrains' own docs describe it as the broader of the two options.

teamcity-mcp predates that tooling and overlaps with it heavily. The official tooling is the better default today. What teamcity-mcp still offers is narrower than it used to be:

  • An MCP server for servers older than 2026.1. If your client speaks only MCP and your TeamCity server predates the built-in endpoint, this still works (TeamCity 2020.1+).
  • Purpose-built MCP tools instead of a REST passthrough. It exposes 87 typed tools (gated by Dev/Full mode), so the agent doesn't need to know REST paths and locators — and it covers operations backed by PUT/DELETE (such as enabling agents or deleting parameters), which the built-in MCP's generic GET/POST tools don't reach.

JetBrains' tooling is evolving quickly, so rather than pin down a feature-by-feature comparison here (it would go stale fast), check the current docs and pick what fits:

If you're comfortable with JetBrains' CLI, you may not need this project at all. It stays MIT-licensed and installable for whatever the built-ins don't yet reach — fork it if you want to take it further yourself.

Installation

Prerequisites

  • Node.js >= 20.10.0 (LTS versions 20, 22, 24 tested in CI)
  • TeamCity Server 2020.1+ with REST API access
  • TeamCity authentication token

Quick Start

# Clone the repository
git clone https://github.com/Daghis/teamcity-mcp.git
cd teamcity-mcp

# Install dependencies
npm install

# Configure environment
cp .env.example .env
# Edit .env with your TeamCity URL and token

# Run in development mode
npm run dev

npm Package

Run the MCP server via npx (requires Node 20.x). Set your TeamCity environment variables inline or via a .env in the working directory.

# One-off run (inline envs)
TEAMCITY_URL="https://teamcity.example.com" \
TEAMCITY_TOKEN="<your_token>" \
MCP_MODE=dev \
npx -y @daghis/teamcity-mcp

# Or rely on .env in the current directory
npx -y @daghis/teamcity-mcp

Claude Code

  • Add the MCP (relying on .env for configuration):
    • claude mcp add teamcity -- npx -y @daghis/teamcity-mcp
  • With env vars (if not using .env):
    • claude mcp add teamcity -e TEAMCITY_URL="https://teamcity.example.com" -e TEAMCITY_TOKEN="tc_<your_token>" -- npx -y @daghis/teamcity-mcp
  • With CLI arguments (recommended for Windows):
    • claude mcp add teamcity -- npx -y @daghis/teamcity-mcp --url "https://teamcity.example.com" --token "tc_<your_token>" --mode dev
  • Add -s user to install user-wide instead of project-scoped (default)
  • Context usage (Opus 4.1, estimates):
    • Dev (default): ~14k tokens for MCP tools
    • Full (MCP_MODE=full): ~26k tokens for MCP tools

Windows Users

On Windows, Claude Code's MCP configuration may not properly merge environment variables. Use CLI arguments as a workaround:

{
  "mcpServers": {
    "teamcity": {
      "command": "npx",
      "args": [
        "-y",
        "@daghis/teamcity-mcp",
        "--url",
        "https://teamcity.example.com",
        "--token",
        "YOUR_TOKEN"
      ]
    }
  }
}

Or use a config file for better security (token not visible in process list):

{
  "mcpServers": {
    "teamcity": {
      "command": "npx",
      "args": ["-y", "@daghis/teamcity-mcp", "--config", "C:\\path\\to\\teamcity.env"]
    }
  }
}

Configuration

Environment is validated centrally with Zod. Supported variables and defaults:

# Server Configuration
PORT=3000
NODE_ENV=development
LOG_LEVEL=info

# TeamCity Configuration (aliases supported)
TEAMCITY_URL=https://teamcity.example.com
TEAMCITY_TOKEN=your-auth-token
# Optional aliases:
# TEAMCITY_SERVER_URL=...
# TEAMCITY_API_TOKEN=...

# MCP Mode (dev or full)
MCP_MODE=dev

# Optional advanced TeamCity options (defaults shown)
# Connection
# TEAMCITY_TIMEOUT=30000
# TEAMCITY_MAX_CONCURRENT=10
# TEAMCITY_KEEP_ALIVE=true
# TEAMCITY_COMPRESSION=true

# Extra headers attached to every TeamCity request — useful when TeamCity
# sits behind a reverse proxy that gates access on custom headers (e.g.
# Cloudflare Zero Trust service tokens). One env var per header; the part
# after `TEAMCITY_HEADER_` is used verbatim as the HTTP header name.
# Example (note the literal hyphens — most shells need quoting):
# TEAMCITY_HEADER_CF-Access-Client-Id=<id>
# TEAMCITY_HEADER_CF-Access-Client-Secret=<secret>

# Retry
# TEAMCITY_RETRY_ENABLED=true
# TEAMCITY_MAX_RETRIES=3
# TEAMCITY_RETRY_DELAY=1000
# TEAMCITY_MAX_RETRY_DELAY=30000

# Pagination
# TEAMCITY_PAGE_SIZE=100
# TEAMCITY_MAX_PAGE_SIZE=1000
# TEAMCITY_AUTO_FETCH_ALL=false

# Circuit Breaker
# TEAMCITY_CIRCUIT_BREAKER=true
# TEAMCITY_CB_FAILURE_THRESHOLD=5
# TEAMCITY_CB_RESET_TIMEOUT=60000
# TEAMCITY_CB_SUCCESS_THRESHOLD=2

These values are normalized in src/config/index.ts and consumed by src/teamcity/config.ts via helper getters.

Usage Examples

Once integrated with your AI coding assistant:

"Build the frontend on feature branch"
"Why did last night's tests fail?"
"Deploy staging with the latest build"
"Create a new build config for the mobile app"

Tool Responses and Pagination

  • Responses: Tools now return consistent MCP content. For list/get operations, the content[0].text contains a JSON string. Example shape: { "items": [...], "pagination": { "page": 1, "pageSize": 100 } } or { "items": [...], "pagination": { "mode": "all", "pageSize": 100, "fetched": 250 } }.
  • Pagination: Most list_* tools accept pageSize, maxPages, and all:
    • pageSize controls items per page.
    • all: true fetches multiple pages up to maxPages.
    • Legacy count on list_builds is kept for compatibility but pageSize is preferred.

Validation and Errors

  • 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.
  • 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.

API Usage

import { TeamCityAPI } from '@/api-client';

// Get the API client instance
const api = TeamCityAPI.getInstance();

// List projects
const projects = await api.listProjects();

// Get build status
const build = await api.getBuild('BuildId123');

// Trigger a new build
const newBuild = await api.triggerBuild('BuildConfigId', {
  branchName: 'main',
});

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.

Development

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Lint code
npm run lint

# Format code
npm run format

# Type check
npm run typecheck

# Build for production
npm run build

# Analyze bundle for Codecov
npm run build:bundle

Bundle analysis in CI

The CI workflow runs npm run build:bundle and uploads the generated coverage/bundles JSON using codecov/codecov-action with the javascript-bundle plugin.

Project Structure

teamcity-mcp/
├── src/                    # Source code
│   ├── tools.ts           # All 87 MCP tool definitions
│   ├── server.ts          # MCP server setup
│   ├── api-client.ts      # TeamCity API singleton
│   ├── config/            # Configuration with Zod validation
│   ├── teamcity/          # Domain logic (build, agent, config managers)
│   ├── teamcity-client/   # Auto-generated OpenAPI client
│   ├── types/             # TypeScript type definitions
│   └── utils/             # Logger, MCP helpers, pagination
├── tests/                  # Unit and integration tests
├── docs/                   # Documentation
└── scripts/                # Build and maintenance scripts

API Documentation

The MCP server exposes tools for TeamCity operations. Each tool corresponds to specific TeamCity REST API endpoints:

Build Management

  • TriggerBuild - Queue a new build
  • GetBuildStatus - Check build progress
  • FetchBuildLog - Retrieve build logs
  • ListBuilds - Search builds by criteria

Test Analysis

  • ListTestFailures - Get failing tests
  • GetTestDetails - Detailed test information
  • AnalyzeBuildProblems - Identify failure reasons

Configuration (Full Mode Only)

  • create_build_config - Create new TeamCity build configurations with full support for:
    • VCS roots (Git, SVN, Perforce) with authentication
    • Build steps (script, Maven, Gradle, npm, Docker, PowerShell)
    • Triggers (VCS, schedule, finish-build, maven-snapshot)
    • Parameters and template-based configurations
    • See the MCP Tool Reference for argument details and additional options.
  • clone_build_config - Duplicate existing configurations into any project, preserving steps, triggers, and parameters.
  • update_build_config - Adjust names, descriptions, artifact rules, and pause state for a configuration.
  • manage_build_steps - Add, update, remove, or reorder build steps through a single tool surface.
  • manage_build_triggers - Add or delete build triggers with full property support.
  • create_vcs_root & add_vcs_root_to_build - Define VCS roots and attach them to build configurations.

See also: docs/TEAMCITY_MCP_TOOLS_GUIDE.md for expanded workflows and examples that align with the current MCP implementation.

Contributing

We welcome contributions! Please see CONTRIBUTING.md for details.

Security

Token Management

  • Configure TEAMCITY_TOKEN via environment variable or config file (see .env.example); never commit real tokens
  • Use a token with minimal required permissions; read-only tokens work for most Dev mode operations
  • Token-based authentication only; the MCP server does not support username/password
  • Logs redact sensitive values including tokens

Mode Selection

  • Prefer Dev mode unless Full mode is explicitly needed—this limits the blast radius of any misconfiguration or prompt injection
  • Full mode enables destructive operations (project deletion, agent management) that cannot be easily undone

Network Security

  • Always use HTTPS for TeamCity connections; the server does not enforce this but strongly recommends it
  • The MCP server connects only to the configured TeamCity URL; no other network calls are made

AI Assistant Considerations

  • AI assistants could be manipulated via prompt injection in build logs, test output, or other TeamCity data
  • Dev mode's limited tool set reduces the impact of such attacks
  • All actions appear in TeamCity's audit log under the token's associated user
  • Build logs and test failure details may contain sensitive information (secrets, paths, internal URLs) that become visible to the AI assistant

Repository Security

This repository has GitHub secret scanning and push protection enabled. See SECURITY.md for vulnerability reporting.

Support

Acknowledgments

  • JetBrains TeamCity for the excellent CI/CD platform
  • Anthropic for the Model Control Protocol specification
  • The open-source community for continuous support
  • See THIRD_PARTY_NOTICES.md for third-party licenses

Built with ❤️ for developers who love efficient CI/CD workflows

版本与发布记录

@daghis/teamcity-mcp 共发布 120 个版本,首次发布于 2025/09/12;过去 12 个月发布了 71 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.12.15latest2026/11/074 天前
2.12.142026/11/074 天前
2.12.132026/11/064 天前
2.12.122026/10/2913 天前
2.12.112026/10/2813 天前
2.12.102026/10/2120 天前

关于 @daghis/teamcity-mcp 的常见问题

@daghis/teamcity-mcp 是什么?

Model Control Protocol server for TeamCity CI/CD integration with AI coding assistants

如何安装 @daghis/teamcity-mcp?

在项目目录运行 npm install @daghis/teamcity-mcp,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 teamcity-mcp,可以用 npx teamcity-mcp 直接运行。

@daghis/teamcity-mcp 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@daghis/teamcity-mcp 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@daghis/teamcity-mcp 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=20.19.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@daghis/teamcity-mcp 可以商用吗?

@daghis/teamcity-mcp 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@daghis/teamcity-mcp 的下载量有多少?

根据 npm 官方下载统计,@daghis/teamcity-mcp 在 2026/10/11 – 2026/11/09 这 30 天内被下载 10,295 次,日均约 343 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@daghis/teamcity-mcp 还在维护吗?

最新版本 2.12.15 发布于 2026/11/07(4 天前);至今共发布 120 个版本,其中过去 12 个月发布了 71 个;首次发布于 2025/09/12。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。