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.1

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.1
File Size Uploaded
ki_mattermost-0.1.1.tar.gz 7.4 kB Details

Built distribution (wheel)

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

Total release size: 16.9 kB

Release files / ki_mattermost-0.1.1.tar.gz

Download URL ki_mattermost-0.1.1.tar.gz
Size 7.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b8a8c29330de2e5f7459021a44541ef17a411595a59a6940000c2efd7fdefa17
BLAKE2b-256 checksum
How to use checksums
c308acfea129519e4a8e1d41f6555281794e9cf06b3297ca69e286fc40dc4531
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.1-py3-none-any.whl

Download URL ki_mattermost-0.1.1-py3-none-any.whl
Size 9.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
609a1dc893cb9cb35536046802925a96d3cdd265d2435f6fefbaf95609dd5d8f
BLAKE2b-256 checksum
How to use checksums
b085a7790df24530fd036b9eda52fc054447683da6de2260425a55ec46fe232d
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

This release

0.1.1 This release

2 release files

0.1.0

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