memsearch-mcp

memsearch-mcp

Provides hybrid vector+BM25+reranker search and index-refresh tools over agent memory stored in markdown files, enabling forge agents to query memory across session, working, and docs tiers without direct file access.

Category
访问服务器

README

memsearch-mcp

FastMCP server wrapping the memsearch semantic memory search library. Exposes hybrid vector+BM25+reranker search and index-refresh tools to forge agents over streamable-http MCP transport.

Overview

Agent memory on forge lives in markdown files across a three-tier hierarchy: session (per-project plugin dirs), working (~/.claude/memory/), and docs. memsearch-mcp lets agents query all of it with a single tool call — without reading files directly or knowing where they live.

Who uses it: All 5 forge resident agents (research, developer, writer, security, sysadmin) have memsearch-mcp in their scoped-mcp manifests. index_memory is denylisted for security, research, and writer.

Tools

Tool Description Key Parameters Returns
search_memory Hybrid vector+BM25+reranker search over Milvus-indexed agent memory query: str, limit: int = 10 list[dict] — results sorted by score
index_memory Trigger a memsearch index refresh for a path or default to ~/.claude/memory/ path: str | None {"indexed": N, "path": str}

search_memory result fields

Field Type Description
path str Absolute path to the source file
score float Relevance score (higher = more relevant)
snippet str Matching text chunk
heading str | null Nearest markdown heading above the chunk
tier str session, working, docs, or unknown
start_line int First line of the chunk in the source file
end_line int Last line of the chunk

index_memory path restrictions

index_memory accepts only paths under:

  • ~/.claude/memory/
  • ~/.claude/projects/
  • /opt/agents/memory/

Requests outside these roots are rejected with an error (not forwarded to the library).

Environment Variables

Variable Required Default Purpose
MEMSEARCH_MCP_PORT No 8493 Port for the streamable-http server
MEMSEARCH_API_TOKEN No (none) Bearer token for HTTP authentication. When set, all requests must include Authorization: Bearer <token>. Uses hmac.compare_digest() for constant-time comparison. Disabled when unset.
LOG_LEVEL No INFO structlog log level
MEMSEARCH_CONFIG No (library default) Path to memsearch config file

Installation

Requires Python 3.11+ and an existing memsearch venv with the memsearch library installed.

# From the memsearch venv (forge standard)
/opt/venvs/memsearch/bin/pip install -e /home/ted/repos/personal/memsearch-mcp

# Or from git
/opt/venvs/memsearch/bin/pip install "git+https://github.com/TadMSTR/memsearch-mcp.git"

Dependencies

  • fastmcp>=2.0
  • pydantic>=2.0
  • structlog>=24.0
  • memsearch (must be installed in the same venv — not in PyPI, install from source)

Deployment

PM2

ecosystem.config.js in the repo root:

module.exports = {
  apps: [{
    name: "memsearch-mcp",
    script: "/opt/venvs/memsearch/bin/python3",
    args: ["-m", "memsearch_mcp.server"],
    cwd: "/home/ted/repos/personal/memsearch-mcp",
    interpreter: "none",
    env: {
      LOG_LEVEL: "INFO",
      MEMSEARCH_MCP_PORT: "8493",
    },
  }]
};
pm2 start ecosystem.config.js
pm2 save

scoped-mcp wiring

Add to each agent manifest at ~/.claude/manifests/<agent>-agent.yml:

modules:
  memsearch-mcp:
    type: mcp_proxy
    config:
      url: http://127.0.0.1:8493/mcp
      headers:
        Authorization: "Bearer ${MEMSEARCH_API_TOKEN}"
      tool_denylist:
        - "index_memory"   # omit for developer and sysadmin

The headers config injects an Authorization header into every upstream request via scoped-mcp's mcp_proxy module. ${MEMSEARCH_API_TOKEN} is resolved from the agent's Vault-backed credentials at session start — agents never see the token value.

No restart of scoped-mcp is needed — manifests are loaded fresh on each agent session start.

Observability

Logs are written to ~/logs/memsearch-mcp.log (stdout + stderr merged, timestamped by PM2).

Log lines are JSON (structlog):

{"event": "search_memory", "query": "grafana dashboard", "limit": 10, "level": "info"}
{"event": "search_memory_done", "query": "grafana dashboard", "results": 7, "level": "info"}
{"event": "index_memory_dir_done", "path": "/home/ted/.claude/memory", "chunks": 412, "level": "info"}

Tool arguments are not included in logs — only query strings and result counts.

To check server health:

pm2 status memsearch-mcp

# Without auth (should return 401 when MEMSEARCH_API_TOKEN is set)
curl -s http://127.0.0.1:8493/mcp

# With auth
curl -s -H "Authorization: Bearer $MEMSEARCH_API_TOKEN" http://127.0.0.1:8493/mcp | head -5

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选