Mattermost MCP服务器

一个生产就绪的Mattermost集成服务器,通过10个MCP工具提供频道管理、消息发布、用户操作和智能话题监控功能。

  • by adeg
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 adeg/mattermost-mcp

使用说明

Mattermost MCP服务器

生产准备就绪 模型上下文协议(MCP) 用于Mattermost集成的服务器。该服务器采用FastAPI和FastMCP构建,通过10个MCP工具展示Mattermost的功能,并包括一个基于Claude AI的语义分析的智能主题监控系统。

目录

概述

Mattermost MCP服务器使AI助手和LLM驱动的应用程序能够通过模型上下文协议与Mattermost工作区进行交互。它为渠道管理、消息传递、用户操作和自动主题监控提供了一套全面的工具。

主要特点

  • 10个MCP工具 用于完整的Mattermost交互(渠道、消息、用户、监控)
  • 主题监控 具有定时轮询和智能通知功能
  • Claude AI集成 用于语义主题匹配(带关键字回退)
  • 生产准备就绪 使用Docker和Nomad部署配置
  • 异步架构 使用FastAPI进行高性能I/O操作
  • 结构化日志记录 具有JSON输出以实现可观察性
  • 健康终点 用于编排和负载均衡器集成

技术栈

组件 技术
语言 Python 3.14+
Web框架 FastAPI+Uvicorn
MCP实施 FastMCP
Mattermost客户 mattermostautodriver
数据验证 Pydantic
任务调度 APScheduler
LLM集成 人类克劳德API
日志 结构日志

可用的MCP工具

服务器公开了10个MCP工具,分为四类:

渠道工具

mattermost_list_channels

列出Mattermost工作区中所有支持分页的公共频道。

参数 类型 默认值 说明
limit int 100 返回的最大通道数(最大:200)
page int 0 分页页码

退货:

{
  "channels": [
    {
      "id": "channel-id",
      "name": "general",
      "display_name": "General",
      "type": "O",
      "purpose": "Channel purpose",
      "header": "Channel header",
      "total_msg_count": 1234
    }
  ],
  "total_count": 50,
  "page": 0,
  "per_page": 100
}

mattermost_get_channel_history

从特定频道检索最近的消息。

参数 类型 默认值 说明
channel_id string 必填 Mattermost频道ID
limit int 30 要检索的邮件数
page int 0 分页页码

退货:

{
  "posts": [
    {
      "id": "post-id",
      "user_id": "user-id",
      "message": "Hello, world!",
      "create_at": "2024-11-04T14:06:82.000Z",
      "reply_count": 3,
      "root_id": null
    }
  ],
  "has_next": true,
  "has_prev": false,
  "page": 0,
  "per_page": 30
}

消息工具

mattermost_post_message

向频道发布新消息。

参数 类型 默认值 说明
channel_id string 必填 目标通道ID
message string 必填 要发布的消息内容

退货:

{
  "id": "post-id",
  "channel_id": "channel-id",
  "message": "Hello, world!",
  "create_at": "2024-11-04T14:06:82.000Z"
}

mattermost_reply_to_thread

回复特定的消息线程。

参数 类型 默认值 说明
channel_id string 必需 包含线程的通道ID
post_id string 必填 要回复的父邮件ID
message string 必填 回复文本内容

退货:

{
  "id": "reply-id",
  "channel_id": "channel-id",
  "root_id": "parent-post-id",
  "message": "This is a reply",
  "create_at": "2024-11-04T14:06:82.000Z"
}

mattermost_add_reaction

在消息中添加表情符号反应。

参数 类型 默认值 说明
channel_id string 必填 包含消息的频道ID
post_id string 必需 要响应的消息ID
emoji_name string 必需 没有冒号的表情符号名称(例如。, thumbsup, heart)

退货:

{
  "post_id": "post-id",
  "user_id": "user-id",
  "emoji_name": "thumbsup",
  "create_at": "2024-12-11T15:31:30.000Z"
}

mattermost_get_thread_replies

检索消息线程中的所有回复。

参数 类型 默认值 说明
channel_id string 必需 包含线程的通道ID
post_id string 必填 父消息ID

退货:

{
  "posts": [
    {
      "id": "reply-id",
      "user_id": "user-id",
      "message": "Reply message",
      "create_at": "2024-11-04T14:06:82.000Z",
      "root_id": "parent-post-id"
    }
  ],
  "root_post": {
    "id": "parent-post-id",
    "user_id": "user-id",
    "message": "Original message",
    "create_at": "2024-12-11T15:30:00.000Z"
  }
}

