nexus

nexus

Acts as an MCP gateway aggregating multiple child MCP servers into a single namespaced interface, with an optional memory layer that caches tool results to reduce redundant calls.

Category
访问服务器

README

Nexus — MCP Aggregator with a Memory Layer

Nexus connects many MCP servers (Jira, GitHub, Postgres, …) behind a single MCP gateway, and (in a later phase) adds a memory layer so repeated or semantically similar tool calls are served from memory instead of re-invoking the underlying tools every time.

Status (v0.1): the aggregation layer, memory layer (per-tool TTL, semantic cache, gray-zone verifier), and encrypted secret storage (OS keychain) are built and tested. Memory caches cacheable (read-only/idempotent) tool results — exact-key and high-similarity hits serve with no tool call; misses forward and store. See Memory layer and Secrets.

📖 Full user guide & roadmap: docs/Nexus_Guide.md. 📚 Command handbook (every command/flag/transport): docs/Nexus_Handbook.md. 🧪 How to install, use, and test it: docs/Testing_Guide.md.

Shape (decided)

Nexus is an MCP gateway/proxy: it is itself an MCP server. A downstream client (Claude Desktop, Cursor, any MCP client) connects to Nexus; Nexus fans out to the child MCP servers you configure, merges their tools into one namespaced manifest, and forwards tools/call to the owning server.

  • Runtime: local daemon + CLI. Config and (later) memory DB live in NEXUS_HOME (default ~/.nexus). Secrets via OS keychain in a later phase.
  • Tool namespacing: <server>.<tool> (dots are allowed in MCP tool names, per SEP-986). Example: jira.get_issue, github.search.
  • Live reload: adding/removing a server re-runs discovery and emits notifications/tools/list_changed.

Quick start

npm install
npm run typecheck      # tsc --noEmit
npm test               # unit + end-to-end (in-memory MCP transports)
npm run build          # → dist/index.js (the `nexus` binary)

Add a server from the curated catalog, then run the gateway:

# Catalog install (prompts for required env if missing)
nexus add memory                       # knowledge-graph MCP, no auth — good first test
nexus add github                      # errors until you pass GITHUB_PERSONAL_ACCESS_TOKEN
nexus add github --env GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxx

# Freeform install (use `--` before dash-leading args like npx's -y)
nexus add mygit --transport stdio --command npx \
  --env GITHUB_PERSONAL_ACCESS_TOKEN=ghp_xxx -- -y @modelcontextprotocol/server-github

# Remote server
nexus add remotething --transport streamable-http --url https://example.com/mcp \
  --header Authorization=Bearer xyz

nexus list-servers                    # show configured child servers
nexus list-tools                      # connect live + print the merged manifest
nexus serve                           # run the MCP gateway on stdio

Point a client at it

Add Nexus to your MCP client config as a stdio server, e.g. for Claude Desktop:

{
  "mcpServers": {
    "nexus": { "command": "node", "args": ["/abs/path/to/nexus/dist/index.js", "serve"] }
  }
}

All child servers' tools then appear under the nexus.* (well, <server>.*) namespace in that client.

CLI reference

nexus serve                                  Run the MCP gateway over stdio
nexus list-servers [--json|-j]               Show configured child servers
nexus list-tools [--json|-j]                 Connect + show the merged tool manifest
nexus add <catalog-name> [--env K=V]...      Install from the curated catalog
nexus add <name> --transport <t> [...]       Freeform install (stdio|sse|streamable-http)
nexus remove <name>                          Remove a configured server
nexus help

All logs go to stderr; stdout is reserved for the MCP wire protocol while serving.

Project structure

src/
  aggregation/   connectionManager · discovery · namespace · manifest · registry
  config/        schema (zod) · store · catalog · paths
  server/        gateway.ts — Nexus-as-MCP-server (merged tools/list + tools/call)
  cli/           index (router) · commands
  types.ts · logging.ts · version.ts · index.ts (public API)
catalog/servers.json   curated install specs (extend at ~/.nexus/catalog.json)
tests/                 namespace · manifest · end-to-end (in-memory transports)

Key design notes (for contributors)

  • Tool namespacing & routing: the merged tools/list rewrites each tool name to <server>.<original>. A separate route table maps each namespaced name back to (server, originalName) — the client never sees routing metadata.
  • Cacheability seam: isCacheableTool(tool) derives from MCP annotations (readOnlyHint/idempotentHint → cacheable; destructiveHint → never). The memory layer will consume this; it is not used to filter the manifest.
  • ConnectionManager supports stdio, sse, and streamable-http. Stdio child stderr is surfaced in Nexus logs. A transport factory is injectable for tests (see tests/registry.integration.test.ts).
  • Validation: zod handles shape/defaults; transport-conditional rules (stdio needs command, remote needs url) live in validateServerConfig.

Memory layer

Opt-in. On nexus serve, enable it with one of:

  • OPENAI_API_KEY → OpenAI text-embedding-3-small (1536-dim).
  • NEXUS_EMBEDDING=hash → offline deterministic embedder (testing / air-gapped; not semantically meaningful).

With memory on, a tools/call to a cacheable tool (MCP annotations readOnlyHint/idempotentHint, not destructiveHint) is intercepted:

  1. Exact args-fingerprint hit → served from memory, no child call (the fast path — no embedding needed).
  2. Otherwise embed the call and run a nearest-neighbor search (sqlite-vec):
    • similarity ≥ 0.92 → served (semantic hit)
    • 0.85–0.92 → gray zone → an LLM verifier decides (accept serves cached; reject refetches). No verifier/key → refetch.
    • below → miss
  3. Miss → forward to the child; store the result if it isn't an error.

Structurally distinct args (env:"staging" vs "production") have different fingerprints → separate entries, so the staging/production trap is avoided before similarity is even consulted.

Store: SQLite (~/.nexus/memory.db) + sqlite-vec, via Node's built-in node:sqlite (no native build). Removing a server drops its cache entries.

Per-tool TTL (entity snapshots)

By default cacheable results never expire (stable knowledge). Override volatile tools in ~/.nexus/config.json:

{
  "ttl": {
    "jira.get_issue": "1d",   // ticket status refreshes daily
    "github.*": "12h",        // all tools from a server
    "*": "30s"                // global fallback
  }
}

Precedence: exact <server>.<tool> > <server>.* > * > Infinity. Values are durations (30s, 5m, 12h, 1d, ms number) or never. Expired entries are refetched on next call.

Secrets

Secrets (tokens, API keys) are stored encrypted in the OS keychain — never in config.json. On nexus add:

  • --env K=V → stored in the keychain (recorded as secretEnv in config).
  • --plain-env K=V → plaintext in config (for non-secrets like base URLs).

At nexus serve, each server's secretEnv is resolved from the keychain and injected into the child's spawn env. nexus remove purges that server's secrets. If the OS keychain is unavailable, --env falls back to plaintext config with a warning.

Current limitations (deliberate, v0.1)

  • TTL defaults to infinite — stable tools cache forever; volatile tools need an explicit override (above). No automatic "this tool looks time-sensitive" heuristic.
  • No "serve stale + freshness signal" — expired entries are treated as misses (refetched), not returned with a staleness flag. This deviates from PRD §4.2's confirm-to-refetch flow, which doesn't fit a non-interactive gateway.
  • LLM verifier needs a key — without OPENAI_API_KEY, gray-zone matches refetch (no verify).

See docs/Nexus_MCP_PRD.md for the full design rationale.

推荐服务器

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

官方
精选