KosmoKrator

productivity

TeamCity Lua API for KosmoKrator Agents

Agent-facing Lua documentation and function reference for the TeamCity KosmoKrator integration.

Lua Namespace

Agents call this integration through app.integrations.teamcity.*. Use lua_read_doc("integrations.teamcity") inside KosmoKrator to discover the same reference at runtime.

Call Lua from the Headless CLI

Use kosmo integrations:lua when a shell script, CI job, cron job, or another coding CLI should run a deterministic TeamCity workflow without starting an interactive agent session.

Inline Lua call
kosmo integrations:lua --eval 'dump(app.integrations.teamcity.get_server_info({}))' --json
Read Lua docs headlessly
kosmo integrations:lua --eval 'print(docs.read("teamcity"))' --json
kosmo integrations:lua --eval 'print(docs.read("teamcity.get_server_info"))' --json

Workflow file

Put repeatable logic in a Lua file, then execute it with JSON output for the calling process.

workflow.lua
local teamcity = app.integrations.teamcity
local result = teamcity.get_server_info({})

dump(result)
Run the workflow
kosmo integrations:lua workflow.lua --json
kosmo integrations:lua workflow.lua --force --json
Namespace note. integrations:lua exposes app.integrations.teamcity, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.teamcity.default.* or app.integrations.teamcity.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need TeamCity, use the narrower mcp:lua command.

MCP Lua command
# Use mcp:lua for MCP-only scripts; use integrations:lua for this integration namespace.
kosmo mcp:lua --eval 'dump(mcp.servers())' --json

Agent-Facing Lua Docs

This is the rendered version of the full Lua documentation exposed to agents when they inspect the integration namespace.

TeamCity

TeamCity tools are available under app.integrations.teamcity.

Use this integration to inspect TeamCity projects, build configurations, builds, queue state, agents, users, groups, investigations, problems, changes, and VCS roots. The integration talks to the TeamCity REST API under /app/rest, sends JSON Accept and Content-Type headers, and uses bearer-token authentication.

Common Patterns

Get server details:

local server = app.integrations.teamcity.teamcity_get_server_info({})

List recent failed builds:

local builds = app.integrations.teamcity.teamcity_list_builds({
  locator = "status:FAILURE,count:10",
  fields = "build(id,number,status,state,webUrl,buildTypeId)"
})

Trigger a build:

local queued = app.integrations.teamcity.teamcity_queue_build({
  payload = {
    buildType = { id = "Project_Build" },
    branchName = "main"
  }
})

Cancel a running build:

app.integrations.teamcity.teamcity_cancel_build({
  locator = "id:12345",
  payload = {
    comment = "Canceled by automation",
    readdIntoQueue = false
  }
})

Pause the build queue:

app.integrations.teamcity.teamcity_set_queue_paused({
  paused = true,
  reason = "Maintenance window"
})

Locator Notes

TeamCity uses locators heavily. Prefer explicit locators such as id:ProjectId, id:BuildTypeId, id:12345, username:ada, or compound build locators like buildType:id:Project_Build,status:SUCCESS,count:20.

For list tools, locator is sent as the TeamCity query parameter. For get, cancel, delete, artifact, statistics, tag, pin, agent, and user tools, locator is used as the path locator.

Raw API Helpers

Use raw helpers only when a named tool does not cover the endpoint:

local result = app.integrations.teamcity.teamcity_api_get({
  path = "/projects",
  query = { fields = "project(id,name,href)" }
})

Raw paths must be relative. /app/rest/projects and /projects are both accepted; full external URLs are rejected.

Response Shape

JSON responses are returned as TeamCity provides them. Empty successful responses return { success = true }. Plain text responses return { value = "..." }.

Safety

  • All examples use fake project and build IDs.
  • Tool access depends on the permissions granted to the TeamCity token.
  • Destructive operations such as deleting projects or builds should use explicit locators.
  • Some TeamCity deployments restrict endpoints by server version, license, plugin availability, or project permissions. Use teamcity_api_get for newer long-tail endpoints when a named tool is not available.
Raw agent markdown
# TeamCity

TeamCity tools are available under `app.integrations.teamcity`.

Use this integration to inspect TeamCity projects, build configurations, builds, queue state, agents, users, groups, investigations, problems, changes, and VCS roots. The integration talks to the TeamCity REST API under `/app/rest`, sends JSON `Accept` and `Content-Type` headers, and uses bearer-token authentication.

## Common Patterns

Get server details:

```lua
local server = app.integrations.teamcity.teamcity_get_server_info({})
```

List recent failed builds:

