插件式MCP服务器

Memex是一个基于插件的MCP服务器,为兼容MCP的AI代理提供个人SOP、平台操作工具和服务器端提示的访问,并作为所有其他MCP服务器的中央注册表。

  • by HaoZ-Work
  • Python
  • 本地部署
  • 更新于
在 GitHub 查看 HaoZ-Work/memex

使用说明

模因

个人第二大脑MCP中心。以Vannevar Bush 1945年的概念命名。

Memex是一个 基于插件的MCP服务器 这为任何与MCP兼容的AI代理提供了支持 访问您的个人SOP、平台操作工具和服务器端提示。 它还充当所有其他MCP服务器的中央注册表 (官方和习俗),所以一个单一 ./scripts/install.sh 配置一切。

memex 也旨在作为上游模板仓库进行维护。如果你 想要长期进行个人默认、实验或私人布线, fork它,并在下游仓库中完成这项工作,同时保持运行时 产品名称 memex.

memex-knowledge/   ← your personal knowledge (Markdown + YAML)
memex/             ← this repo — the MCP hub
  plugins/         ← each capability as an independent plugin
  config/mcps.yaml ← which MCPs and plugins to enable
  scripts/install.sh ← one-shot setup for any machine

快速启动(新机器)

# 1. Clone the hub
git clone git@github.com:<you>/memex.git

# 2. Clone your knowledge base
git clone git@github.com:<you>/memex-knowledge.git memex/knowledge

# 3. Install dependencies
cd memex && uv sync

# 4. Edit config (choose which MCPs / plugins to enable)
#    Add secrets to config/mcps.local.yaml  (gitignored)
cp config/mcps.local.yaml.example config/mcps.local.yaml
$EDITOR config/mcps.local.yaml

# 5. Register everything with your MCP client
./scripts/install.sh

# 6. Reload your MCP client
#    Claude Code (VSCode):  Cmd/Ctrl+Shift+P → "Developer: Reload Window"
#    Codex:                 restart the CLI

如果您计划在GitHub上维护个人工作副本,建议 模型是叉 memex 并将您的fork用作日常回购。保持稳定 通过PR向上游回流的通用改进。看 docs/FORK_WORKFLOW.md 对于完整的模型。


注册内容

install.sh 写入 ~/.claude.json (克劳德代码)基于 config/mcps.yaml:

条目 类型 它的作用
memex stdio进程 您的自定义插件(知识+操作+提示)
github HTTP GitHub Copilot MCP(官方)
notion HTTP 通知MCP——在配置中启用+添加令牌

在代理会话中使用工具

克劳德代码

安装并重新加载窗口后,所有工具都显示为延迟工具。

# Auto-detect workspace context
memex_workspace_autodetect()

# Read an SOP document
@memex://signal-research/overfitting-checklist
@memex://platform-engineering/gitops-release

# Trigger a server-assembled prompt
/mcp__memex__review_signal
/mcp__memex__deploy_checklist

# Query the cluster
k8s_logs_get("staging", "executor-polymarket")
argocd_app_get("staging", "executor-polymarket")
host_status_get("staging")

法典

添加 ~/.codex/config.yaml:

mcp:
  servers:
    - name: memex
      command: /home/<you>/.local/bin/uv
      args:
        - run
        - --project
        - /path/to/memex
        - python
        - /path/to/memex/server.py
      env:
        KNOWLEDGE_PATH: /path/to/memex/knowledge
        MEMEX_PLUGINS: knowledge,platform_ops,prompts

任何其他MCP兼容客户端(Cursor、Gemini等)

向客户指出 server.py 和 stdio 运输:

command: uv run --project /path/to/memex python /path/to/memex/server.py
env:
  KNOWLEDGE_PATH: /path/to/memex/knowledge
  MEMEX_PLUGINS: knowledge,platform_ops,prompts

服务器使用 仅限stdio传输 --无端口、无HTTP、无需身份验证 从客户端。


配置

config/mcps.yaml

所有MCP的单一真相来源。分叉此仓库并编辑此文件。

official_mcps:
  github:
    enabled: true
    type: http
    url: "https://api.githubcopilot.com/mcp/"

  notion:
    enabled: false          # flip to true + add token in mcps.local.yaml
    type: http
    url: "https://mcp.notion.so/sse"
    auth:
      type: bearer
      env_var: NOTION_TOKEN

custom_plugins:
  knowledge:    { enabled: true }   # always loaded
  platform_ops: { enabled: true }   # k8s / argocd / host tools
  prompts:      { enabled: true }   # review_signal / deploy_checklist

config/mcps.local.yaml (忽略)

本地覆盖——令牌、路径。从示例中复制:

cp config/mcps.local.yaml.example config/mcps.local.yaml
chmod 600 config/mcps.local.yaml

示例内容:

