KosmoKrator

productivity

Mattermost Lua API for KosmoKrator Agents

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

Lua Namespace

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

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

Workflow file

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

workflow.lua
local mattermost = app.integrations.mattermost
local result = mattermost.api_get({})

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

MCP-only Lua

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

Mattermost

Mattermost tools are exposed under app.integrations.mattermost. The integration targets the Mattermost REST API v4 using a personal access token or bot token.

Raw API Helpers

Use raw helpers for REST API v4 endpoints that do not yet have a first-class tool:

  • mattermost_api_get
  • mattermost_api_post
  • mattermost_api_put
  • mattermost_api_patch
  • mattermost_api_delete

Paths can be relative to /api/v4 or include /api/v4.

local users = app.integrations.mattermost.mattermost_api_get({
  path = "/users",
  query = {
    page = 0,
    per_page = 20
  }
})

Users

local me = app.integrations.mattermost.mattermost_get_current_user({})

local results = app.integrations.mattermost.mattermost_search_users({
  term = "alex",
  team_id = "team_123"
})

User tools:

  • mattermost_list_users
  • mattermost_search_users
  • mattermost_get_user
  • mattermost_get_user_by_username
  • mattermost_create_user
  • mattermost_patch_user
  • mattermost_deactivate_user
  • mattermost_get_current_user

User creation and activation changes require server permissions for the token.

Teams

local teams = app.integrations.mattermost.mattermost_list_teams({
  page = 0,
  per_page = 60
})

app.integrations.mattermost.mattermost_add_team_member({
  team_id = "team_123",
  user_id = "user_123"
})

Team tools:

  • mattermost_list_teams
  • mattermost_get_team
  • mattermost_create_team
  • mattermost_patch_team
  • mattermost_list_team_members
  • mattermost_add_team_member
  • mattermost_remove_team_member

Channels

local channels = app.integrations.mattermost.mattermost_list_team_channels({
  team_id = "team_123",
  page = 0,
  per_page = 50
})

local created = app.integrations.mattermost.mattermost_create_channel({
  team_id = "team_123",
  name = "release-updates",
  display_name = "Release Updates",
  type = "O"
})

Channel tools:

  • mattermost_list_channels
  • mattermost_list_team_channels
  • mattermost_search_channels
  • mattermost_create_channel
  • mattermost_get_channel
  • mattermost_patch_channel
  • mattermost_delete_channel
  • mattermost_list_channel_members
  • mattermost_add_channel_member
  • mattermost_remove_channel_member

The legacy mattermost_list_channels tool lists channels for the current user. Use mattermost_list_team_channels when you need channels in a specific team.

Posts, Threads, And Reactions

local post = app.integrations.mattermost.mattermost_create_post({
  channel_id = "channel_123",
  message = "Deployment finished."
})

local thread = app.integrations.mattermost.mattermost_get_post_thread({
  post_id = post.id
})

Post and reaction tools:

  • mattermost_create_post
  • mattermost_list_posts
  • mattermost_get_post
  • mattermost_patch_post
  • mattermost_delete_post
  • mattermost_search_posts
  • mattermost_get_post_thread
  • mattermost_list_post_reactions
  • mattermost_create_reaction
  • mattermost_delete_reaction

Files

mattermost_get_file_info returns metadata for a file ID. File upload/download endpoints can involve multipart or binary payloads, so use raw helpers only when the host can handle that request or response shape.

Output Shape

Existing compatibility tools such as mattermost_list_posts, mattermost_list_channels, and mattermost_get_current_user keep their current normalized responses. New endpoint-mapped tools return Mattermost’s parsed JSON response directly, or an empty object for 204 No Content.

Raw agent markdown
# Mattermost

Mattermost tools are exposed under `app.integrations.mattermost`. The integration targets the Mattermost REST API v4 using a personal access token or bot token.

## Raw API Helpers

Use raw helpers for REST API v4 endpoints that do not yet have a first-class tool:

- `mattermost_api_get`
- `mattermost_api_post`
- `mattermost_api_put`
- `mattermost_api_patch`
- `mattermost_api_delete`

Paths can be relative to `/api/v4` or include `/api/v4`.

```lua
local users = app.integrations.mattermost.mattermost_api_get({
  path = "/users",
  query = {
    page = 0,
    per_page = 20
  }
})
```

