KosmoKrator

data

Railway Lua API for KosmoKrator Agents

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

Lua Namespace

Agents call this integration through app.integrations.railway.*. Use lua_read_doc("integrations.railway") 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 Railway workflow without starting an interactive agent session.

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

Workflow file

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

workflow.lua
local railway = app.integrations.railway
local result = railway.list_projects({})

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.railway, app.mcp.*, docs.*, json.*, and regex.*. Use app.integrations.railway.default.* or app.integrations.railway.work.* when you configured named credential accounts.

MCP-only Lua

If the script only needs configured MCP servers and does not need Railway, 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.

Railway — Lua API Reference

Railway tools use the public GraphQL API with a stored account or workspace bearer token. The integration returns normalized project, service, deployment, and user fields instead of raw GraphQL envelopes.

list_projects

List all Railway projects the authenticated user has access to.

Parameters

This tool takes no parameters.

Examples

local result = app.integrations.railway.list_projects({})

for _, project in ipairs(result.projects) do
  print(project.id .. ": " .. project.name)
  if project.description then
    print("  Description: " .. project.description)
  end
  if project.team then
    print("  Team: " .. project.team)
  end
  print("  Public: " .. tostring(project.is_public))
end

get_project

Get detailed information about a specific Railway project, including environments and plugins.

Parameters

NameTypeRequiredDescription
project_idstringyesThe Railway project ID

Examples

local result = app.integrations.railway.get_project({
  project_id = "clx123abc456"
})

print("Project: " .. result.name)
print("Description: " .. (result.description or "N/A"))
print("Environments: " .. result.environment_count)

for _, env in ipairs(result.environments) do
  print("  " .. env.name .. " (ephemeral: " .. tostring(env.is_ephemeral) .. ")")
end

print("Plugins: " .. result.plugin_count)
for _, plugin in ipairs(result.plugins) do
  print("  " .. plugin.name)
end

create_project

Create a new Railway project.

Parameters

NameTypeRequiredDescription
namestringyesThe name for the new project
descriptionstringnoAn optional description for the project

Examples

-- Create a project with a name only
local result = app.integrations.railway.create_project({
  name = "My New App"
})
print(result.message)
print("Project ID: " .. result.id)

-- Create a project with a description
local result = app.integrations.railway.create_project({
  name = "My Backend Service",
  description = "Production backend API deployed on Railway"
})
print(result.message)

list_services

List all services in a Railway project.

Parameters

NameTypeRequiredDescription
project_idstringyesThe Railway project ID

Examples

local result = app.integrations.railway.list_services({
  project_id = "clx123abc456"
})

print("Services: " .. result.count)
for _, service in ipairs(result.services) do
  print("  " .. service.id .. ": " .. service.name)
  if service.repo_name then
    print("    Repo: " .. service.repo_name)
  end
end

get_service

Get detailed information about a specific Railway service.

Parameters

NameTypeRequiredDescription
service_idstringyesThe Railway service ID

Examples

local result = app.integrations.railway.get_service({
  service_id = "clx789xyz012"
})

print("Service: " .. result.name)
print("Forked: " .. tostring(result.is_forked))

if result.repo.full_name then
  print("Repo: " .. result.repo.full_name)
  print("Branch: " .. (result.repo.branch or "default"))
end

list_deployments

List deployments for a Railway service.

Parameters

NameTypeRequiredDescription
service_idstringyesThe Railway service ID
environment_idstringnoFilter deployments by environment ID
limitintegernoMax deployments to return (default: 20)

Examples

-- List recent deployments for a service
local result = app.integrations.railway.list_deployments({
  service_id = "clx789xyz012"
})

for _, dep in ipairs(result.deployments) do
  print(dep.id .. " [" .. dep.status .. "]")
  print("  Environment: " .. (dep.environment or "N/A"))
  print("  Created: " .. dep.created_at)
  if dep.creator then
    print("  By: " .. dep.creator)
  end
end

-- Filter by environment
local result = app.integrations.railway.list_deployments({
  service_id = "clx789xyz012",
  environment_id = "clxenv123",
  limit = 5
})

get_current_user

Get the currently authenticated Railway user.

Parameters

This tool takes no parameters.

Examples

local result = app.integrations.railway.get_current_user({})

print("User: " .. result.name)
print("Email: " .. result.email)
print("Verified: " .. tostring(result.is_verified))

Multi-Account Usage

If you have multiple Railway accounts configured, use account-specific namespaces:

-- Default account (always works)
app.integrations.railway.function_name({...})

-- Explicit default (portable across setups)
app.integrations.railway.default.function_name({...})

-- Named accounts
app.integrations.railway.work.function_name({...})
app.integrations.railway.staging.function_name({...})

All functions are identical across accounts — only the credentials differ.

Raw agent markdown
# Railway — Lua API Reference

Railway tools use the public GraphQL API with a stored account or workspace bearer token. The integration returns normalized project, service, deployment, and user fields instead of raw GraphQL envelopes.

## list_projects

List all Railway projects the authenticated user has access to.

### Parameters

This tool takes no parameters.

### Examples

```lua
local result = app.integrations.railway.list_projects({})

for _, project in ipairs(result.projects) do
  print(project.id .. ": " .. project.name)
  if project.description then
    print("  Description: " .. project.description)
  end
  if project.team then
    print("  Team: " .. project.team)
  end
  print("  Public: " .. tostring(project.is_public))
end
```

---

## get_project