official_mcps:
  notion:
    enabled: true
    auth:
      token: "secret_xxxx..."

模板工作流

建议的长期设置是:

  • memex 作为上游模板存储库
  • 你自己的叉子,比如 hao-memex,作为个人下游回购
  • memex 作为运行时服务器名称和MCP前缀,甚至在fork内部

使用下游叉进行个人布线和实验。当发生变化时 稳定且通用,将其作为重点PR发送回上游。

这是一个存储库工作流,而不是知识库工作流。它没有 改变治理 memex-knowledge, hao-knowledge,或任何未来 知识分叉。

看 docs/FORK_WORKFLOW.md 对于整个工作流程, 促销清单,以及 origin / upstream 模型。


插件引用

内置插件公开的所有工具:

工具 插件 描述
memex_list_domains 知识 列出知识领域及其SOP
memex_workspace_set 知识 手动设置活动域
memex_workspace_autodetect 知识 从MCP根自动检测域
memex_inventory_get platform_ops 平台清单(envs/apps/hosts)
k8s_resource_get platform_ops Kubernetes资源查询
k8s_logs_get platform_ops Pod日志
k8s_events_get platform_ops Kubernetes事件
argocd_app_get platform_ops ArgoCD单应用程序状态
argocd_app_list platform_ops 环境中的所有ArgoCD应用程序
host_status_get platform_ops 主机运行状况(正常运行时间/内存/磁盘)
host_service_status_get platform_ops 系统服务状态
host_container_list platform_ops Docker容器列表
host_journal_get platform_ops systemd日志
memex_review_signal_tool 提示 review_signal 提示作为工具(回退)
memex_deploy_checklist_tool 提示 deploy_checklist 提示作为工具(回退)

资源 (使用 @ 克劳德代码):

memex://{domain}/{doc}
# e.g. @memex://signal-research/overfitting-checklist

提示 (使用 / 克劳德代码):

/mcp__memex__review_signal
/mcp__memex__deploy_checklist

添加插件

看 插件/PLUGIN_GUIDE.md.


回购结构

memex/
├── server.py                  ← pure loader (~120 lines)
├── core/                      ← generic infrastructure only
│   ├── plugin.py              ← Plugin base class + PluginContext
│   ├── runner.py              ← CommandRunner (local + SSH)
│   └── errors.py              ← MemexError, ValidationError, ConfigError
├── plugins/
│   ├── knowledge.py           ← SOP resources + workspace tools
│   ├── platform_ops/          ← 10 ops tools (k8s/argocd/host)
│   │   ├── __init__.py        ← plugin class + tool registration
│   │   ├── inventory.py       ← PlatformInventory (reads workflow-map.yaml)
│   │   ├── k8s.py / argocd.py / host.py
│   ├── prompts.py             ← generic YAML loader (zero business logic)
│   └── PLUGIN_GUIDE.md        ← how to add a plugin
├── config/
│   ├── mcps.yaml              ← ★ edit this to configure your MCPs
│   └── mcps.local.yaml.example
├── scripts/
│   └── install.sh             ← syncs mcps.yaml → ~/.claude.json
├── knowledge/                 ← symlink to memex-knowledge repo
│   └── prompts/               ← prompt definitions live here (YAML), not in code
└── CLAUDE.md                  ← AI agent context (read this first)

安全

  1. 只读操作: plugins/platform_ops/ 仅执行GET/READ命令
  2. 回购中没有凭据:代币进入 config/mcps.local.yaml (忽略) 或环境变量——从不在 mcps.yaml
  3. 域隔离:SOP资源的范围为 memex://{domain}/ — 一个域无法访问另一个域的文件

知识库

这 knowledge/ 目录是指向您的私有知识仓库的符号链接。 在启动时, server.py 跑 git pull --ff-only 以保持同步。

分叉 模因知识 创造 您自己的私人知识库,然后连接它:

rm knowledge                          # remove placeholder symlink
ln -s ~/your-knowledge knowledge      # point at your repo

看 docs/KNOWLEDGE_SETUP.md 查看完整的设置指南。

添加内容(无需更改代码)

新SOP:

echo "# My SOP" > knowledge/platform-engineering/sop/my-runbook.md
cd knowledge && git add . && git commit -m "add my-runbook" && git push

可用作 @memex://platform-engineering/my-runbook.

新提示:

cat > knowledge/prompts/my_prompt.yaml << 'EOF'
name: my_prompt
description: "What this prompt does"
args:
  - topic
sops:
  my_sop: my-domain/my-sop-name
template: |
  Evaluate "{topic}" against:

  {my_sop}

  Provide specific recommendations.
EOF
cd knowledge && git add . && git commit -m "add my_prompt" && git push

可用作 /mcp__memex__my_prompt (克劳德代码)或 memex_my_prompt_tool.