feat: start MCP servers on first call and keep stored tool lists fresh #43
Loading…
Reference in a new issue
No description provided.
Delete branch "feature/lazy-upstream-start"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Agents'
tools/listno longer starts a runner process per server. Lazy servers (the new default) answer from the tools stored at their last listing and start on the firsttools/call.Stored lists stay current through
ToolRefresher:upstream_tool_listsholds one row per process key:user_idnull for a shared process, one row per user for a per-user server. A per-user row is shown only to that user. The sharedserver_toolscatalog is unchanged, and per-user tools still never go into it.TOOL_REFRESH_INTERVAL_HOURS,TOOL_REFRESH_CONCURRENCY,TOOL_REFRESH_ACTIVE_DAYS(documented in.env.exampleanddocs/configuration.md).Evidence
tools/listattached one runner process per ready server, so connecting a client spawned all of them.After:
apps/api/test/lazy-start.test.ts(10 tests):The full CI script (
nix develop -c ./scripts/ci.sh) passes: lint, typecheck, API 325, runner 46, web 149, shared 5, build, andnpm auditwith 0 vulnerabilities.Merge Danger
Door: two-way
The migration only adds things: an enum, a column with a default, and a table. Reverting the code leaves them unused and harmless.
Blast Radius: every server
lazy. Its first tool call is slower (cold start), and its tool list can be up to one refresh interval old. An admin can switch a server back to eager on its overview.trail checkflagsapp.ts,config.ts,schema.tsandupstream/index.tsagainst old learnings (hand-written or admin tools on/mcp, catalog re-enabling). They are keyword matches. No MCP tools are added, and stored lists never writeenabled; the gateway still applies the admin's tool switch to them (tested).🤖 Generated with Claude Code