@mastra/mcp-docs-server 1.0.0-beta.6 → 1.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +12 -12
  2. package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +10 -10
  3. package/.docs/organized/changelogs/%40mastra%2Fastra.md +10 -10
  4. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +12 -12
  5. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +48 -48
  6. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +65 -65
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +48 -48
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +48 -48
  9. package/.docs/organized/changelogs/%40mastra%2Fcodemod.md +6 -0
  10. package/.docs/organized/changelogs/%40mastra%2Fconvex.md +47 -0
  11. package/.docs/organized/changelogs/%40mastra%2Fcore.md +196 -196
  12. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +11 -11
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +19 -19
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +27 -27
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +48 -48
  16. package/.docs/organized/changelogs/%40mastra%2Felasticsearch.md +9 -0
  17. package/.docs/organized/changelogs/%40mastra%2Flance.md +48 -48
  18. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +48 -48
  19. package/.docs/organized/changelogs/%40mastra%2Floggers.md +40 -40
  20. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +16 -16
  21. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +43 -43
  22. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +10 -10
  23. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +48 -48
  24. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +48 -48
  25. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +10 -10
  26. package/.docs/organized/changelogs/%40mastra%2Fpg.md +52 -52
  27. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +10 -10
  28. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +41 -41
  29. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +10 -10
  30. package/.docs/organized/changelogs/%40mastra%2Freact.md +14 -0
  31. package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +9 -0
  32. package/.docs/organized/changelogs/%40mastra%2Fserver.md +65 -65
  33. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +10 -10
  34. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +48 -48
  35. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +10 -10
  36. package/.docs/organized/changelogs/create-mastra.md +7 -7
  37. package/.docs/organized/changelogs/mastra.md +14 -14
  38. package/.docs/organized/code-examples/ai-elements.md +1 -1
  39. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  40. package/.docs/organized/code-examples/ai-sdk-v5.md +1 -1
  41. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  42. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
  43. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
  44. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  45. package/.docs/organized/code-examples/mcp-server-adapters.md +2 -2
  46. package/.docs/organized/code-examples/server-app-access.md +2 -2
  47. package/.docs/organized/code-examples/server-express-adapter.md +87 -0
  48. package/.docs/organized/code-examples/server-hono-adapter.md +85 -0
  49. package/.docs/raw/agents/overview.mdx +2 -111
  50. package/.docs/raw/agents/processors.mdx +1 -1
  51. package/.docs/raw/agents/structured-output.mdx +224 -0
  52. package/.docs/raw/guides/build-your-ui/ai-sdk-ui.mdx +381 -431
  53. package/.docs/raw/guides/getting-started/quickstart.mdx +11 -0
  54. package/.docs/raw/guides/migrations/upgrade-to-v1/workflows.mdx +40 -1
  55. package/.docs/raw/memory/working-memory.mdx +1 -0
  56. package/.docs/raw/observability/tracing/bridges/otel.mdx +25 -1
  57. package/.docs/raw/observability/tracing/exporters/arize.mdx +19 -0
  58. package/.docs/raw/observability/tracing/exporters/langfuse.mdx +63 -0
  59. package/.docs/raw/observability/tracing/exporters/otel.mdx +30 -19
  60. package/.docs/raw/observability/tracing/exporters/posthog.mdx +20 -0
  61. package/.docs/raw/observability/tracing/overview.mdx +6 -1
  62. package/.docs/raw/reference/ai-sdk/chat-route.mdx +127 -0
  63. package/.docs/raw/reference/ai-sdk/handle-chat-stream.mdx +117 -0
  64. package/.docs/raw/reference/ai-sdk/handle-network-stream.mdx +64 -0
  65. package/.docs/raw/reference/ai-sdk/handle-workflow-stream.mdx +116 -0
  66. package/.docs/raw/reference/ai-sdk/network-route.mdx +99 -0
  67. package/.docs/raw/reference/ai-sdk/to-ai-sdk-stream.mdx +289 -0
  68. package/.docs/raw/reference/ai-sdk/workflow-route.mdx +110 -0
  69. package/.docs/raw/reference/observability/tracing/bridges/otel.mdx +27 -0
  70. package/.docs/raw/reference/observability/tracing/exporters/arize.mdx +25 -0
  71. package/.docs/raw/reference/observability/tracing/exporters/langfuse.mdx +43 -0
  72. package/.docs/raw/reference/observability/tracing/exporters/otel.mdx +27 -43
  73. package/.docs/raw/reference/server/create-route.mdx +314 -0
  74. package/.docs/raw/reference/server/express-adapter.mdx +193 -0
  75. package/.docs/raw/reference/server/hono-adapter.mdx +174 -0
  76. package/.docs/raw/reference/server/mastra-server.mdx +316 -0
  77. package/.docs/raw/reference/server/routes.mdx +250 -0
  78. package/.docs/raw/reference/streaming/workflows/timeTravelStream.mdx +170 -0
  79. package/.docs/raw/reference/tools/mcp-client.mdx +54 -1
  80. package/.docs/raw/reference/workflows/run-methods/timeTravel.mdx +310 -0
  81. package/.docs/raw/reference/workflows/run.mdx +14 -0
  82. package/.docs/raw/server-db/custom-adapters.mdx +380 -0
  83. package/.docs/raw/server-db/custom-api-routes.mdx +5 -5
  84. package/.docs/raw/server-db/mastra-server.mdx +11 -32
  85. package/.docs/raw/server-db/server-adapters.mdx +286 -0
  86. package/.docs/raw/workflows/workflow-state.mdx +4 -5
  87. package/CHANGELOG.md +15 -0
  88. package/package.json +4 -4
