Skip to content

Commit fec3874

Browse files
committed
docs: update mcp documents
1 parent 038a895 commit fec3874

File tree

2 files changed

+25
-107
lines changed
  • site
    • docs/extensions
    • i18n/en/docusaurus-plugin-content-docs/current/extensions

2 files changed

+25
-107
lines changed

site/docs/extensions/mcp.md

Lines changed: 13 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -422,32 +422,7 @@ JWT payload 应包含以下标准字段:
422422
}
423423
```
424424

425-
客户端使用示例。
426425

427-
```typescript
428-
// 客户端发送带有 JWT token 的请求
429-
const client = new Client({
430-
name: 'my-client',
431-
version: '1.0.0'
432-
});
433-
434-
const transport = new StreamableHTTPClientTransport(
435-
new URL('http://localhost:3000/mcp'),
436-
{
437-
headers: {
438-
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
439-
}
440-
}
441-
);
442-
443-
await client.connect(transport);
444-
445-
// 现在所有的工具调用都会自动包含认证信息
446-
const result = await client.callTool({
447-
name: 'secure_operation',
448-
arguments: {}
449-
});
450-
```
451426

452427

453428

@@ -756,7 +731,14 @@ const client = new Client({
756731

757732
// 创建 StreamHTTP 传输
758733
const transport = new StreamableHTTPClientTransport(
759-
new URL('http://localhost:3000/mcp')
734+
new URL('http://localhost:3000/mcp'),
735+
{
736+
requestInit: {
737+
headers: {
738+
'Authorization': 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...'
739+
}
740+
}
741+
}
760742
);
761743

762744
// 连接到服务器
@@ -781,31 +763,7 @@ console.log('Tool result:', result);
781763
await client.close();
782764
```
783765

784-
### SSE 客户端 (传统方式)
785-
786-
```typescript
787-
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
788-
import { SSEClientTransport } from '@modelcontextprotocol/sdk/client/sse.js';
789766

790-
// 创建客户端实例
791-
const client = new Client({
792-
name: 'my-mcp-client',
793-
version: '1.0.0'
794-
});
795-
796-
// 创建 SSE 传输
797-
const transport = new SSEClientTransport(
798-
new URL('http://localhost:3000/sse')
799-
);
800-
801-
// 连接到服务器
802-
await client.connect(transport);
803-
804-
// 使用客户端...
805-
806-
// 使用完毕后关闭连接
807-
await client.close();
808-
```
809767

810768
### Stdio 客户端 (进程通信)
811769

@@ -822,7 +780,7 @@ const client = new Client({
822780
// 创建 Stdio 传输,启动 MCP 服务器进程
823781
const transport = new StdioClientTransport({
824782
command: 'node',
825-
args: ['dist/bootstrap.js'],
783+
args: ['bootstrap.js'],
826784
env: {
827785
NODE_ENV: 'production',
828786
// 继承当前进程的环境变量
@@ -867,7 +825,7 @@ await client.close();
867825
**传输类型选择建议**
868826
- **StreamHTTP**: 适用于网络服务、微服务架构、Web 应用集成
869827
- **SSE**: 传统方式,主要用于向下兼容
870-
- **Stdio**: 适用于命令行工具、本地脚本、桌面应用集成(如 Claude Desktop、Cursor 等 AI 编辑器)
828+
- **Stdio**: 适用于命令行工具、本地脚本、桌面应用集成(如 Claude Desktop、Cursor、Trae 等 AI 编辑器)
871829
:::
872830

873831
### 与编辑器集成
@@ -881,7 +839,7 @@ stdio 示例如下:
881839
"mcpServers": {
882840
"my-midway-mcp-server": {
883841
"command": "node",
884-
"args": ["dist/bootstrap.js"],
842+
"args": ["bootstrap.js"],
885843
"env": {
886844
"NODE_ENV": "production"
887845
}
@@ -1005,6 +963,8 @@ A: 当前版本每个应用实例只支持一种传输类型。如需支持多
1005963

1006964
A: 使用日志记录、MCP 客户端工具进行测试,或者使用官方提供的 [MCP Inspector](https://modelcontextprotocol.io/docs/tools/inspector)
1007965

966+
967+
1008968
## 相关链接
1009969

1010970
- [MCP 官方文档](https://modelcontextprotocol.io/)

site/i18n/en/docusaurus-plugin-content-docs/current/extensions/mcp.md

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,14 @@ const client = new Client({
550550

551551
// Create a StreamHTTP transport
552552
const 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);
575582
await 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
617600
const 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();
661644
Transport 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

Comments
 (0)