用户工具

mattermost_get_users

列出带分页的工作区用户。

参数 类型 默认值 说明
limit int 100 可返回的最大用户数(最大值:200)
page int 0 分页页码

退货:

{
  "users": [
    {
      "id": "user-id",
      "username": "john.doe",
      "email": "john@example.com",
      "first_name": "John",
      "last_name": "Doe",
      "nickname": "Johnny",
      "position": "Developer",
      "roles": "system_user",
      "is_bot": false
    }
  ],
  "total_count": 150,
  "page": 0,
  "per_page": 100
}

mattermost_get_user_profile

获取特定用户的详细个人资料信息。

参数 类型 默认值 说明
user_id string 必填 用户ID

退货:

{
  "id": "user-id",
  "username": "john.doe",
  "email": "john@example.com",
  "first_name": "John",
  "last_name": "Doe",
  "nickname": "Johnny",
  "position": "Developer",
  "roles": "system_user system_admin",
  "locale": "en",
  "timezone": "Asia/Dubai",
  "is_bot": false,
  "create_at": "2023-01-15T10:00:00.000Z",
  "update_at": "2024-12-01T14:30:00.000Z"
}

监视工具

mattermost_run_monitoring

立即触发主题监控过程(在预定时间间隔之外)。

参数 类型 默认值 说明
(无) - - -

退货:

{
  "success": true,
  "message": "Monitoring completed successfully"
}

mattermost_get_monitoring_status

获取当前监控系统状态。

参数 类型 默认值 说明
(无) - - -

退货:

{
  "enabled": true,
  "running": true,
  "message": "Monitoring is active"
}

安装

先决条件

  • Python 3.14+ (或3.11+,稍作调整)
  • Mattermost个人访问令牌 具有适当的权限
  • 无烟煤API密钥 (可选,用于语义主题分析)

快速开始

# Clone the repository
git clone https://github.com/adeg/mattermost-mcp.git
cd mattermost-mcp

# Create and activate virtual environment
python -m venv .venv
source .venv/bin/activate  # On Windows: .venv\Scripts\activate

# Install dependencies
pip install -e .

# Copy and configure environment
cp .env.example .env
# Edit .env with your configuration

# Run the server
python -m mattermost_mcp.main

使用紫外线(推荐)

# Install uv if not already installed
curl -LsSf https://astral.sh/uv/install.sh | sh

# Install dependencies
uv pip install -e .

# Run with uv
uv run python -m mattermost_mcp.main

开发安装

# Install with development dependencies
pip install -e ".[dev]"

# Or using Make
make dev

配置

配置是通过环境变量进行管理的。复制 .env.example 到 .env 并调整值:

cp .env.example .env

必要设置

变量 描述 示例
MATTERMOST_URL Mattermost服务器URL(无 /api/v4) https://mattermost.example.com
MATTERMOST_TOKEN 用于身份验证的个人访问令牌 abc123xyz789
MATTERMOST_TEAM_ID 要操作的团队ID team-id-from-mattermost

服务器设置

变量 默认值 描述
HTTP_PORT 8000 服务器的HTTP端口
LOG_LEVEL INFO 日志级别: DEBUG, INFO, WARNING, ERROR
LOG_FORMAT json 日志格式: json (生产)或 console (发展)

主题监控设置

变量 默认值 描述
MONITORING_ENABLED false 启用/禁用主题监视
MONITORING_SCHEDULE */5 * * * * 监控频率的Cron表达式
MONITORING_CHANNELS (空) 要监视的逗号分隔通道名称
MONITORING_TOPICS (空) 需要注意的逗号分隔主题
MONITORING_MESSAGE_LIMIT 50 每次运行每个通道要分析的最大消息数
MONITORING_STATE_PATH ./monitor-state.json 状态持久性文件的路径
MONITORING_PROCESS_EXISTING false 首次运行时处理现有消息
MONITORING_FIRST_RUN_LIMIT 10 首次运行时要处理的消息

LLM设置(可选)

变量 默认值 描述
ANTHROPIC_API_KEY (空) 基于Claude的分析的人类API密钥
ANTHROPIC_MODEL claude-sonnet-4-20250514 要使用的Claude模型
ANTHROPIC_MAX_TOKENS 1000 LLM响应的最大令牌数

配置示例

# Required
MATTERMOST_URL=https://mattermost.company.com
MATTERMOST_TOKEN=your-personal-access-token
MATTERMOST_TEAM_ID=your-team-id

