Lazy load MCP SDK client - #191
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Jason Winters (@jwin321) please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
Defers MCP SDK client and transport initialization until the SDK fallback path is needed, improving cached direct-call startup performance.
Changes:
- Lazily loads and caches the SDK client and transport.
- Adds a regression test confirming cached calls skip SDK construction.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
cli/test/unit/cache.test.ts |
Verifies the cached direct-call path avoids SDK construction. |
cli/src/mcp/client.ts |
Implements lazy SDK client and transport initialization. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Cached Learn MCP sessions can complete direct tool calls without initializing the SDK client or HTTP transport. This change defers those imports and client construction until the SDK fallback is actually needed, reducing startup work on the common cache fast path.
A unit test now confirms the cached direct-call path does not construct the SDK client.