@@ -550,7 +550,14 @@ const client = new Client({
550550
551551// Create a StreamHTTP transport
552552const transport = new StreamableHTTPClientTransport (
553- new URL (' http://localhost:3000/mcp' )
553+ new URL (' http://localhost:3000/mcp' ),
554+ {
555+ requestInit: {
556+ headers: {
557+ ' Authorization' : ' Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
558+ }
559+ }
560+ }
554561);
555562
556563// Connect to the server
@@ -575,31 +582,7 @@ console.log('Tool result:', result);
575582await client .close ();
576583```
577584
578- ### SSE client (legacy)
579-
580- ``` typescript
581- import { Client } from ' @modelcontextprotocol/sdk/client/index.js' ;
582- import { SSEClientTransport } from ' @modelcontextprotocol/sdk/client/sse.js' ;
583-
584- // Create a client instance
585- const client = new Client ({
586- name: ' my-mcp-client' ,
587- version: ' 1.0.0'
588- });
589-
590- // Create an SSE transport
591- const transport = new SSEClientTransport (
592- new URL (' http://localhost:3000/sse' )
593- );
594-
595- // Connect to the server
596- await client .connect (transport );
597-
598- // Use the client...
599585
600- // Close the connection when done
601- await client .close ();
602- ```
603586
604587### Stdio client (process communication)
605588
@@ -616,7 +599,7 @@ const client = new Client({
616599// Create a Stdio transport and start the MCP server process
617600const transport = new StdioClientTransport ({
618601 command: ' node' ,
619- args: [' dist/ bootstrap.js' ],
602+ args: [' bootstrap.js' ],
620603 env: {
621604 NODE_ENV: ' production' ,
622605 // Inherit environment variables from the current process
@@ -661,7 +644,7 @@ await client.close();
661644Transport selection suggestions:
662645- StreamHTTP: Suitable for network services, microservices architectures, and web app integrations
663646- SSE: Legacy approach, mainly for backward compatibility
664- - Stdio: Suitable for command-line tools, local scripts, and desktop app integrations (e.g., Claude Desktop, Cursor, and other AI editors)
647+ - Stdio: Suitable for command-line tools, local scripts, and desktop app integrations (e.g., Claude Desktop, Cursor, Trae, and other AI editors)
665648:::
666649
667650### Editor integration
@@ -675,7 +658,7 @@ Example using stdio:
675658 "mcpServers" : {
676659 "my-midway-mcp-server" : {
677660 "command" : " node" ,
678- "args" : [" dist/ bootstrap.js" ],
661+ "args" : [" bootstrap.js" ],
679662 "env" : {
680663 "NODE_ENV" : " production"
681664 }
@@ -765,32 +748,7 @@ The JWT payload should contain the following standard fields:
765748}
766749```
767750
768- Client usage example:
769-
770- ``` typescript
771- // Client sends request with JWT token
772- const client = new Client ({
773- name: ' my-client' ,
774- version: ' 1.0.0'
775- });
776-
777- const transport = new StreamableHTTPClientTransport (
778- new URL (' http://localhost:3000/mcp' ),
779- {
780- headers: {
781- ' Authorization' : ' Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
782- }
783- }
784- );
785-
786- await client .connect (transport );
787751
788- // Now all tool calls will automatically include authentication information
789- const result = await client .callTool ({
790- name: ' secure_operation' ,
791- arguments: {}
792- });
793- ```
794752
795753
796754
@@ -999,7 +957,7 @@ A: The current version supports only one transport type per application instance
999957
1000958### Q: How do I debug MCP services?
1001959
1002- A: Use logging, MCP client tools for testing, or the official [ MCP Inspector ] ( https://github.com/modelcontextprotocol/ inspector ) .
960+ A: Use logging, MCP client tools for testing, or the official ` https://modelcontextprotocol.io/docs/tools/ inspector `
1003961
1004962## Related links
1005963
0 commit comments