Get detailed information about a specific Railway project, including environments and plugins.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_id` | string | yes | The Railway project ID |

### Examples

```lua
local result = app.integrations.railway.get_project({
  project_id = "clx123abc456"
})

print("Project: " .. result.name)
print("Description: " .. (result.description or "N/A"))
print("Environments: " .. result.environment_count)

for _, env in ipairs(result.environments) do
  print("  " .. env.name .. " (ephemeral: " .. tostring(env.is_ephemeral) .. ")")
end

print("Plugins: " .. result.plugin_count)
for _, plugin in ipairs(result.plugins) do
  print("  " .. plugin.name)
end
```

---

## create_project

Create a new Railway project.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `name` | string | yes | The name for the new project |
| `description` | string | no | An optional description for the project |

### Examples

```lua
-- Create a project with a name only
local result = app.integrations.railway.create_project({
  name = "My New App"
})
print(result.message)
print("Project ID: " .. result.id)

-- Create a project with a description
local result = app.integrations.railway.create_project({
  name = "My Backend Service",
  description = "Production backend API deployed on Railway"
})
print(result.message)
```

---

## list_services

List all services in a Railway project.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `project_id` | string | yes | The Railway project ID |

### Examples

```lua
local result = app.integrations.railway.list_services({
  project_id = "clx123abc456"
})

print("Services: " .. result.count)
for _, service in ipairs(result.services) do
  print("  " .. service.id .. ": " .. service.name)
  if service.repo_name then
    print("    Repo: " .. service.repo_name)
  end
end
```

---

## get_service

Get detailed information about a specific Railway service.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `service_id` | string | yes | The Railway service ID |

### Examples

```lua
local result = app.integrations.railway.get_service({
  service_id = "clx789xyz012"
})

print("Service: " .. result.name)
print("Forked: " .. tostring(result.is_forked))

if result.repo.full_name then
  print("Repo: " .. result.repo.full_name)
  print("Branch: " .. (result.repo.branch or "default"))
end
```

---

## list_deployments

List deployments for a Railway service.

### Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `service_id` | string | yes | The Railway service ID |
| `environment_id` | string | no | Filter deployments by environment ID |
| `limit` | integer | no | Max deployments to return (default: 20) |

### Examples

```lua
-- List recent deployments for a service
local result = app.integrations.railway.list_deployments({
  service_id = "clx789xyz012"
})

for _, dep in ipairs(result.deployments) do
  print(dep.id .. " [" .. dep.status .. "]")
  print("  Environment: " .. (dep.environment or "N/A"))
  print("  Created: " .. dep.created_at)
  if dep.creator then
    print("  By: " .. dep.creator)
  end
end

-- Filter by environment
local result = app.integrations.railway.list_deployments({
  service_id = "clx789xyz012",
  environment_id = "clxenv123",
  limit = 5
})
```

---

## get_current_user

Get the currently authenticated Railway user.

### Parameters

This tool takes no parameters.

### Examples

```lua
local result = app.integrations.railway.get_current_user({})

print("User: " .. result.name)
print("Email: " .. result.email)
print("Verified: " .. tostring(result.is_verified))
```

---

## Multi-Account Usage

If you have multiple Railway accounts configured, use account-specific namespaces:

```lua
-- Default account (always works)
app.integrations.railway.function_name({...})

-- Explicit default (portable across setups)
app.integrations.railway.default.function_name({...})

-- Named accounts
app.integrations.railway.work.function_name({...})
app.integrations.railway.staging.function_name({...})
```

All functions are identical across accounts — only the credentials differ.
Metadata-derived Lua example
local result = app.integrations.railway.list_projects({})
print(result)

Functions

list_projects Read

List all Railway projects the authenticated user has access to. Returns project IDs, names, descriptions, and team info.

Lua path
app.integrations.railway.list_projects
Full name
railway.railway_list_projects
ParameterTypeRequiredDescription
No parameters.
get_project Read

Get detailed information about a specific Railway project, including its environments and plugins.

Lua path
app.integrations.railway.get_project
Full name
railway.railway_get_project
ParameterTypeRequiredDescription
project_id string yes The Railway project ID.
create_project Write

Create a new Railway project with a name and optional description.

Lua path
app.integrations.railway.create_project
Full name
railway.railway_create_project
ParameterTypeRequiredDescription
name string yes The name for the new Railway project.
description string no An optional description for the project.
list_services Read

List all services in a Railway project. Returns service IDs, names, and repository info.

Lua path
app.integrations.railway.list_services
Full name
railway.railway_list_services
ParameterTypeRequiredDescription
project_id string yes The Railway project ID.
get_service Read

Get detailed information about a specific Railway service, including its source configuration and repository details.

Lua path
app.integrations.railway.get_service
Full name
railway.railway_get_service
ParameterTypeRequiredDescription
service_id string yes The Railway service ID.
list_deployments Read

List deployments for a Railway service. Returns deployment status, environment, and creator info.

Lua path
app.integrations.railway.list_deployments
Full name
railway.railway_list_deployments
ParameterTypeRequiredDescription
service_id string yes The Railway service ID.
environment_id string no Optional environment ID to filter deployments.
limit integer no Maximum number of deployments to return (default: 20).
get_current_user Read

Get information about the currently authenticated Railway user. Useful for verifying API credentials.

Lua path
app.integrations.railway.get_current_user
Full name
railway.railway_get_current_user
ParameterTypeRequiredDescription
No parameters.