# Server
HTTP_PORT=8000
LOG_LEVEL=INFO
LOG_FORMAT=json

# Monitoring
MONITORING_ENABLED=true
MONITORING_SCHEDULE=*/5 * * * *
MONITORING_CHANNELS=general,engineering,support
MONITORING_TOPICS=urgent,outage,help needed

# LLM (optional but recommended for semantic matching)
ANTHROPIC_API_KEY=sk-ant-api03-xxx

Docker部署

塑造形象

# Using Make
make docker-build

# Or directly
docker build -f infra/docker/Dockerfile -t mattermost-mcp:latest .

运行容器

# Using Make (reads from .env file)
make docker-run

# Or directly
docker run -d \
  --name mattermost-mcp \
  --env-file .env \
  -p 8000:8000 \
  -v mattermost-mcp-data:/data/mattermost-mcp \
  mattermost-mcp:latest

Docker编写示例

version: '3.8'

services:
  mattermost-mcp:
    build:
      context: .
      dockerfile: infra/docker/Dockerfile
    container_name: mattermost-mcp
    restart: unless-stopped
    ports:
      - "8000:8000"
    environment:
      - MATTERMOST_URL=${MATTERMOST_URL}
      - MATTERMOST_TOKEN=${MATTERMOST_TOKEN}
      - MATTERMOST_TEAM_ID=${MATTERMOST_TEAM_ID}
      - MONITORING_ENABLED=${MONITORING_ENABLED:-false}
      - MONITORING_CHANNELS=${MONITORING_CHANNELS:-}
      - MONITORING_TOPICS=${MONITORING_TOPICS:-}
      - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY:-}
    volumes:
      - mattermost-mcp-data:/data/mattermost-mcp
    healthcheck:
      test: ["CMD", "python", "-c", "import httpx; httpx.get('http://localhost:8000/health').raise_for_status()"]
      interval: 30s
      timeout: 10s
      retries: 3
      start_period: 5s

volumes:
  mattermost-mcp-data:

Dockerfile概述

Dockerfile使用多阶段构建来实现最佳映像大小:

  1. 建设者阶段:安装 uv 用于快速解决依赖关系并创建虚拟环境
  2. 生产阶段:只有应用程序代码和依赖项的最小Python运行时

关键安全功能:

  • 以非root用户身份运行(mcp:mcp)
  • 生产映像中没有开发依赖关系
  • 健康检查端点验证

游牧部署

该项目包括Nomad的工作规范 infra/nomad/mattermost-mcp.nomad.hcl.

先决条件

  • HashiCorp游牧集群
  • HashiCorp秘密管理库
  • Traefik入口(可选)
  • 带有内置映像的容器注册表

保险库机密设置

将秘密存储在Vault中 secret/data/mattermost-mcp:

vault kv put secret/mattermost-mcp \
  mattermost_url="https://mattermost.example.com" \
  mattermost_token="your-token" \
  team_id="your-team-id" \
  anthropic_api_key="your-anthropic-key" \  # pragma: allowlist secret
  monitoring_enabled="true" \
  monitoring_channels="general,engineering" \
  monitoring_topics="urgent,help"

部署作业

# Plan the deployment
nomad job plan infra/nomad/mattermost-mcp.nomad.hcl

# Run the deployment
nomad job run infra/nomad/mattermost-mcp.nomad.hcl

# Check status
nomad job status mattermost-mcp

作业配置亮点

设置 值 描述
类型 service 长期运行服务
CPU 256 MHz 资源请求
内存 512 MB 内存分配
端口 8000 HTTP服务器端口

健康检查

Nomad作业配置了两个健康检查:

  • 活性: GET /health 每30秒
  • 准备就绪: GET /ready 每60秒(包括Mattermost连接检查)

Traefik集成

该作业包括用于自动布线的Traefik标签:

tags = [
  "traefik.enable=true",
  "traefik.http.routers.mattermost-mcp.rule=Host(`mcp.example.com`)",
  "traefik.http.routers.mattermost-mcp.tls=true"
]

永久存储

该作业装载主机卷以监视状态持久性:

volume "data" {
  type   = "host"
  source = "mattermost-mcp-data"
}

配置主题监控

主题监控系统会自动扫描配置的频道,查找与指定主题相关的消息,并在发现相关内容时发送通知。

启用监控

MONITORING_ENABLED=true
MONITORING_SCHEDULE=*/5 * * * *
MONITORING_CHANNELS=general,engineering,support
MONITORING_TOPICS=urgent,outage,incident,help needed