```lua
local builds = app.integrations.teamcity.teamcity_list_builds({
  locator = "status:FAILURE,count:10",
  fields = "build(id,number,status,state,webUrl,buildTypeId)"
})
```

Trigger a build:

```lua
local queued = app.integrations.teamcity.teamcity_queue_build({
  payload = {
    buildType = { id = "Project_Build" },
    branchName = "main"
  }
})
```

Cancel a running build:

```lua
app.integrations.teamcity.teamcity_cancel_build({
  locator = "id:12345",
  payload = {
    comment = "Canceled by automation",
    readdIntoQueue = false
  }
})
```

Pause the build queue:

```lua
app.integrations.teamcity.teamcity_set_queue_paused({
  paused = true,
  reason = "Maintenance window"
})
```

## Locator Notes

TeamCity uses locators heavily. Prefer explicit locators such as `id:ProjectId`, `id:BuildTypeId`, `id:12345`, `username:ada`, or compound build locators like `buildType:id:Project_Build,status:SUCCESS,count:20`.

For list tools, `locator` is sent as the TeamCity query parameter. For get, cancel, delete, artifact, statistics, tag, pin, agent, and user tools, `locator` is used as the path locator.

## Raw API Helpers

Use raw helpers only when a named tool does not cover the endpoint:

```lua
local result = app.integrations.teamcity.teamcity_api_get({
  path = "/projects",
  query = { fields = "project(id,name,href)" }
})
```

Raw paths must be relative. `/app/rest/projects` and `/projects` are both accepted; full external URLs are rejected.

## Response Shape

JSON responses are returned as TeamCity provides them. Empty successful responses return `{ success = true }`. Plain text responses return `{ value = "..." }`.

## Safety

- All examples use fake project and build IDs.
- Tool access depends on the permissions granted to the TeamCity token.
- Destructive operations such as deleting projects or builds should use explicit locators.
- Some TeamCity deployments restrict endpoints by server version, license, plugin availability, or project permissions. Use `teamcity_api_get` for newer long-tail endpoints when a named tool is not available.
Metadata-derived Lua example
local result = app.integrations.teamcity.get_server_info({})
print(result)

Functions

get_server_info Read

Get TeamCity server details.

Lua path
app.integrations.teamcity.get_server_info
Full name
teamcity.teamcity_get_server_info
ParameterTypeRequiredDescription
No parameters.
list_projects Read

List TeamCity projects.

Lua path
app.integrations.teamcity.list_projects
Full name
teamcity.teamcity_list_projects
ParameterTypeRequiredDescription
No parameters.
get_project Read

Get one project by locator.

Lua path
app.integrations.teamcity.get_project
Full name
teamcity.teamcity_get_project
ParameterTypeRequiredDescription
No parameters.
create_project Write

Create a TeamCity project.

Lua path
app.integrations.teamcity.create_project
Full name
teamcity.teamcity_create_project
ParameterTypeRequiredDescription
No parameters.
delete_project Write

Delete a TeamCity project.

Lua path
app.integrations.teamcity.delete_project
Full name
teamcity.teamcity_delete_project
ParameterTypeRequiredDescription
No parameters.
list_build_types Read

List build configurations.

Lua path
app.integrations.teamcity.list_build_types
Full name
teamcity.teamcity_list_build_types
ParameterTypeRequiredDescription
No parameters.
get_build_type Read

Get one build configuration.

Lua path
app.integrations.teamcity.get_build_type
Full name
teamcity.teamcity_get_build_type
ParameterTypeRequiredDescription
No parameters.
list_build_type_builds Read

List builds for one build configuration.

Lua path
app.integrations.teamcity.list_build_type_builds
Full name
teamcity.teamcity_list_build_type_builds
ParameterTypeRequiredDescription
No parameters.
list_builds Read

List builds by locator.

Lua path
app.integrations.teamcity.list_builds
Full name
teamcity.teamcity_list_builds
ParameterTypeRequiredDescription
No parameters.
get_build Read

Get one build by locator.

Lua path
app.integrations.teamcity.get_build
Full name
teamcity.teamcity_get_build
ParameterTypeRequiredDescription
No parameters.
queue_build Write

Add a build to the queue.

Lua path
app.integrations.teamcity.queue_build
Full name
teamcity.teamcity_queue_build
ParameterTypeRequiredDescription
No parameters.
cancel_queued_build Write

Cancel a queued build by locator.

Lua path
app.integrations.teamcity.cancel_queued_build
Full name
teamcity.teamcity_cancel_queued_build
ParameterTypeRequiredDescription
No parameters.
cancel_build Write

Cancel a started build by locator.

