Skip to main content

ki_mattermost

Typed Python 3.14 client and CLI for self-hosted Mattermost (API v4). Built with uv and linted with Ruff.

Install

pip install ki_mattermost
# or
uv add ki_mattermost

Features

  • List teams and channels
  • Read channel messages and threads
  • Create new threads (root posts)
  • Comment (reply) in threads
  • Like / unlike posts via emoji reactions (thumbsup by default)

Configuration

Set environment variables (or a local .env):

export MM_URL=https://mattermost.example.com
export MM_TOKEN=your-personal-access-token
# optional
export MM_TEAM_ID=
export MM_VERIFY_SSL=true
export MM_TIMEOUT=30

Create a Personal Access Token in Mattermost: Profile → Security → Personal Access Tokens (or use a bot account token).

CLI

After install, the ki-mattermost console script is available:

ki-mattermost whoami
ki-mattermost teams
ki-mattermost channels
ki-mattermost channels --team-id <TEAM_ID>

ki-mattermost posts <CHANNEL_ID> --flat
ki-mattermost thread <POST_ID> --flat

ki-mattermost create-thread <CHANNEL_ID> "Hello from API"
ki-mattermost comment <POST_ID> "Replying in thread"
ki-mattermost like <POST_ID>
ki-mattermost like <POST_ID> --emoji heart
ki-mattermost unlike <POST_ID>
ki-mattermost reactions <POST_ID>

Library usage

from ki_mattermost import MattermostClient, get_settings

with MattermostClient(get_settings()) as mm:
    channels = mm.list_channels()
    posts = mm.list_posts(channels[0].id)
    root = mm.create_thread(channels[0].id, "New thread")
    mm.comment(root.id, "First reply")
    mm.like(root.id)

Environment

Variable Required Description
MM_URL yes Mattermost base URL
MM_TOKEN yes Bearer token
MM_TEAM_ID no Default team for channel listing
MM_VERIFY_SSL no TLS verify (true/false, default true)
MM_TIMEOUT no HTTP timeout seconds (default 30)

Development

uv sync
cp .env.example .env
uv run ruff check .
uv run ruff format .
uv run ki-mattermost --help

Build & publish to PyPI

uv build
uv publish
# or with an explicit token:
# uv publish --token $UV_PUBLISH_TOKEN

Create an API token at https://pypi.org/manage/account/token/.

Release files for ki_mattermost 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ki_mattermost 0.1.0
File Size Uploaded
ki_mattermost-0.1.0.tar.gz 7.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for ki_mattermost 0.1.0
File Interpreter ABI Platform
ki_mattermost-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 16.9 kB

Release files / ki_mattermost-0.1.0.tar.gz

Download URL ki_mattermost-0.1.0.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
be860dc897d388a52cc7790a4376c9b58b64d7ff87b078c8a1c7e133acb13052
BLAKE2b-256 checksum
How to use checksums
26708a61603202d3fe80e7e7741036c68abe50d29e4c79f041f4c5633e2b018c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / ki_mattermost-0.1.0-py3-none-any.whl

Download URL ki_mattermost-0.1.0-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a3b8c8d0ef2a5c47cdb841cae051526d1fc94835a61858687d3180e5447140a0
BLAKE2b-256 checksum
How to use checksums
b355dd3b9b82c80c9334ff28d687864b25d77b35524bde9b0d79c8159d521d92
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"12","id":"bookworm","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.1

2 release files

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page