运作原理

  1. 计划执行:监视器按照配置的cron计划运行(默认值:每5分钟一次)
  2. 通道扫描:从每个配置的通道获取最新消息
  3. 去重:跟踪已处理的消息以避免重复通知
  4. 话题检测:使用LLM语义匹配或关键字回退分析消息
  5. 通知递送:发送带有相关消息详细信息的DM通知

主题检测方法

LLM语义分析(推荐)

当 ANTHROPIC_API_KEY 系统使用Claude AI进行智能主题匹配:

  • 理解上下文和同义词(例如,“乒乓球”与“乒乓球)
  • 处理自然语言变化
  • 减少仅关键字匹配的误报

关键字回退

如果没有API密钥,系统将返回到不区分大小写的关键字匹配:

  • 快速和确定性
  • 没有外部API依赖项
  • 最适合精确匹配术语

状态持久性

监控系统在JSON文件中维护状态(MONITORING_STATE_PATH)致:

  • 跨重新启动跟踪已处理的消息
  • 防止重复通知
  • 记录上次运行时间戳

首次运行行为

首次运行时,您可以控制如何处理现有消息:

设置 行为
MONITORING_PROCESS_EXISTING=false 跳过现有消息,只监视新消息
MONITORING_PROCESS_EXISTING=true 流程至 MONITORING_FIRST_RUN_LIMIT 现有消息

通知格式

通知以直接消息的形式发送,包括:

  • 频道名称和消息计数
  • 最多5条相关消息,包括:
    • 作者用户名
    • 时间戳
    • 消息预览
    • 链接到原始帖子
    • 匹配主题

手动触发

使用 mattermost_run_monitoring MCP工具立即触发监控:

# Via MCP client
result = await mcp_client.call_tool("mattermost_run_monitoring", {})

监控状态

检查当前监控状态:

# Via MCP client
status = await mcp_client.call_tool("mattermost_get_monitoring_status", {})
# Returns: {"enabled": true, "running": true, "message": "Monitoring is active"}

发展

设置

# Install development dependencies
make dev

# This installs:
# - All runtime dependencies
# - pytest, pytest-asyncio, pytest-cov
# - ruff, mypy
# - Pre-commit hooks

可用的生成命令

命令 描述
make install 安装运行时依赖项
make dev 安装开发依赖项+预提交挂钩
make run 在本地启动服务器
make lint 运行ruff linting
make format 带褶皱的格式代码
make type-check 运行mypy类型检查
make test 以覆盖率运行pytest
make build 构建分发包
make docker-build 构建Docker镜像
make docker-run 运行Docker容器
make clean 删除构建工件

代码质量工具

褶边(装饰和格式化)

# Check for issues
make lint

# Auto-fix and format
make format

Ruff配置(英寸 pyproject.toml):

  • 行长:120个字符
  • 目标Python:3.14
  • 综合规则集(pycodestyle、pyflakes、isort、bugbear等)

MyPy(类型检查)

make type-check

该项目使用Pydantic模型的严格类型提示进行运行时验证。

预提交钩子

预提交钩子自动运行 git commit:

  • 文件检查(尾随空格、EOF、YAML/JSON验证)
  • 秘密检测(gitleaks,检测秘密)
  • Python linting和格式化(ruff)
  • 类型检查(mypy)
  • Markdown跳转

手动运行:

pre-commit run --all-files

测试

# Run all tests with coverage
make test

# Or directly with pytest
pytest tests/ -v --cov=mattermost_mcp --cov-report=term-missing

测试夹具可用于 tests/conftest.py:

  • mock_mattermost_client:启用异步的模拟客户端
  • sample_channel:通道数据示例
  • sample_post:示例帖子数据
  • sample_user:示例用户数据

本地运行

# Start the server
make run

# Or directly
python -m mattermost_mcp.main

服务器在端口8000上启动时:

  • MCP端点: http://localhost:8000/llm/mcp
  • 健康检查: http://localhost:8000/health
  • 准备就绪检查: http://localhost:8000/ready
  • 根信息: http://localhost:8000/

项目结构

