Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
tools() calls client.listTools() for every connected MCP server on every invocation. Since tools() is called in the core loop on each iteration via prompt.ts, this causes N×M redundant network roundtrips.
Solution
Add an in-memory Map cache for listTools results per server. Cache is invalidated on:
ToolListChanged notification from server
connect() / add() / disconnect()
State shutdown
Impact
3 servers × 10 calls: 30 requests → 3 (90% reduction, ~540ms saved at 20ms/request)
Risk: Minimal — all state change paths invalidate the cache.
Feature hasn't been suggested before.
Describe the enhancement you want to request
Problem
tools() calls client.listTools() for every connected MCP server on every invocation. Since tools() is called in the core loop on each iteration via prompt.ts, this causes N×M redundant network roundtrips.
Solution
Add an in-memory Map cache for listTools results per server. Cache is invalidated on:
ToolListChanged notification from server
connect() / add() / disconnect()
State shutdown
Impact
3 servers × 10 calls: 30 requests → 3 (90% reduction, ~540ms saved at 20ms/request)
Risk: Minimal — all state change paths invalidate the cache.