## Users

```lua
local me = app.integrations.mattermost.mattermost_get_current_user({})

local results = app.integrations.mattermost.mattermost_search_users({
  term = "alex",
  team_id = "team_123"
})
```

User tools:

- `mattermost_list_users`
- `mattermost_search_users`
- `mattermost_get_user`
- `mattermost_get_user_by_username`
- `mattermost_create_user`
- `mattermost_patch_user`
- `mattermost_deactivate_user`
- `mattermost_get_current_user`

User creation and activation changes require server permissions for the token.

## Teams

```lua
local teams = app.integrations.mattermost.mattermost_list_teams({
  page = 0,
  per_page = 60
})

app.integrations.mattermost.mattermost_add_team_member({
  team_id = "team_123",
  user_id = "user_123"
})
```

Team tools:

- `mattermost_list_teams`
- `mattermost_get_team`
- `mattermost_create_team`
- `mattermost_patch_team`
- `mattermost_list_team_members`
- `mattermost_add_team_member`
- `mattermost_remove_team_member`

## Channels

```lua
local channels = app.integrations.mattermost.mattermost_list_team_channels({
  team_id = "team_123",
  page = 0,
  per_page = 50
})

local created = app.integrations.mattermost.mattermost_create_channel({
  team_id = "team_123",
  name = "release-updates",
  display_name = "Release Updates",
  type = "O"
})
```

Channel tools:

- `mattermost_list_channels`
- `mattermost_list_team_channels`
- `mattermost_search_channels`
- `mattermost_create_channel`
- `mattermost_get_channel`
- `mattermost_patch_channel`
- `mattermost_delete_channel`
- `mattermost_list_channel_members`
- `mattermost_add_channel_member`
- `mattermost_remove_channel_member`

The legacy `mattermost_list_channels` tool lists channels for the current user. Use `mattermost_list_team_channels` when you need channels in a specific team.

## Posts, Threads, And Reactions

```lua
local post = app.integrations.mattermost.mattermost_create_post({
  channel_id = "channel_123",
  message = "Deployment finished."
})

local thread = app.integrations.mattermost.mattermost_get_post_thread({
  post_id = post.id
})
```

Post and reaction tools:

- `mattermost_create_post`
- `mattermost_list_posts`
- `mattermost_get_post`
- `mattermost_patch_post`
- `mattermost_delete_post`
- `mattermost_search_posts`
- `mattermost_get_post_thread`
- `mattermost_list_post_reactions`
- `mattermost_create_reaction`
- `mattermost_delete_reaction`

## Files

`mattermost_get_file_info` returns metadata for a file ID. File upload/download endpoints can involve multipart or binary payloads, so use raw helpers only when the host can handle that request or response shape.

## Output Shape

Existing compatibility tools such as `mattermost_list_posts`, `mattermost_list_channels`, and `mattermost_get_current_user` keep their current normalized responses. New endpoint-mapped tools return Mattermost's parsed JSON response directly, or an empty object for `204 No Content`.
Metadata-derived Lua example
local result = app.integrations.mattermost.api_get({})
print(result)

Functions

api_get Read

Execute a raw Mattermost API GET request.

Lua path
app.integrations.mattermost.api_get
Full name
mattermost.mattermost_api_get
ParameterTypeRequiredDescription
No parameters.
api_post Write

Execute a raw Mattermost API POST request.

Lua path
app.integrations.mattermost.api_post
Full name
mattermost.mattermost_api_post
ParameterTypeRequiredDescription
No parameters.
api_put Write

Execute a raw Mattermost API PUT request.

Lua path
app.integrations.mattermost.api_put
Full name
mattermost.mattermost_api_put
ParameterTypeRequiredDescription
No parameters.
api_patch Write

Execute a raw Mattermost API PATCH request.

Lua path
app.integrations.mattermost.api_patch
Full name
mattermost.mattermost_api_patch
ParameterTypeRequiredDescription
No parameters.
api_delete Write

Execute a raw Mattermost API DELETE request.

Lua path
app.integrations.mattermost.api_delete
Full name
mattermost.mattermost_api_delete
ParameterTypeRequiredDescription
No parameters.
get_current_user Read