Lua path
app.integrations.teamcity.cancel_build
Full name
teamcity.teamcity_cancel_build
ParameterTypeRequiredDescription
No parameters.
delete_build Write

Delete build metadata by locator.

Lua path
app.integrations.teamcity.delete_build
Full name
teamcity.teamcity_delete_build
ParameterTypeRequiredDescription
No parameters.
list_build_artifacts Read

List artifact files for a build.

Lua path
app.integrations.teamcity.list_build_artifacts
Full name
teamcity.teamcity_list_build_artifacts
ParameterTypeRequiredDescription
No parameters.
get_build_statistics Read

Get statistical values for a build.

Lua path
app.integrations.teamcity.get_build_statistics
Full name
teamcity.teamcity_get_build_statistics
ParameterTypeRequiredDescription
No parameters.
get_build_tags Read

Get tags for a build.

Lua path
app.integrations.teamcity.get_build_tags
Full name
teamcity.teamcity_get_build_tags
ParameterTypeRequiredDescription
No parameters.
add_build_tags Write

Add tags to a build.

Lua path
app.integrations.teamcity.add_build_tags
Full name
teamcity.teamcity_add_build_tags
ParameterTypeRequiredDescription
No parameters.
set_build_pin_info Write

Pin or unpin a build.

Lua path
app.integrations.teamcity.set_build_pin_info
Full name
teamcity.teamcity_set_build_pin_info
ParameterTypeRequiredDescription
No parameters.
list_build_queue Read

List queued builds.

Lua path
app.integrations.teamcity.list_build_queue
Full name
teamcity.teamcity_list_build_queue
ParameterTypeRequiredDescription
No parameters.
set_queue_paused Write

Pause or resume the build queue.

Lua path
app.integrations.teamcity.set_queue_paused
Full name
teamcity.teamcity_set_queue_paused
ParameterTypeRequiredDescription
No parameters.
list_agents Read

List build agents.

Lua path
app.integrations.teamcity.list_agents
Full name
teamcity.teamcity_list_agents
ParameterTypeRequiredDescription
No parameters.
get_agent Read

Get one build agent by locator.

Lua path
app.integrations.teamcity.get_agent
Full name
teamcity.teamcity_get_agent
ParameterTypeRequiredDescription
No parameters.
list_users Read

List TeamCity users.

Lua path
app.integrations.teamcity.list_users
Full name
teamcity.teamcity_list_users
ParameterTypeRequiredDescription
No parameters.
get_user Read

Get one user by locator.

Lua path
app.integrations.teamcity.get_user
Full name
teamcity.teamcity_get_user
ParameterTypeRequiredDescription
No parameters.
list_groups Read

List user groups.

Lua path
app.integrations.teamcity.list_groups
Full name
teamcity.teamcity_list_groups
ParameterTypeRequiredDescription
No parameters.
list_investigations Read

List investigations.

Lua path
app.integrations.teamcity.list_investigations
Full name
teamcity.teamcity_list_investigations
ParameterTypeRequiredDescription
No parameters.
list_problems Read

List build problems.

Lua path
app.integrations.teamcity.list_problems
Full name
teamcity.teamcity_list_problems
ParameterTypeRequiredDescription
No parameters.
list_changes Read

List VCS changes.

Lua path
app.integrations.teamcity.list_changes
Full name
teamcity.teamcity_list_changes
ParameterTypeRequiredDescription
No parameters.
list_vcs_roots Read

List VCS roots.

Lua path
app.integrations.teamcity.list_vcs_roots
Full name
teamcity.teamcity_list_vcs_roots
ParameterTypeRequiredDescription
No parameters.
api_get Read

Call a safe relative TeamCity GET path.

Lua path
app.integrations.teamcity.api_get
Full name
teamcity.teamcity_api_get
ParameterTypeRequiredDescription
No parameters.
api_post Write

Call a safe relative TeamCity POST path.

Lua path
app.integrations.teamcity.api_post
Full name
teamcity.teamcity_api_post
ParameterTypeRequiredDescription
No parameters.
api_put Write

Call a safe relative TeamCity PUT path.

Lua path
app.integrations.teamcity.api_put
Full name
teamcity.teamcity_api_put
ParameterTypeRequiredDescription
No parameters.
api_patch Write

Call a safe relative TeamCity PATCH path.

Lua path
app.integrations.teamcity.api_patch
Full name
teamcity.teamcity_api_patch
ParameterTypeRequiredDescription
No parameters.
api_delete Write

Call a safe relative TeamCity DELETE path.

Lua path
app.integrations.teamcity.api_delete
Full name
teamcity.teamcity_api_delete
ParameterTypeRequiredDescription
No parameters.