@@ -0,0 +1,250 @@
1
+ ---
2
+ title: "Reference: Server Routes | Server"
3
+ description: "API reference for HTTP routes registered by Mastra server adapters."
4
+ ---
5
+
6
+ # Server Routes
7
+
8
+ Server adapters register these routes when you call `server.init()`. All routes are prefixed with the `prefix` option if configured.
9
+
10
+ ## Agents
11
+
12
+ | Method | Path | Description |
13
+ |--------|------|-------------|
14
+ | `GET` | `/api/agents` | List all agents |
15
+ | `GET` | `/api/agents/:agentId` | Get agent by ID |
16
+ | `POST` | `/api/agents/:agentId/generate` | Generate agent response |
17
+ | `POST` | `/api/agents/:agentId/stream` | Stream agent response |
18
+ | `GET` | `/api/agents/:agentId/tools` | List agent tools |
19
+ | `POST` | `/api/agents/:agentId/tools/:toolId/execute` | Execute agent tool |
20
+
21
+ ### Generate request body
22
+
23
+ ```typescript
24
+ {
25
+ messages: CoreMessage[] | string; // Required
26
+ instructions?: string; // System instructions
27
+ system?: string; // System prompt
28
+ context?: CoreMessage[]; // Additional context
29
+ memory?: { key: string } | boolean; // Memory config
30
+ resourceId?: string; // Resource identifier
31
+ threadId?: string; // Thread identifier
32
+ runId?: string; // Run identifier
33
+ maxSteps?: number; // Max tool steps
34
+ activeTools?: string[]; // Tools to enable
35
+ toolChoice?: ToolChoice; // Tool selection mode
36
+ requestContext?: Record<string, unknown>; // Request context
37
+ output?: ZodSchema; // Structured output schema
38
+ }
39
+ ```
40
+
41
+ ### Generate response
42
+
43
+ ```typescript
44
+ {
45
+ text: string;
46
+ toolCalls?: ToolCall[];
47
+ finishReason: string;
48
+ usage?: {
49
+ promptTokens: number;
50
+ completionTokens: number;
51
+ };
52
+ }
53
+ ```
54
+
55
+ ## Workflows
56
+
57
+ | Method | Path | Description |
58
+ |--------|------|-------------|
59
+ | `GET` | `/api/workflows` | List all workflows |
60
+ | `GET` | `/api/workflows/:workflowId` | Get workflow by ID |
61
+ | `POST` | `/api/workflows/:workflowId/stream` | Stream workflow execution |
62
+ | `POST` | `/api/workflows/:workflowId/resume` | Resume suspended workflow |
63
+ | `POST` | `/api/workflows/:workflowId/resume-async` | Resume asynchronously |
64
+ | `GET` | `/api/workflows/:workflowId/runs` | List workflow runs |
65
+ | `GET` | `/api/workflows/:workflowId/runs/:runId` | Get specific run |
66
+
67
+ ### Stream workflow request body
68
+
69
+ ```typescript
70
+ {
71
+ inputData?: unknown;
72
+ initialState?: unknown;
73
+ requestContext?: Record<string, unknown>;
74
+ closeOnSuspend?: boolean;
75
+ }
76
+ ```
77
+
78
+ ### Resume request body
79
+
80
+ ```typescript
81
+ {
82
+ step?: string | string[];
83
+ resumeData?: unknown;
84
+ requestContext?: Record<string, unknown>;
85
+ }
86
+ ```
87
+
88
+ ## Tools
89
+
90
+ | Method | Path | Description |
91
+ |--------|------|-------------|
92
+ | `GET` | `/api/tools` | List all tools |
93
+ | `GET` | `/api/tools/:toolId` | Get tool by ID |
94
+ | `POST` | `/api/tools/:toolId/execute` | Execute tool |
95
+
96
+ ### Execute tool request body
97
+
98
+ ```typescript
99
+ {
100
+ data: unknown; // Tool input data
101
+ requestContext?: Record<string, unknown>;
102
+ }
103
+ ```
104
+
105
+ ## Memory
106
+
107
+ | Method | Path | Description |
108
+ |--------|------|-------------|
109
+ | `GET` | `/api/memory/threads` | List threads |
110
+ | `GET` | `/api/memory/threads/:threadId` | Get thread |
111
+ | `POST` | `/api/memory/threads` | Create thread |
112
+ | `DELETE` | `/api/memory/threads/:threadId` | Delete thread |
113
+ | `GET` | `/api/memory/threads/:threadId/messages` | Get thread messages |
114
+ | `POST` | `/api/memory/threads/:threadId/messages` | Add message |
115
+
116
+ ### Create thread request body
117
+
118
+ ```typescript
119
+ {
120
+ resourceId: string;
121
+ title?: string;
122
+ metadata?: Record<string, unknown>;
123
+ }
124
+ ```
125
+
126
+ ## Vectors
127
+
128
+ | Method | Path | Description |
129
+ |--------|------|-------------|
130
+ | `POST` | `/api/vectors/:vectorName/upsert` | Upsert vectors |
131
+ | `POST` | `/api/vectors/:vectorName/query` | Query vectors |
132
+ | `POST` | `/api/vectors/:vectorName/delete` | Delete vectors |
133
+
134
+ ### Upsert request body
135
+
136
+ ```typescript
137
+ {
138
+ vectors: Array<{
139
+ id: string;
140
+ values: number[];
141
+ metadata?: Record<string, unknown>;
142
+ }>;
143
+ }
144
+ ```
145
+
146
+ ### Query request body
147
+
148
+ ```typescript
149
+ {
150
+ vector: number[];
151
+ topK?: number;
152
+ filter?: Record<string, unknown>;
153
+ includeMetadata?: boolean;
154
+ }
155
+ ```
156
+
157
+ ## MCP
158
+
159
+ | Method | Path | Description |
160
+ |--------|------|-------------|
161
+ | `GET` | `/api/mcp/servers` | List MCP servers |
162
+ | `GET` | `/api/mcp/servers/:serverId/tools` | List server tools |
163
+ | `POST` | `/api/mcp/:serverId` | MCP HTTP transport |
164
+ | `GET` | `/api/mcp/:serverId/sse` | MCP SSE transport |
165
+
166
+ ## Logs
167
+
168
+ | Method | Path | Description |
169
+ |--------|------|-------------|
170
+ | `GET` | `/api/logs` | List logs |
171
+ | `GET` | `/api/logs/:runId` | Get logs by run ID |
172
+
173
+ ### Query parameters
174
+
175
+ ```typescript
176
+ {
177
+ page?: number;
178
+ perPage?: number;
179
+ transportId?: string;
180
+ }
181
+ ```
182
+
183
+ ## Telemetry
184
+
185
+ | Method | Path | Description |
186
+ |--------|------|-------------|
187
+ | `GET` | `/api/telemetry/traces` | List traces |
188
+ | `GET` | `/api/telemetry/traces/:traceId` | Get trace |
189
+ | `GET` | `/api/telemetry/traces/:traceId/spans` | Get trace spans |
190
+
191
+ ## Common query parameters
192
+
193
+ ### Pagination
194
+
195
+ Most list endpoints support:
196
+
197
+ ```typescript
198
+ {
199
+ page?: number; // Page number (0-indexed)
200
+ perPage?: number; // Items per page (default: 10)
201
+ }
202
+ ```
203
+
204
+ Or offset-based:
205
+
206
+ ```typescript
207
+ {
208
+ offset?: number; // Skip N items
209
+ limit?: number; // Max items (default: 50)
210
+ }
211
+ ```
212
+
213
+ ### Filtering
214
+
215
+ Workflow runs support:
216
+
217
+ ```typescript
218
+ {
219
+ fromDate?: string; // ISO date string
220
+ toDate?: string; // ISO date string
221
+ status?: string; // Run status filter
222
+ resourceId?: string; // Filter by resource
223
+ }
224
+ ```
225
+
226
+ ## Error responses
227
+
228
+ All routes return errors in this format:
229
+
230
+ ```typescript
231
+ {
232
+ error: string; // Error message
233
+ details?: unknown; // Additional details
234
+ }
235
+ ```
236
+
237
+ Common status codes:
238
+
239
+ | Code | Meaning |
240
+ |------|---------|
241
+ | 400 | Bad Request - Invalid parameters |
242
+ | 401 | Unauthorized - Missing/invalid auth |
243
+ | 403 | Forbidden - Insufficient permissions |
244
+ | 404 | Not Found - Resource doesn't exist |
245
+ | 500 | Internal Server Error |
246
+
247
+ ## Related
248
+
249
+ - [createRoute()](/reference/v1/server/create-route) - Creating custom routes
250
+ - [Server Adapters](/docs/v1/server-db/server-adapters) - Using adapters
@@ -0,0 +1,170 @@
1
+ ---
2
+ title: "Reference: Run.timeTravelStream() | Streaming"
3
+ description: Documentation for the `Run.timeTravelStream()` method for streaming workflow time travel execution.
4
+ ---
5
+
6
+ # Run.timeTravelStream()
7
+
8
+ The `.timeTravelStream()` method re-executes a workflow starting from any specific step with streaming events. This allows you to receive real-time updates during time travel execution while maintaining full visibility into each step's progress.
9
+
10
+ ## Usage example
11
+
12
+ ```typescript showLineNumbers copy
13
+ const run = await workflow.createRun();
14
+
15
+ const output = run.timeTravelStream({
16
+ step: "step2",
17
+ inputData: { value: 10 },
18
+ });
19
+
20
+ // Process events as they arrive
21
+ for await (const event of output.fullStream) {
22
+ console.log(event.type, event.payload);
23
+ }
24
+
25
+ // Get the final result
26
+ const result = await output.result;
27
+ ```
28
+
29
+ ## Parameters
30
+
31
+ All parameters are the same as [`Run.timeTravel()`](../../workflows/run-methods/timeTravel#parameters). See the [timeTravel reference](../../workflows/run-methods/timeTravel#parameters) for detailed parameter documentation.
32
+
33
+ ## Returns
34
+
35
+ <PropertiesTable
36
+ content={[
37
+ {
38
+ name: "output",
39
+ type: "WorkflowRunOutput<WorkflowResult<TState, TInput, TOutput, TSteps>>",
40
+ description:
41
+ "An object containing both the stream and result promise",
42
+ },
43
+ {
44
+ name: "output.fullStream",
45
+ type: "ReadableStream<WorkflowStreamEvent>",
46
+ description:
47
+ "A readable stream that emits workflow events as execution progresses",
48
+ },
49
+ {
50
+ name: "output.result",
51
+ type: "Promise<WorkflowResult<TState, TInput, TOutput, TSteps>>",
52
+ description:
53
+ "A promise that resolves to the final workflow execution result",
54
+ },
55
+ {
56
+ name: "output.traceId",
57
+ type: "string",
58
+ isOptional: true,
59
+ description:
60
+ "The trace ID associated with this execution when Tracing is enabled",
61
+ },
62
+ ]}
63
+ />
64
+
65
+ ## Stream events
66
+
67
+ The stream emits various workflow events during execution:
68
+
69
+ - `workflow-step-start`: Emitted when a step begins execution
70
+ - `workflow-step-finish`: Emitted when a step completes successfully
71
+ - `workflow-step-error`: Emitted when a step encounters an error
72
+ - `workflow-step-suspended`: Emitted when a step suspends
73
+ - Additional events depending on step types (agents, tools, etc.)
74
+
75
+ ## Extended usage examples
76
+
77
+ ### Processing events during time travel
78
+
79
+ ```typescript showLineNumbers copy
80
+ const run = await workflow.createRun();
81
+
82
+ const output = run.timeTravelStream({
83
+ step: "step2",
84
+ inputData: { value: 10 },
85
+ });
86
+
87
+ for await (const event of output.fullStream) {
88
+ switch (event.type) {
89
+ case "workflow-step-start":
90
+ console.log(`Starting step: ${event.payload.stepName}`);
91
+ break;
92
+ case "workflow-step-finish":
93
+ console.log(`Completed step: ${event.payload.stepName}`);
94
+ break;
95
+ case "workflow-step-error":
96
+ console.error(`Error in step: ${event.payload.stepName}`, event.payload.error);
97
+ break;
98
+ }
99
+ }
100
+
101
+ const result = await output.result;
102
+ console.log("Time travel completed:", result);
103
+ ```
104
+
105
+ ### Time travel stream with context
106
+
107
+ ```typescript showLineNumbers copy
108
+ const output = run.timeTravelStream({
109
+ step: "step2",
110
+ context: {
111
+ step1: {
112
+ status: "success",
113
+ payload: { value: 0 },
114
+ output: { step1Result: 2 },
115
+ startedAt: Date.now(),
116
+ endedAt: Date.now(),
117
+ },
118
+ },
119
+ });
120
+
121
+ for await (const event of output.fullStream) {
122
+ // Handle events
123
+ console.log(event);
124
+ }
125
+
126
+ const result = await output.result;
127
+ ```
128
+
129
+ ### Time travel stream with nested workflows
130
+
131
+ ```typescript showLineNumbers copy
132
+ const output = run.timeTravelStream({
133
+ step: ["nestedWorkflow", "step3"],
134
+ inputData: { value: 10 },
135
+ nestedStepsContext: {
136
+ nestedWorkflow: {
137
+ step2: {
138
+ status: "success",
139
+ payload: { step1Result: 2 },
140
+ output: { step2Result: 3 },
141
+ startedAt: Date.now(),
142
+ endedAt: Date.now(),
143
+ },
144
+ },
145
+ },
146
+ });
147
+
148
+ for await (const event of output.fullStream) {
149
+ console.log(event.type, event.payload);
150
+ }
151
+
152
+ const result = await output.result;
153
+ ```
154
+
155
+ ## Notes
156
+
157
+ - The stream closes automatically when time travel execution completes or encounters an error
158
+ - You can process events from the stream while the workflow is still executing
159
+ - The `result` promise resolves only after all steps have completed
160
+ - Stream events follow the same format as regular workflow streaming
161
+ - Time travel streaming requires storage to be configured since it relies on persisted workflow snapshots
162
+
163
+ ## Related
164
+
165
+ - [Run.timeTravel()](../../workflows/run-methods/timeTravel)
166
+ - [Time Travel](/docs/v1/workflows/time-travel)
167
+ - [Workflow Streaming](/docs/v1/streaming/workflow-streaming)
168
+ - [Run.stream()](./stream)
169
+ - [Run.resumeStream()](./resumeStream)
170
+
@@ -99,6 +99,13 @@ Each server in the `servers` map is configured using the `MastraMCPServerDefinit
99
99
  description:
100
100
  "For SSE fallback: Custom fetch configuration for SSE connections. Required when using custom headers with SSE.",
101
101
  },
102
+ {
103
+ name: "fetch",
104
+ type: "FetchLike",
105
+ isOptional: true,
106
+ description:
107
+ "For HTTP servers: Custom fetch implementation used for all network requests. When provided, this function will be used for all HTTP requests, allowing you to add dynamic authentication headers (e.g., refreshing bearer tokens), customize request behavior per-request, or intercept and modify requests/responses. When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.",
108
+ },
102
109
  {
103
110
  name: "logger",
104
111
  type: "LogHandler",
@@ -854,11 +861,40 @@ MCPClient handles server connections gracefully:
854
861
  2. Graceful server shutdown to prevent error messages during development
855
862
  3. Proper cleanup of resources when disconnecting
856
863
 
864
+ ## Using Custom Fetch for Dynamic Authentication
865
+
866
+ For HTTP servers, you can provide a custom `fetch` function to handle dynamic authentication, request interception, or other custom behavior. This is particularly useful when you need to refresh tokens on each request or customize request behavior.
867
+
868
+ When `fetch` is provided, `requestInit`, `eventSourceInit`, and `authProvider` become optional, as you can handle these concerns within your custom fetch function.
869
+
870
+ ```typescript
871
+ const mcpClient = new MCPClient({
872
+ servers: {
873
+ apiServer: {
874
+ url: new URL("https://api.example.com/mcp"),
875
+ fetch: async (url, init) => {
876
+ // Refresh token on each request
877
+ const token = await getAuthToken(); // Your token refresh logic
878
+
879
+ return fetch(url, {
880
+ ...init,
881
+ headers: {
882
+ ...init?.headers,
883
+ Authorization: `Bearer ${token}`,
884
+ },
885
+ });
886
+ },
887
+ },
888
+ },
889
+ });
890
+ ```
891
+
857
892
  ## Using SSE Request Headers
858
893
 
859
- When using the legacy SSE MCP transport, you must configure both `requestInit` and `eventSourceInit` due to a bug in the MCP SDK:
894
+ When using the legacy SSE MCP transport, you must configure both `requestInit` and `eventSourceInit` due to a bug in the MCP SDK. Alternatively, you can use a custom `fetch` function which will be automatically used for both POST requests and SSE connections:
860
895
 
861
896
  ```ts
897
+ // Option 1: Using requestInit and eventSourceInit (required for SSE)
862
898
  const sseClient = new MCPClient({
863
899
  servers: {
864
900
  exampleServer: {
@@ -883,6 +919,23 @@ const sseClient = new MCPClient({
883
919
  },
884
920
  },
885
921
  });
922
+
923
+ // Option 2: Using custom fetch (simpler, works for both Streamable HTTP and SSE)
924
+ const sseClientWithFetch = new MCPClient({
925
+ servers: {
926
+ exampleServer: {
927
+ url: new URL("https://your-mcp-server.com/sse"),
928
+ fetch: async (url, init) => {
929
+ const headers = new Headers(init?.headers || {});
930
+ headers.set("Authorization", "Bearer your-token");
931
+ return fetch(url, {
932
+ ...init,
933
+ headers,
934
+ });
935
+ },
936
+ },
937
+ },
938
+ });
886
939
  ```
887
940
 
888
941
  ## Related Information