Get the profile of the currently authenticated Mattermost user. Returns username, email, display name, roles, and locale.

Lua path
app.integrations.mattermost.get_current_user
Full name
mattermost.mattermost_get_current_user
ParameterTypeRequiredDescription
No parameters.
list_users Read

List Mattermost users.

Lua path
app.integrations.mattermost.list_users
Full name
mattermost.mattermost_list_users
ParameterTypeRequiredDescription
No parameters.
search_users Read

Search Mattermost users.

Lua path
app.integrations.mattermost.search_users
Full name
mattermost.mattermost_search_users
ParameterTypeRequiredDescription
No parameters.
get_user Read

Get a Mattermost user by ID.

Lua path
app.integrations.mattermost.get_user
Full name
mattermost.mattermost_get_user
ParameterTypeRequiredDescription
No parameters.
get_user_by_username Read

Get a Mattermost user by username.

Lua path
app.integrations.mattermost.get_user_by_username
Full name
mattermost.mattermost_get_user_by_username
ParameterTypeRequiredDescription
No parameters.
create_user Write

Create a Mattermost user.

Lua path
app.integrations.mattermost.create_user
Full name
mattermost.mattermost_create_user
ParameterTypeRequiredDescription
No parameters.
patch_user Write

Patch a Mattermost user.

Lua path
app.integrations.mattermost.patch_user
Full name
mattermost.mattermost_patch_user
ParameterTypeRequiredDescription
No parameters.
set_user_active Write

Deactivate or activate a Mattermost user.

Lua path
app.integrations.mattermost.set_user_active
Full name
mattermost.mattermost_deactivate_user
ParameterTypeRequiredDescription
No parameters.
list_teams Read

List teams the current user belongs to in Mattermost. Returns team IDs, names, display names, and types. Use this to discover available teams before working with channels.

Lua path
app.integrations.mattermost.list_teams
Full name
mattermost.mattermost_list_teams
ParameterTypeRequiredDescription
page integer no Page number (0-indexed). Default: 0.
per_page integer no Number of teams per page. Default: 60.
get_team Read

Get a Mattermost team.

Lua path
app.integrations.mattermost.get_team
Full name
mattermost.mattermost_get_team
ParameterTypeRequiredDescription
No parameters.
create_team Write

Create a Mattermost team.

Lua path
app.integrations.mattermost.create_team
Full name
mattermost.mattermost_create_team
ParameterTypeRequiredDescription
No parameters.
patch_team Write

Patch a Mattermost team.

Lua path
app.integrations.mattermost.patch_team
Full name
mattermost.mattermost_patch_team
ParameterTypeRequiredDescription
No parameters.
list_team_members Read

List Mattermost team members.

Lua path
app.integrations.mattermost.list_team_members
Full name
mattermost.mattermost_list_team_members
ParameterTypeRequiredDescription
No parameters.
add_team_member Write

Add a user to a Mattermost team.

Lua path
app.integrations.mattermost.add_team_member
Full name
mattermost.mattermost_add_team_member
ParameterTypeRequiredDescription
No parameters.
remove_team_member Write

Remove a user from a Mattermost team.

Lua path
app.integrations.mattermost.remove_team_member
Full name
mattermost.mattermost_remove_team_member
ParameterTypeRequiredDescription
No parameters.
list_channels Read

List channels the current user belongs to in Mattermost. Returns channel IDs, names, types, and team associations. Use this to discover available channels before posting messages or reading posts.

Lua path
app.integrations.mattermost.list_channels
Full name
mattermost.mattermost_list_channels
ParameterTypeRequiredDescription
page integer no Page number (0-indexed). Default: 0.
per_page integer no Number of channels per page. Default: 60.
list_team_channels Read

List channels in a Mattermost team.

Lua path
app.integrations.mattermost.list_team_channels
Full name
mattermost.mattermost_list_team_channels
ParameterTypeRequiredDescription
No parameters.
search_channels Read

Search channels in a Mattermost team.

Lua path
app.integrations.mattermost.search_channels
Full name
mattermost.mattermost_search_channels
ParameterTypeRequiredDescription
No parameters.
create_channel Write

Create a Mattermost channel.

