sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

[CORRECTION] TypeScript MCP examples import from @modelcontextprotocol/sdk, hide the transport import, and never call disconnect()

Open sandhya-subramani opened this issue 3 weeks ago • 1 comments

Documentation Location

  • https://strandsagents.com/docs/user-guide/sdk/tools/mcp-tools/ (site/src/content/docs/user-guide/sdk/tools/mcp-tools.mdx and mcp-tools.ts)
  • https://strandsagents.com/docs/user-guide/sdk/tools/mcp-transports/ (mcp-transports.ts, sse_transport region)
  • https://strandsagents.com/docs/user-guide/harness/configure/mcp-servers/ (mcp-servers.mdx, TypeScript tab)

Current Content

Three things in the TypeScript MCP examples:

  1. The MCP tools page calls new StdioClientTransport(...) 11 times and no rendered block shows where it is imported from. The import is on line 2 of mcp-tools.ts, outside every included region.
  2. Where an import is shown, it names @modelcontextprotocol/sdk: '@modelcontextprotocol/sdk/client/sse.js' on the transports page and '@modelcontextprotocol/sdk/client/stdio.js' on the harness MCP servers page. The hidden import behind the quick start uses the same package.
  3. No TypeScript example on these pages calls disconnect(). The best-practices line on the MCP tools page reads "In Python, always use context managers" and has no TypeScript equivalent.

Correction Needed

  • @strands-agents/sdk declares @modelcontextprotocol/client ^2.0.0 as its peer dependency, and the package README imports from '@modelcontextprotocol/client/stdio'. Show the transport import in the quick start and use the @modelcontextprotocol/client/... paths in all three places.
  • End the stdio examples with await mcpClient.disconnect(), and say in one sentence that a stdio client keeps the Node process alive until it is disconnected.

Supporting Evidence

Tested in an empty folder with npm install @strands-agents/[email protected] (Node.js 25.8.1, macOS). npm installed @modelcontextprotocol/client, core, and ext-tasks.

Check Result
import('@modelcontextprotocol/sdk/client/stdio.js') ERR_MODULE_NOT_FOUND
import('@modelcontextprotocol/sdk/client/sse.js') ERR_MODULE_NOT_FOUND
import('@modelcontextprotocol/client/stdio') resolves
Script below, without disconnect() process still running 23 s after the last statement
Script below, with disconnect() process exits as soon as the last statement finishes
Script
import { McpClient } from '@strands-agents/sdk'
import { StdioClientTransport } from '@modelcontextprotocol/client/stdio'

const client = new McpClient({
  transport: new StdioClientTransport({
    command: process.execPath,
    // Any stdio MCP server; this one is the repo's integ-test fixture
    args: ['--import', 'tsx', 'strands-ts/test/integ/__fixtures__/test-mcp-server.ts'],
  }),
})
const tools = await client.listTools()
console.log('tools listed:', tools.length)
if (process.env.DISCONNECT) await client.disconnect()

Additional Information

Related: #5014 covers the SDK side (Agent.shutdown() never disconnects an McpClient). This issue is only about the docs.

Checked against main at 46cbb8c. This issue was drafted with an AI coding assistant; the checks above were run as described.

sandhya-subramani avatar Nov 14 '26 07:11 sandhya-subramani

Taking this.

Confirmed all three on current main: @strands-agents/sdk declares @modelcontextprotocol/client ^2.0.0 as its peer dep, but the three pages' TypeScript examples import from @modelcontextprotocol/sdk/client/stdio.js (and streamableHttp / sse / shared/transport) — which resolves to nothing under the v2 client package, exactly the ERR_MODULE_NOT_FOUND you measured.

I've switched them to the real paths (@modelcontextprotocol/client/stdio for the stdio transport; the root export carries StreamableHTTPClientTransport, SSEClientTransport, Transport and ElicitResult), shown the transport import in the quick start and on the transports page via the _imports.ts pattern the other pages already use, and ended the complete stdio examples with await …disconnect() plus the one-sentence note about the process staying alive.

Verification: the repo's own snippet typecheck (site/test-snippets, which tsc's every docs .ts against the built SDK) reports the same single pre-existing error as the untouched tree — zero new — and prettier is clean on all touched files.

I left the server-side example's imports alone: the v2 @modelcontextprotocol/server package has a different McpServer API (no .tool()), so changing it is a separate change.

Unless you're already on it.

insuffer avatar Nov 27 '26 06:11 insuffer