memo概率程序MCP服务

memo-mcp 是一个 MCP 服务,为 LLM 提供编写、校验、运行和解释 memo 概率程序的工具,适用于生成正确的 memo 代码以及向非技术受众解释多智能体递归推理模型。

  • by robert-johansson
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 robert-johansson/memo-mcp

使用说明

memo-mcp

An MCP server that gives LLMs tools for writing, validating, running, and explaining memo probabilistic programs.

memo is a DSL that compiles recursive multi-agent reasoning models to JAX array programs. This server helps LLMs produce correct memo code and explain models to non-technical audiences.

Tools

Tool Purpose
validate_memo Compile-check memo code and report memo's compile-time warnings
critique_memo Compile verdict, idiom checks, and a plain-English round-trip readback
run_memo Execute memo code in an isolated subprocess
explain_memo Static analysis producing a plain-English model summary (agents, beliefs, choices, recursive structure)
narrate_results Run a memo function and return a labeled table with domain value names
compare_scenarios Run two parameter settings side-by-side for comparison
trace_reasoning Show the recursive execution flow (entry/exit, depth, timing)
inspect_compiled Show the generated JAX code for debugging
search_examples Keyword search across the 36 indexed demo programs, or "" to browse them all
get_handbook Return the memo Handbook: whole, by part, or by any heading (to_be, forgets_about, cost, ...)
list_patterns Browse 23 design pattern templates, each a complete script that runs as-is

Installation

Install memo-mcp once in a convenient location. It runs as a standalone service — your projects reference it via config, they don't need to embed it.

Requires Python 3.12+ (tested with 3.14). Works with either MCP SDK 1.x or 2.x — 2.0 renamed FastMCP to MCPServer, and the server imports whichever is present.

# Pick a location, e.g. ~/tools
git clone --recurse-submodules https://github.com/robert-johansson/memo-mcp.git
cd memo-mcp

python -m venv venv
venv/bin/pip install jax mcp memo-lang numpy matplotlib

If you already cloned without --recurse-submodules:

git submodule update --init

Check the installation (memo parity, every pattern template, the demo index, the Handbook lookup, and the stdio transport), in about 5 seconds:

venv/bin/python test_server.py

Usage with Claude Code

Add to your project's .mcp.json (or ~/.claude/mcp.json for global access), pointing to your memo-mcp installation:

{
  "mcpServers": {
    "memo-dsl": {
      "command": "/absolute/path/to/memo-mcp/venv/bin/python",
      "args": ["/absolute/path/to/memo-mcp/server.py"]
    }
  }
}

Your project is a separate repo with its own code and data. The MCP server runs alongside as a tool that Claude Code can call — no need to add memo-mcp as a submodule or dependency of your project.

Usage with other MCP clients

The server communicates over stdio and works with any MCP-compatible client:

venv/bin/python server.py

Repository layout

server.py        -- MCP server (all 11 tools)
examples.json    -- Search index covering all 36 demo programs
test_server.py   -- Regression checks (run with venv/bin/python)
memo/            -- Git submodule: the memo DSL, Handbook, and demos (pinned to v1.3.3)

Links