Lua path
app.integrations.mattermost.create_channel
Full name
mattermost.mattermost_create_channel
ParameterTypeRequiredDescription
No parameters.
get_channel Read

Get details of a specific Mattermost channel by ID. Returns channel name, display name, type, header, purpose, and member counts.

Lua path
app.integrations.mattermost.get_channel
Full name
mattermost.mattermost_get_channel
ParameterTypeRequiredDescription
channel_id string yes The channel ID.
patch_channel Write

Patch a Mattermost channel.

Lua path
app.integrations.mattermost.patch_channel
Full name
mattermost.mattermost_patch_channel
ParameterTypeRequiredDescription
No parameters.
delete_channel Write

Delete a Mattermost channel.

Lua path
app.integrations.mattermost.delete_channel
Full name
mattermost.mattermost_delete_channel
ParameterTypeRequiredDescription
No parameters.
list_channel_members Read

List Mattermost channel members.

Lua path
app.integrations.mattermost.list_channel_members
Full name
mattermost.mattermost_list_channel_members
ParameterTypeRequiredDescription
No parameters.
add_channel_member Write

Add a user to a Mattermost channel.

Lua path
app.integrations.mattermost.add_channel_member
Full name
mattermost.mattermost_add_channel_member
ParameterTypeRequiredDescription
No parameters.
remove_channel_member Write

Remove a user from a Mattermost channel.

Lua path
app.integrations.mattermost.remove_channel_member
Full name
mattermost.mattermost_remove_channel_member
ParameterTypeRequiredDescription
No parameters.
create_post Write

Post a message to a Mattermost channel. Provide the channel_id and the message text. Returns the created post with its ID and timestamp.

Lua path
app.integrations.mattermost.create_post
Full name
mattermost.mattermost_create_post
ParameterTypeRequiredDescription
channel_id string yes The channel ID to post the message in.
message string yes The message text to post. Supports Markdown formatting.
list_posts Read

List posts in a Mattermost channel. Returns post IDs, messages, author info, and timestamps. Use page and per_page for pagination.

Lua path
app.integrations.mattermost.list_posts
Full name
mattermost.mattermost_list_posts
ParameterTypeRequiredDescription
channel_id string yes The channel ID to list posts from.
page integer no Page number (0-indexed). Default: 0.
per_page integer no Number of posts per page. Default: 60.
get_post Read

Get a specific Mattermost post by ID. Returns the full post including message content, author, channel, and timestamps.

Lua path
app.integrations.mattermost.get_post
Full name
mattermost.mattermost_get_post
ParameterTypeRequiredDescription
post_id string yes The post ID.
patch_post Write

Patch a Mattermost post.

Lua path
app.integrations.mattermost.patch_post
Full name
mattermost.mattermost_patch_post
ParameterTypeRequiredDescription
No parameters.
delete_post Write

Delete a Mattermost post.

Lua path
app.integrations.mattermost.delete_post
Full name
mattermost.mattermost_delete_post
ParameterTypeRequiredDescription
No parameters.
search_posts Read

Search posts in a Mattermost team.

Lua path
app.integrations.mattermost.search_posts
Full name
mattermost.mattermost_search_posts
ParameterTypeRequiredDescription
No parameters.
get_post_thread Read

Get a Mattermost post thread.

Lua path
app.integrations.mattermost.get_post_thread
Full name
mattermost.mattermost_get_post_thread
ParameterTypeRequiredDescription
No parameters.
list_post_reactions Read

List reactions for a Mattermost post.

Lua path
app.integrations.mattermost.list_post_reactions
Full name
mattermost.mattermost_list_post_reactions
ParameterTypeRequiredDescription
No parameters.
create_reaction Write

Add a reaction to a Mattermost post.

Lua path
app.integrations.mattermost.create_reaction
Full name
mattermost.mattermost_create_reaction
ParameterTypeRequiredDescription
No parameters.
delete_reaction Write

Delete a Mattermost reaction.

Lua path
app.integrations.mattermost.delete_reaction
Full name
mattermost.mattermost_delete_reaction
ParameterTypeRequiredDescription
No parameters.
get_file_info Read

Get Mattermost file metadata.

Lua path
app.integrations.mattermost.get_file_info
Full name
mattermost.mattermost_get_file_info
ParameterTypeRequiredDescription
No parameters.