mattermost-mcp/
├── src/mattermost_mcp/           # Main application package
│   ├── __init__.py               # Package version
│   ├── main.py                   # FastAPI application entry point
│   ├── config.py                 # Pydantic settings management
│   ├── logging.py                # Structured logging configuration
│   │
│   ├── api/                      # REST API endpoints
│   │   └── health.py             # Health and readiness endpoints
│   │
│   ├── clients/                  # External service clients
│   │   └── mattermost.py         # Async Mattermost API wrapper
│   │
│   ├── models/                   # Data models
│   │   └── mattermost.py         # Pydantic models for API responses
│   │
│   ├── mcp/                      # MCP server implementation
│   │   ├── server.py             # FastMCP server instance
│   │   └── tools/                # MCP tool definitions
│   │       ├── channels.py       # Channel tools
│   │       ├── messages.py       # Message tools
│   │       ├── users.py          # User tools
│   │       └── monitoring.py     # Monitoring tools
│   │
│   └── monitoring/               # Topic monitoring system
│       ├── monitor.py            # Main orchestrator
│       ├── analyzer.py           # Message analysis (LLM + keyword)
│       ├── scheduler.py          # APScheduler wrapper
│       └── persistence.py        # State management
│
├── infra/                        # Infrastructure configuration
│   ├── docker/
│   │   ├── Dockerfile            # Multi-stage Docker build
│   │   └── .dockerignore
│   └── nomad/
│       └── mattermost-mcp.nomad.hcl  # Nomad job specification
│
├── tests/                        # Test suite
│   ├── conftest.py               # Pytest fixtures
│   └── test_mcp_tools.py         # Tool and model tests
│
├── pyproject.toml                # Project metadata and tool config
├── Makefile                      # Development automation
├── .env.example                  # Configuration template
├── .pre-commit-config.yaml       # Pre-commit hooks
└── .mise.toml                    # Tool version management

模块职责

模块 目的
main.py 应用程序入口点、生命周期管理、路由挂载
config.py 使用Pydantic设置解析环境变量
logging.py 带structlog的结构化日志记录(JSON/控制台输出)
clients/mattermost.py mattermostautodriver周围的异步包装器
models/mattermost.py 渠道、帖子、用户、反应的Pydantic模型
mcp/server.py FastMCP服务器实例创建
mcp/tools/* 单个MCP工具实现
monitoring/monitor.py 监控编排和通知传递
monitoring/analyzer.py LLM和基于关键字的消息分析
monitoring/scheduler.py 基于APScheduler的cron调度
monitoring/persistence.py 基于JSON的状态持久化

解决方案架构

系统概述

┌───────────────────────────────────────────────────────────────────┐
│                        Mattermost MCP Server                      │
├───────────────────────────────────────────────────────────────────┤
│                                                                   │
│  ┌──────────────┐    ┌──────────────┐    ┌────────────────────┐   │
│  │   FastAPI    │    │   FastMCP    │    │  Topic Monitoring  │   │
│  │   (HTTP)     │    │   (MCP)      │    │    (Scheduler)     │   │
│  └──────┬───────┘    └──────┬───────┘    └─────────┬──────────┘   │
│         │                   │                      │              │
│         │    ┌──────────────┴───────────────┐      │              │
│         │    │         MCP Tools            │      │              │
│         │    │  ┌──────────┬─────────────┐  │      │              │
│         │    │  │ Channels │  Messages   │  │      │              │
│         │    │  ├──────────┼─────────────┤  │      │              │
│         │    │  │   Users  │ Monitoring  │  │      │              │
│         │    │  └──────────┴─────────────┘  │      │              │
│         │    └──────────────┬───────────────┘      │              │
│         │                   │                      │              │
│         └───────────────────┼──────────────────────┘              │
│                             │                                     │
│                    ┌────────▼────────┐                            │
│                    │ MattermostClient│                            │
│                    │   (Async)       │                            │
│                    └────────┬────────┘                            │
│                             │                                     │
└─────────────────────────────┼─────────────────────────────────────┘
                              │
                    ┌─────────▼─────────┐
                    │  Mattermost API   │
                    │   (External)      │
                    └───────────────────┘

请求流:MCP工具调用

1. LLM/Client sends MCP tool request
   │
   ▼
2. FastMCP receives request at /llm/mcp
   │
   ▼
3. Tool function invoked (e.g., mattermost_post_message)
   │
   ▼
4. MattermostClient method called (async)
   │
   ├─► Ensures login via await self.login()
   │
   └─► Wraps sync driver call with asyncio.to_thread()
       │
       ▼
5. mattermostautodriver makes HTTP request to Mattermost
   │
   ▼
6. Response converted to Pydantic model
   │
   ▼
7. Formatted response returned to LLM/Client

监测管道

                    ┌────────────────────┐
                    │  APScheduler Cron  │
                    │   (*/5 * * * *)    │
                    └─────────┬──────────┘
                              │ triggers
                              ▼
                    ┌────────────────────┐
                    │   TopicMonitor     │
                    │  _run_monitoring() │
                    └─────────┬──────────┘
                              │
           ┌──────────────────┼──────────────────┐
           ▼                  ▼                  ▼
    ┌─────────────┐    ┌─────────────┐    ┌─────────────┐
    │  Channel 1  │    │  Channel 2  │    │  Channel N  │
    │   Analysis  │    │   Analysis  │    │   Analysis  │
    └──────┬──────┘    └──────┬──────┘    └──────┬──────┘
           │                  │                  │
           └──────────────────┼──────────────────┘
                              │
                              ▼
                    ┌────────────────────┐
                    │  MessageAnalyzer   │
                    │  _analyze_posts_*  │
                    └─────────┬──────────┘
                              │
              ┌───────────────┴───────────────┐
              ▼                               ▼
    ┌──────────────────┐            ┌──────────────────┐
    │   LLM Analysis   │            │ Keyword Fallback │
    │  (Claude API)    │            │  (No API Key)    │
    └────────┬─────────┘            └────────┬─────────┘
             │                               │
             └───────────────┬───────────────┘
                             │
                             ▼
                   ┌────────────────────┐
                   │  StateManager      │
                   │  (Deduplication)   │
                   └─────────┬──────────┘
                             │
                             ▼
                   ┌────────────────────┐
                   │  Send Notification │
                   │  (DM to User)      │
                   └────────────────────┘

