ml-lifecycle-mcp

ml-lifecycle-mcp

Exposes a time series forecasting model as an MCP tool with built-in audit logging for every call, enabling trustworthy autonomous forecasting.

Category
访问服务器

README

ml-lifecycle-mcp

An MCP server that exposes a time series forecasting model as a tool, with a built-in audit trail for every call.

Why this project

Two things prompted this:

  1. A conversation with an RBC contact about the Model Context Protocol as a way to expose internal ML/data tools to LLM clients in a standardized way.
  2. RBC Borealis's own research focus areas include time series analysis and NLP — this project picks time series as the first concrete capability, built the way I'd want a production tool to be built, not a notebook demo.

The goal isn't "wrap a model in MCP." It's: what does it take for an ML capability to be trustworthy enough to hand to an autonomous client? That means typed interfaces, input validation, tests that cover the failure modes (not just the happy path), and — carried over from a separate project of mine, ai-governance-gateway — an audit log of every call, since "what happened and with what inputs" is the first question anyone asks when a model-backed system misbehaves.

Architecture

src/ml_lifecycle_mcp/
  forecasting.py   # the model: Holt-Winters exponential smoothing (statsmodels),
                    # wrapped behind a typed function so the tool layer never
                    # touches statsmodels directly
  audit.py          # AuditLogger — context manager that records every call
                     # (timing, input shape, success/failure) as JSON lines
  server.py         # FastMCP server: registers `forecast_timeseries` as an
                     # MCP tool, wraps it with the audit logger
  web.py             # Starlette app: a browser UI over the same model +
                      # the same audit log, for demoing without an MCP client
  static/            # index.html / style.css / app.js — the browser UI
tests/
  test_forecasting.py  # model correctness + input validation
  test_audit.py        # logging behavior, including the failure path
  test_server.py        # the tool function as a client would call it
  test_web.py            # the HTTP API as a browser would call it

Design choices worth knowing about, and their limitations:

  • Confidence intervals are approximated from in-sample residual standard deviation under a normal-residual assumption, not from statsmodels' simulation-based intervals. That's a reasonable trade for a lightweight service, but it understates uncertainty for short or non-stationary series. A production version would switch to get_prediction() with simulated paths.
  • Audit logging defaults to shape-only (list length, types), not raw values, since forecasting inputs may be business-sensitive. log_values=True exists for local debugging but shouldn't be turned on against real data without a retention/PII policy — same lesson as the governance gateway project.
  • One tool, on purpose. This was scoped to be small and correct rather than broad. An NLP tool (sentiment/summarization) following the same pattern — typed wrapper, audited, tested — is the natural next addition.
  • The web UI adds zero new dependencies. mcp already pulls in starlette and uvicorn transitively, so web.py uses those directly instead of adding FastAPI on top. It shares the same AuditLogger instance (same default log file) as the MCP server, so a call made from Claude Desktop and a call made from the browser both show up in one audit trail — the log shouldn't care which door a request came through.

Setup

python -m venv .venv
source .venv/bin/activate        # Windows: .venv\Scripts\activate
pip install -e ".[dev]"

Running the tests

python -m pytest -v

Running the server

python -m ml_lifecycle_mcp.server

This starts an MCP server over stdio. To use it from Claude Desktop, add it to claude_desktop_config.json:

{
  "mcpServers": {
    "ml-lifecycle-mcp": {
      "command": "/absolute/path/to/.venv/bin/python",
      "args": ["-m", "ml_lifecycle_mcp.server"]
    }
  }
}

Then ask Claude something like: "Forecast the next 5 points of [10, 12, 13, 15, 14, 17, 19, 20]" — it will call forecast_timeseries and every call gets written to audit_log.jsonl in the working directory.

Running the web UI

python -m ml_lifecycle_mcp.web

Open http://127.0.0.1:8000. Paste a series, set a horizon, hit run forecast — you'll see the series plotted with the forecast segment and its 80% confidence band, and the audit log panel underneath updates with every call. This is the same model and the same audit trail the MCP tool uses, just reachable without an MCP client — useful for a live demo when you don't want to depend on Claude Desktop being configured correctly in the room.

Example

from ml_lifecycle_mcp.server import forecast_timeseries

forecast_timeseries(values=[10, 12, 13, 15, 14, 17, 19, 20], horizon=3)
# {'forecast': [21.21, 22.60, 23.98],
#  'lower_80': [20.32, 21.70, 23.08],
#  'upper_80': [22.11, 23.49, 24.87],
#  'method': 'holt_winters_trend'}

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选