GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - andrebrov/mcp-hub: One shared instance of each stdio MCP server, served to every coding agent over streamable HTTP. Lazy spawn, idle reaping, per-root pooling.

BranchesTags
Open more actions menu

Latest commit

 

History

1 Commit
1 Commit

Folders and files

NameName
Last commit message
Last commit date
examples
examples
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
check.mjs
check.mjs
 
 
hub.mjs
hub.mjs
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 

Repository files navigation

mcp-hub

One shared instance of each stdio MCP server, served to every agent over streamable HTTP.

Coding agents (Claude Code, OpenCode, Codex, Grok, Cursor) start a fresh copy of every stdio MCP server for every session. Run a few agents in parallel and the same server is running ten or twenty times. On the machine this was written for that was 66 processes and 8 GB of RAM for servers that were idle most of the day.

mcp-hub runs each server once, lazily, and hands it to every session over the MCP streamable-HTTP transport that all of those harnesses already support:

  • one child per server, spawned on the first request, shared by every session
  • idle reaping: a child with no requests for idleMinutes is killed; a client's session survives that, the next call respawns the child transparently
  • per-root pooling for servers that index their working directory (one child per root)
  • GET /status tells you what is alive, its pid, RSS, sessions and idle time

Install

git clone https://github.com/andrebrov/mcp-hub && cd mcp-hub && npm install
cp examples/mcp-hub.example.json ~/.config/mcp-hub.json   # edit
node hub.mjs                      # or: node hub.mjs /path/to/config.json

Requires Node 20+. The only dependency is @modelcontextprotocol/sdk.

Config

~/.config/mcp-hub.json (or $MCP_HUB_CONFIG, or the first argument):

{
  "port": 7900,
  "idleMinutes": 20,
  "requestTimeoutMinutes": 20,
  "servers": {
    "context7":  { "command": "npx", "args": ["-y", "@upstash/context7-mcp"] },
    "github":    { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-github"],
                   "env": { "GITHUB_PERSONAL_ACCESS_TOKEN": "..." } },
    "codegraph": { "command": "codegraph", "args": ["serve", "--mcp", "-p", "{root}"],
                   "cwd": "{root}", "perRoot": true }
  }
}

Each server becomes http://127.0.0.1:7900/<name>/mcp. Children inherit the hub's environment plus env. For perRoot servers the client passes ?root=/abs/path or an X-Root header, and {root} in args/cwd is replaced with it.

Point your agents at it

Claude Code (.mcp.json in the project, or claude mcp add --transport http):

{ "mcpServers": { "context7": { "type": "http", "url": "http://127.0.0.1:7900/context7/mcp" } } }

OpenCode (~/.config/opencode/opencode.json). {env:PWD} gives per-root servers the session's own directory:

{ "mcp": {
  "context7":  { "type": "remote", "url": "http://127.0.0.1:7900/context7/mcp", "enabled": true },
  "codegraph": { "type": "remote", "url": "http://127.0.0.1:7900/codegraph/mcp",
                 "headers": { "X-Root": "{env:PWD}" }, "enabled": true }
} }

Codex (~/.codex/config.toml) and Grok (~/.grok/config.toml):

[mcp_servers.context7]
url = "http://127.0.0.1:7900/context7/mcp"

Grok also imports Cursor's and Claude's MCP lists by default; turn that off with [compat.cursor] mcps = false / [compat.claude] mcps = false or you get both copies.

Run it as a service

macOS: examples/com.example.mcp-hub.plist goes in ~/Library/LaunchAgents (edit the paths), then launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.example.mcp-hub.plist. After editing the hub: launchctl kickstart -k gui/$(id -u)/com.example.mcp-hub.

Linux: examples/mcp-hub.service is a systemd user unit (systemctl --user enable --now mcp-hub).

Check it

node check.mjs http://127.0.0.1:7900/context7/mcp                     # handshake + tool list
node check.mjs http://127.0.0.1:7900/github/mcp search_repositories '{"query":"mcp"}'
curl -s http://127.0.0.1:7900/status | jq

What it does not do

  • Isolation between sessions. All sessions on a child share that child's state, and a notification the child emits (tool list changed, log message) reaches every session. That is right for tool servers; do not put a server that keeps secret per-session state behind the hub.
  • Auth. It binds to 127.0.0.1 only and has no authentication. Do not expose the port.
  • Requests that outlive the idle window. The reaper only looks at when the last request started, so a single tool call longer than idleMinutes can be cut off. Raise idleMinutes for servers with very long calls; the next request spawns a fresh child.

License

MIT

About

One shared instance of each stdio MCP server, served to every coding agent over streamable HTTP. Lazy spawn, idle reaping, per-root pooling.

Resources

Readme
MIT license
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.