错误处理策略

该系统实现了三层错误处理:

层级 策略 示例
故障弱化 回退到备选方案 LLM失败→ 使用关键字匹配
尝试除日志记录外 日志错误,继续处理 通道获取失败→ 跳过、处理其他
任务隔离 错误不会使计划程序崩溃 通知失败→ 日志,下一次运行继续

异步设计

所有I/O操作都使用async/await来防止阻塞:

  • 快速API:异步请求处理程序
  • FastMCP:异步工具函数
  • Mattermost客户:用途 asyncio.to_thread() 包装同步驱动程序
  • 监控:用途 AsyncIOScheduler 来自APScheduler
  • Anthropic:对LLM调用使用异步客户端

组件交互

┌─────────────────────────────────────────────────────────────────┐
│                       Configuration Layer                       │
│  ┌──────────┐  ┌──────────────────┐  ┌────────────┐             │
│  │ Settings │  │ MonitoringConfig │  │ LlmConfig  │             │
│  └────┬─────┘  └────────┬─────────┘  └─────┬──────┘             │
└───────┼─────────────────┼──────────────────┼────────────────────┘
        │                 │                  │
        ▼                 ▼                  ▼
┌─────────────────────────────────────────────────────────────────┐
│                        Application Layer                        │
│  ┌──────────────────────────────────────────────────────┐       │
│  │                    main.py                           │       │
│  │  - Lifespan management (startup/shutdown)            │       │
│  │  - FastAPI + FastMCP mounting                        │       │
│  │  - Health endpoints                                  │       │
│  └──────────────────────────────────────────────────────┘       │
└─────────────────────────────────────────────────────────────────┘
        │
        ▼
┌─────────────────────────────────────────────────────────────────┐
│                        Service Layer                            │
│  ┌────────────────┐     ┌────────────────┐                      │
│  │ MCP Tools      │     │ TopicMonitor   │                      │
│  │ (channels,     │     │ (scheduler,    │                      │
│  │  messages,     │     │  analyzer,     │                      │
│  │  users,        │     │  persistence)  │                      │
│  │  monitoring)   │     │                │                      │
│  └───────┬────────┘     └───────┬────────┘                      │
└──────────┼──────────────────────┼───────────────────────────────┘
           │                      │
           ▼                      ▼
┌─────────────────────────────────────────────────────────────────┐
│                        Client Layer                             │
│  ┌────────────────────────┐  ┌────────────────────────────┐     │
│  │   MattermostClient     │  │   Anthropic Async Client   │     │
│  │   (mattermostautodriver│  │   (Claude API)             │     │
│  │    TypedDriver)        │  │                            │     │
│  └────────────────────────┘  └────────────────────────────┘     │
└─────────────────────────────────────────────────────────────────┘
           │                      │
           ▼                      ▼
    ┌──────────────┐      ┌──────────────┐
    │ Mattermost   │      │  Anthropic   │
    │ API v4       │      │  API         │
    └──────────────┘      └──────────────┘

许可证

麻省理工学院