Skip to main content

Local-first MCP tools: workflow routing/spec + keyword memory (JSON) with optional toggles.

Project description

agent-supervisor-memory (MCP server)

本目录提供一个 单进程 的 Python MCP server(stdio),默认启用:

  • workflow_*: 生成最小化 spec(lite/spike/heavy)+ 路由建议(模型/effort)
  • memory_*: 个人记忆(JSON 存储,关键词+tags+key 命名空间检索;无向量数据库/无 embedding)

MCP server ID:agent-supervisor-memory(见 mcp-tools/agent-supervisor-memory/src/agent_supervisor_memory/server.py)。

Quickstart

cd mcp-tools/agent-supervisor-memory
poetry install
poetry run agent-supervisor-memory --dispatch-dir "$HOME/.codex/codex-dispatch"

默认存储文件:

  • Memory:优先使用“最近的祖先目录中已存在的 .codex/”下的 .codex/memory.json;若不存在,则用 <cwd>/.codex/memory.json
  • Policy:同理,默认 .codex/agent-policy.json
  • Dispatch:--dispatch-dir 指定一个 base 目录,server 会按项目自动分桶:
    • <dispatch-dir>/<project_bucket>/<job_id>/{meta.json,stdout.jsonl,stderr.log,last_message.txt}
    • project_bucket 会尽量从 codex_dispatch_start(cwd=...) 的 cwd 向上推断(优先 .codex/,其次 .git/),并用 hash 保证稳定且不会太长
    • job_id 形如 <project_bucket>--<uuid>

说明:Poetry 会统一管理虚拟环境与依赖,避免你本机 shell 的 python/pip alias 干扰。

如何引用(MCP client 注册)

不同 MCP client 的配置方式不同,但核心信息通常是:

  • command: uvx
  • args: ["agent-supervisor-memory", "...flags"]

工具名引用方式是 tool name,例如:memory_searchworkflow_route

参考配置片段(TOML 风格)

如果你的 client 支持类似下面这种配置(你贴的 exa 例子就是这种风格),可以这样写:

[mcp_servers.supervisor_memory]
command = "uvx"
args = ["agent-supervisor-memory", "--dispatch-dir", "/ABS/PATH/TO/.codex/codex-dispatch"]

说明:

  • [mcp_servers.supervisor_memory] 里的 supervisor_memoryclient 侧别名,你可以随便取(只要不跟别的 server 重名)。
  • 是否“唯一”由你的 client 配置决定;PyPI 包名的唯一性是另一层(发布时)。

常用开关

[mcp_servers.supervisor_memory]
command = "uvx"
args = ["agent-supervisor-memory", "--dispatch-dir", "/ABS/PATH/TO/.codex/codex-dispatch", "--global-memory", "--global-policy"]

关闭某些能力(默认都是启用):

[mcp_servers.supervisor_memory]
command = "uvx"
args = ["agent-supervisor-memory", "--dispatch-dir", "/ABS/PATH/TO/.codex/codex-dispatch", "--no-memory", "--no-subagents", "--no-policy"]

高级覆盖(一般不需要)

为兼容少数 client 场景,仍保留路径覆盖参数(优先级最高;不建议作为默认配置):

agent-supervisor-memory --dispatch-dir /abs/path/to/codex-dispatch --memory-path /abs/path/to/memory.json --policy-path /abs/path/to/agent-policy.json

每次 tool 调用也可传:

  • options.enable_memory: true|false
  • options.enable_subagents: true|false

模型与模式(跨模型路由)

本 server 不直接调用模型;它只提供“建议路由”,由你的 Supervisor/Client 负责真正使用什么模型去执行。

  • policy_get: 读取策略文件
  • workflow_route: 根据任务文本 + mode/effort/auto 给出建议的 supervisor_model/coder_model/effort

默认配置:

  • Supervisor:codex-5.2
  • Coder:gpt-5.1-codex-max
  • saving:默认 effort=medium
  • efficient:默认 effort=medium

如何确认正在使用(VSCode/其他 client)

  • 调用 capabilities_get,查看返回里的 memory.mode / policy.modeproject|global|disabled)以及落盘 path
  • 写入/检索验证:memory_put 写入一条,然后 memory_search 搜索关键字。

VSCode:自动“主/子模型”分工(推荐)

如果你同时启用了:

  • mcp__supervisor_memory__*(本 server 的 tools)
  • mcp__codex__codex / mcp__codex__codex-reply(Codex MCP)

