list_projects
Retrieve TeamCity projects with filtering and pagination options to manage CI/CD workflows and build configurations.
Instructions
List TeamCity projects (supports pagination)
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| locator | No | Optional locator to filter projects | |
| parentProjectId | No | Filter by parent project ID | |
| pageSize | No | Items per page (default 100) | |
| maxPages | No | Max pages to fetch (when all=true) | |
| all | No | Fetch all pages up to maxPages | |
| fields | No | Optional fields selector for server-side projection |
Implementation Reference
- Core handler function that implements project listing logic: builds TeamCity locator from params, calls API, transforms response, computes pagination metadata. Matches tool usage patterns with locator building and pagination.async listProjects(params: ProjectListParams = {}): Promise<ProjectListResult> { const { name, archived, parentProjectId, includeHierarchy = false, limit = 100, offset = 0, } = params; // Build TeamCity locator string const locator = this.buildLocator({ name, archived, parentProjectId, offset, limit, }); try { // Call TeamCity API const response = await this.client.modules.projects.getAllProjects( locator, this.buildFieldsString(includeHierarchy) ); // Extract data from AxiosResponse const projectsData = response.data; // Transform response to our format const projects = this.transformProjects(projectsData, includeHierarchy); // Build metadata const metadata = { count: projects.length, offset, limit, hasMore: this.hasMoreResults(projectsData, limit), totalCount: projectsData.count, }; return { projects, metadata }; } catch (error) { throw this.handleApiError(error); } }
- src/types/project.ts:84-128 (schema)Type definitions for tool input (ProjectListParams) and output (ProjectListResult), used directly by the handler for validation and structure.export interface ProjectListParams { /** Filter by project name (supports wildcards) */ name?: string; /** Filter by archived status */ archived?: boolean; /** Filter by parent project ID */ parentProjectId?: string; /** Include hierarchy information */ includeHierarchy?: boolean; /** Pagination: number of results to return */ limit?: number; /** Pagination: offset for results */ offset?: number; } /** * Result of a project list operation */ export interface ProjectListResult { /** List of projects matching the criteria */ projects: ProjectInfo[]; /** Metadata about the result set */ metadata: { /** Number of projects in this response */ count: number; /** Offset used for this query */ offset: number; /** Limit used for this query */ limit: number; /** Whether more results are available */ hasMore: boolean; /** Total count of matching projects (if available) */ totalCount?: number; }; }
- Adapter mapping that exposes listProjects method on the unified client interface, bridging to the underlying API.listProjects: (locator) => api.listProjects(locator),
- src/api-client.ts:289-291 (helper)Low-level API wrapper that calls TeamCity's getAllProjects endpoint with optional locator, returns raw response data.async listProjects(locator?: string) { const response = await this.projects.getAllProjects(locator); return response.data;