Toolset represents a set of MCP tools. Connection lifecycle (initial connect, watcher goroutine, restart with backoff, graceful Stop) is delegated to a *lifecycle.Supervisor; the historical watchConnection / tryRestart / forceReconnectAndWait helpers have been replaced by the supervisor's Start / R
| 162 | // historical watchConnection / tryRestart / forceReconnectAndWait helpers |
| 163 | // have been replaced by the supervisor's Start / RestartAndWait / Stop. |
| 164 | type Toolset struct { |
| 165 | name string |
| 166 | mcpClient mcpClient |
| 167 | logID string |
| 168 | description string // user-visible description, set by constructors |
| 169 | instructions string |
| 170 | |
| 171 | supervisor *lifecycle.Supervisor |
| 172 | |
| 173 | mu sync.Mutex |
| 174 | |
| 175 | // Cached tools and prompts, invalidated via MCP notifications and |
| 176 | // supervisor disconnect callbacks. cacheGen is bumped on each |
| 177 | // invalidation so that a concurrent Tools()/ListPrompts() call can |
| 178 | // detect that its result is stale and drop it. |
| 179 | cachedTools []tools.Tool |
| 180 | cachedPrompts []PromptInfo |
| 181 | cacheGen uint64 |
| 182 | |
| 183 | // toolsChangedHandler is called after the tool cache is refreshed |
| 184 | // following a ToolListChanged notification from the server, or after |
| 185 | // a successful supervisor reconnect. |
| 186 | toolsChangedHandler func() |
| 187 | } |
| 188 | |
| 189 | // invalidateCache clears the cached tools and prompts and bumps the |
| 190 | // generation counter. The caller must hold ts.mu. |
nothing calls this directly
no outgoing calls
no test coverage detected