那么可以在一个 Supervisor 会话里自动启动 Coder 子会话,并显式指定 coder 使用 model=gpt-5.1-codex-max(或按策略自动选择):

  1. 生成最小 spec(供 coder 执行):
  • 调用 mcp__supervisor_memory__workflow_ensure_spec(输入你的任务文本)
  1. 获取路由建议(选择 coder 模型与 effort):
  • 调用 mcp__supervisor_memory__workflow_routetask_text 传上一步的 spec)
  1. 启动 coder 子会话并执行:
  • 调用 mcp__codex__codex,并设置:
    • cwd: 项目根目录
    • model: 上一步返回的 coder_model
    • prompt: spec + 约束(例如:只做必要改动、不要跑 build gate、先做最小校验)
  1. 迭代直至完成:
  • mcp__codex__codex-replyconversationId 为上一步返回)继续

如果 mcp__codex__codex 超时/返回类型不兼容

部分环境下,Codex MCP tool 可能会遇到 tool-call 超时(例如 60s)或 “Unexpected response type”。 此时可以改用本 server 自带的 dispatch 工具:它会在本机启动 codex exec 作为后台任务,并通过轮询查询结果。

流程:

  1. 启动任务(立即返回 job_id):
  • 调用 codex_dispatch_startmodelworkflow_route 返回的 coder_modelcwd 为项目根目录;prompt 传 spec)
  1. 轮询结果:
  • 调用 codex_dispatch_status(job_id=...) 直到 meta.status 变为 completed|failed
  • 成功时 last_message 会包含 codex 的最终输出(同时 job_dir 下会保留 stdout.jsonl/stderr.log
  • 默认 compact=true 仅返回精简 meta(基础字段),如需命令或产物路径请显式传 include_command=true / include_artifacts=true,或将 compact=false 保留完整响应。
  • 默认输出已压缩:成功/运行中只回传 stdout_tail(失败时回传 stderr_tail + exit_code),job_id/meta/artifacts 仅首次打印,避免占用对话上下文;如需原始/完整输出,请传 options={\"verbosity\":\"full\"}options={\"verbose\":true},或在启动 server 时设置 SUPERVISOR_MEMORY_VERBOSE=1(或 SUPERVISOR_MEMORY_VERBOSITY=full)。

Tools

  • capabilities_get
  • policy_get
  • memory_put
  • memory_search
  • memory_delete
  • memory_compact(生成 profile.json,把“杂乱记忆”压缩为分类摘要)
  • workflow_ensure_spec
  • workflow_route
  • subagents_echo(示例)
  • codex_dispatch_start(启动 codex exec 后台任务)
  • codex_dispatch_status(轮询任务状态/输出)

发布到 PyPI(维护者)

PyPI 不允许覆盖已发布的同版本号,所以每次发布前都需要 bump version。

cd mcp-tools/agent-supervisor-memory

# 1) bump version(示例:0.1.0 -> 0.1.1)
poetry version patch

# 2) build
poetry build

# 3) publish(推荐用 token)
poetry publish -u __token__ -p "$PYPI_TOKEN"

可选:发布到 TestPyPI(先验证安装/依赖/元数据):

poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry publish -r testpypi -u __token__ -p "$TESTPYPI_TOKEN"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

agent_supervisor_memory-0.2.2.tar.gz (23.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

agent_supervisor_memory-0.2.2-py3-none-any.whl (24.2 kB view details)

Uploaded Python 3

File details

Details for the file agent_supervisor_memory-0.2.2.tar.gz.

File metadata

  • Download URL: agent_supervisor_memory-0.2.2.tar.gz
  • Upload date:
  • Size: 23.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.14.2 Darwin/24.6.0

File hashes

Hashes for agent_supervisor_memory-0.2.2.tar.gz
Algorithm Hash digest
SHA256 65308be90b4c5233dc151b6a40456ab881c40b6f96668b5e80e6932834ee0d9d
MD5 d3f5d4a334159395a7b7a9bf1c97a446
BLAKE2b-256 837f31e4021f2f3b3e5a469b23445aad7945b1051088a5f9869d806028ee1e76

See more details on using hashes here.

File details

Details for the file agent_supervisor_memory-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agent_supervisor_memory-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 64da132808d54f8cd68e74e5b4941d034d4d2a0f72c9f3984274a8a702dde25a
MD5 aa25abf5658c894389315e7f511b21b0
BLAKE2b-256 f038e62e70e5331effc94b4bd991c4408154c15b988dfa453ecbbd32c1351a9d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page