@mastra/mcp-docs-server 0.0.0-commonjs-20250414101718
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.
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +161 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +110 -0
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +26 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +196 -0
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Frag.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-azure.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-ibm.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-replicate.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fspeech-speechify.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +250 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +302 -0
- package/.docs/organized/changelogs/create-mastra.md +302 -0
- package/.docs/organized/changelogs/mastra.md +302 -0
- package/.docs/organized/code-examples/agent-network.md +282 -0
- package/.docs/organized/code-examples/agent.md +388 -0
- package/.docs/organized/code-examples/ai-sdk-useChat.md +378 -0
- package/.docs/organized/code-examples/assistant-ui.md +37 -0
- package/.docs/organized/code-examples/bird-checker-with-express.md +235 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +360 -0
- package/.docs/organized/code-examples/bird-checker-with-nextjs.md +250 -0
- package/.docs/organized/code-examples/client-side-tools.md +69 -0
- package/.docs/organized/code-examples/crypto-chatbot.md +96 -0
- package/.docs/organized/code-examples/fireworks-r1.md +159 -0
- package/.docs/organized/code-examples/mcp-registry-registry.md +63 -0
- package/.docs/organized/code-examples/memory-todo-agent.md +164 -0
- package/.docs/organized/code-examples/memory-with-context.md +167 -0
- package/.docs/organized/code-examples/memory-with-libsql.md +204 -0
- package/.docs/organized/code-examples/memory-with-mem0.md +121 -0
- package/.docs/organized/code-examples/memory-with-pg.md +224 -0
- package/.docs/organized/code-examples/memory-with-upstash.md +268 -0
- package/.docs/organized/code-examples/quick-start.md +129 -0
- package/.docs/organized/code-examples/stock-price-tool.md +124 -0
- package/.docs/organized/code-examples/weather-agent.md +353 -0
- package/.docs/organized/code-examples/workflow-ai-recruiter.md +159 -0
- package/.docs/organized/code-examples/workflow-with-inline-steps.md +111 -0
- package/.docs/organized/code-examples/workflow-with-memory.md +393 -0
- package/.docs/organized/code-examples/workflow-with-separate-steps.md +131 -0
- package/.docs/raw/agents/adding-tools.mdx +317 -0
- package/.docs/raw/agents/adding-voice.mdx +175 -0
- package/.docs/raw/agents/agent-memory.mdx +62 -0
- package/.docs/raw/agents/mcp-guide.mdx +215 -0
- package/.docs/raw/agents/overview.mdx +303 -0
- package/.docs/raw/community/discord.mdx +12 -0
- package/.docs/raw/community/licensing.mdx +63 -0
- package/.docs/raw/deployment/client.mdx +120 -0
- package/.docs/raw/deployment/deployment.mdx +127 -0
- package/.docs/raw/deployment/server.mdx +282 -0
- package/.docs/raw/evals/custom-eval.mdx +22 -0
- package/.docs/raw/evals/overview.mdx +95 -0
- package/.docs/raw/evals/running-in-ci.mdx +81 -0
- package/.docs/raw/evals/textual-evals.mdx +54 -0
- package/.docs/raw/faq/index.mdx +63 -0
- package/.docs/raw/frameworks/ai-sdk.mdx +296 -0
- package/.docs/raw/frameworks/next-js.mdx +238 -0
- package/.docs/raw/getting-started/installation.mdx +442 -0
- package/.docs/raw/getting-started/mcp-docs-server.mdx +141 -0
- package/.docs/raw/getting-started/project-structure.mdx +80 -0
- package/.docs/raw/index.mdx +22 -0
- package/.docs/raw/integrations/index.mdx +213 -0
- package/.docs/raw/local-dev/add-to-existing-project.mdx +48 -0
- package/.docs/raw/local-dev/creating-a-new-project.mdx +54 -0
- package/.docs/raw/local-dev/mastra-dev.mdx +108 -0
- package/.docs/raw/memory/memory-processors.mdx +131 -0
- package/.docs/raw/memory/overview.mdx +119 -0
- package/.docs/raw/memory/semantic-recall.mdx +122 -0
- package/.docs/raw/memory/working-memory.mdx +87 -0
- package/.docs/raw/observability/logging.mdx +38 -0
- package/.docs/raw/observability/nextjs-tracing.mdx +108 -0
- package/.docs/raw/observability/tracing.mdx +115 -0
- package/.docs/raw/rag/chunking-and-embedding.mdx +156 -0
- package/.docs/raw/rag/overview.mdx +85 -0
- package/.docs/raw/rag/retrieval.mdx +365 -0
- package/.docs/raw/rag/vector-databases.mdx +340 -0
- package/.docs/raw/reference/agents/createTool.mdx +229 -0
- package/.docs/raw/reference/agents/generate.mdx +334 -0
- package/.docs/raw/reference/agents/getAgent.mdx +54 -0
- package/.docs/raw/reference/agents/stream.mdx +369 -0
- package/.docs/raw/reference/cli/build.mdx +55 -0
- package/.docs/raw/reference/cli/dev.mdx +134 -0
- package/.docs/raw/reference/cli/init.mdx +43 -0
- package/.docs/raw/reference/client-js/agents.mdx +107 -0
- package/.docs/raw/reference/client-js/error-handling.mdx +38 -0
- package/.docs/raw/reference/client-js/logs.mdx +24 -0
- package/.docs/raw/reference/client-js/memory.mdx +97 -0
- package/.docs/raw/reference/client-js/telemetry.mdx +20 -0
- package/.docs/raw/reference/client-js/tools.mdx +44 -0
- package/.docs/raw/reference/client-js/vectors.mdx +79 -0
- package/.docs/raw/reference/client-js/workflows.mdx +136 -0
- package/.docs/raw/reference/core/mastra-class.mdx +232 -0
- package/.docs/raw/reference/deployer/cloudflare.mdx +207 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +109 -0
- package/.docs/raw/reference/deployer/vercel.mdx +117 -0
- package/.docs/raw/reference/evals/answer-relevancy.mdx +186 -0
- package/.docs/raw/reference/evals/bias.mdx +186 -0
- package/.docs/raw/reference/evals/completeness.mdx +174 -0
- package/.docs/raw/reference/evals/content-similarity.mdx +183 -0
- package/.docs/raw/reference/evals/context-position.mdx +190 -0
- package/.docs/raw/reference/evals/context-precision.mdx +189 -0
- package/.docs/raw/reference/evals/context-relevancy.mdx +188 -0
- package/.docs/raw/reference/evals/contextual-recall.mdx +191 -0
- package/.docs/raw/reference/evals/faithfulness.mdx +193 -0
- package/.docs/raw/reference/evals/hallucination.mdx +219 -0
- package/.docs/raw/reference/evals/keyword-coverage.mdx +176 -0
- package/.docs/raw/reference/evals/prompt-alignment.mdx +238 -0
- package/.docs/raw/reference/evals/summarization.mdx +205 -0
- package/.docs/raw/reference/evals/textual-difference.mdx +161 -0
- package/.docs/raw/reference/evals/tone-consistency.mdx +181 -0
- package/.docs/raw/reference/evals/toxicity.mdx +165 -0
- package/.docs/raw/reference/index.mdx +12 -0
- package/.docs/raw/reference/memory/Memory.mdx +212 -0
- package/.docs/raw/reference/memory/createThread.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadById.mdx +46 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +48 -0
- package/.docs/raw/reference/memory/query.mdx +167 -0
- package/.docs/raw/reference/networks/agent-network.mdx +159 -0
- package/.docs/raw/reference/observability/create-logger.mdx +106 -0
- package/.docs/raw/reference/observability/logger.mdx +55 -0
- package/.docs/raw/reference/observability/otel-config.mdx +120 -0
- package/.docs/raw/reference/observability/providers/braintrust.mdx +40 -0
- package/.docs/raw/reference/observability/providers/dash0.mdx +40 -0
- package/.docs/raw/reference/observability/providers/index.mdx +16 -0
- package/.docs/raw/reference/observability/providers/laminar.mdx +41 -0
- package/.docs/raw/reference/observability/providers/langfuse.mdx +51 -0
- package/.docs/raw/reference/observability/providers/langsmith.mdx +48 -0
- package/.docs/raw/reference/observability/providers/langwatch.mdx +45 -0
- package/.docs/raw/reference/observability/providers/new-relic.mdx +40 -0
- package/.docs/raw/reference/observability/providers/signoz.mdx +40 -0
- package/.docs/raw/reference/observability/providers/traceloop.mdx +40 -0
- package/.docs/raw/reference/rag/astra.mdx +258 -0
- package/.docs/raw/reference/rag/chroma.mdx +281 -0
- package/.docs/raw/reference/rag/chunk.mdx +235 -0
- package/.docs/raw/reference/rag/document.mdx +127 -0
- package/.docs/raw/reference/rag/embeddings.mdx +160 -0
- package/.docs/raw/reference/rag/extract-params.mdx +226 -0
- package/.docs/raw/reference/rag/graph-rag.mdx +182 -0
- package/.docs/raw/reference/rag/libsql.mdx +357 -0
- package/.docs/raw/reference/rag/metadata-filters.mdx +298 -0
- package/.docs/raw/reference/rag/pg.mdx +477 -0
- package/.docs/raw/reference/rag/pinecone.mdx +281 -0
- package/.docs/raw/reference/rag/qdrant.mdx +236 -0
- package/.docs/raw/reference/rag/rerank.mdx +212 -0
- package/.docs/raw/reference/rag/turbopuffer.mdx +249 -0
- package/.docs/raw/reference/rag/upstash.mdx +247 -0
- package/.docs/raw/reference/rag/vectorize.mdx +298 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +48 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +207 -0
- package/.docs/raw/reference/tools/document-chunker-tool.mdx +141 -0
- package/.docs/raw/reference/tools/graph-rag-tool.mdx +154 -0
- package/.docs/raw/reference/tools/mcp-configuration.mdx +206 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/composite-voice.mdx +140 -0
- package/.docs/raw/reference/voice/deepgram.mdx +164 -0
- package/.docs/raw/reference/voice/elevenlabs.mdx +216 -0
- package/.docs/raw/reference/voice/google.mdx +198 -0
- package/.docs/raw/reference/voice/mastra-voice.mdx +394 -0
- package/.docs/raw/reference/voice/murf.mdx +251 -0
- package/.docs/raw/reference/voice/openai-realtime.mdx +431 -0
- package/.docs/raw/reference/voice/openai.mdx +168 -0
- package/.docs/raw/reference/voice/playai.mdx +159 -0
- package/.docs/raw/reference/voice/sarvam.mdx +260 -0
- package/.docs/raw/reference/voice/speechify.mdx +145 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +122 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +195 -0
- package/.docs/raw/reference/voice/voice.on.mdx +189 -0
- package/.docs/raw/reference/voice/voice.send.mdx +118 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/workflows/after.mdx +88 -0
- package/.docs/raw/reference/workflows/afterEvent.mdx +76 -0
- package/.docs/raw/reference/workflows/commit.mdx +37 -0
- package/.docs/raw/reference/workflows/createRun.mdx +77 -0
- package/.docs/raw/reference/workflows/else.mdx +72 -0
- package/.docs/raw/reference/workflows/events.mdx +305 -0
- package/.docs/raw/reference/workflows/execute.mdx +110 -0
- package/.docs/raw/reference/workflows/if.mdx +107 -0
- package/.docs/raw/reference/workflows/resume.mdx +155 -0
- package/.docs/raw/reference/workflows/resumeWithEvent.mdx +133 -0
- package/.docs/raw/reference/workflows/snapshots.mdx +207 -0
- package/.docs/raw/reference/workflows/start.mdx +84 -0
- package/.docs/raw/reference/workflows/step-class.mdx +100 -0
- package/.docs/raw/reference/workflows/step-condition.mdx +134 -0
- package/.docs/raw/reference/workflows/step-function.mdx +92 -0
- package/.docs/raw/reference/workflows/step-options.mdx +69 -0
- package/.docs/raw/reference/workflows/step-retries.mdx +203 -0
- package/.docs/raw/reference/workflows/suspend.mdx +70 -0
- package/.docs/raw/reference/workflows/then.mdx +74 -0
- package/.docs/raw/reference/workflows/until.mdx +165 -0
- package/.docs/raw/reference/workflows/watch.mdx +118 -0
- package/.docs/raw/reference/workflows/while.mdx +168 -0
- package/.docs/raw/reference/workflows/workflow.mdx +233 -0
- package/.docs/raw/storage/overview.mdx +378 -0
- package/.docs/raw/voice/overview.mdx +135 -0
- package/.docs/raw/voice/speech-to-text.mdx +45 -0
- package/.docs/raw/voice/text-to-speech.mdx +52 -0
- package/.docs/raw/voice/voice-to-voice.mdx +310 -0
- package/.docs/raw/workflows/control-flow.mdx +778 -0
- package/.docs/raw/workflows/dynamic-workflows.mdx +236 -0
- package/.docs/raw/workflows/error-handling.mdx +183 -0
- package/.docs/raw/workflows/nested-workflows.mdx +352 -0
- package/.docs/raw/workflows/overview.mdx +203 -0
- package/.docs/raw/workflows/steps.mdx +108 -0
- package/.docs/raw/workflows/suspend-and-resume.mdx +404 -0
- package/.docs/raw/workflows/variables.mdx +313 -0
- package/LICENSE.md +46 -0
- package/README.md +129 -0
- package/dist/_tsup-dts-rollup.d.ts +149 -0
- package/dist/chunk-QWYMT5LP.js +194 -0
- package/dist/prepare-docs/prepare.d.ts +1 -0
- package/dist/prepare-docs/prepare.js +1 -0
- package/dist/stdio.d.ts +1 -0
- package/dist/stdio.js +518 -0
- package/package.json +60 -0
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Cloudflare Vector Store | Vector Databases | RAG | Mastra Docs"
|
|
3
|
+
description: Documentation for the CloudflareVector class in Mastra, which provides vector search using Cloudflare Vectorize.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Cloudflare Vector Store
|
|
7
|
+
|
|
8
|
+
The CloudflareVector class provides vector search using [Cloudflare Vectorize](https://developers.cloudflare.com/vectorize/), a vector database service integrated with Cloudflare's edge network.
|
|
9
|
+
|
|
10
|
+
## Constructor Options
|
|
11
|
+
|
|
12
|
+
<PropertiesTable
|
|
13
|
+
content={[
|
|
14
|
+
{
|
|
15
|
+
name: "accountId",
|
|
16
|
+
type: "string",
|
|
17
|
+
description: "Cloudflare account ID",
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
name: "apiToken",
|
|
21
|
+
type: "string",
|
|
22
|
+
description: "Cloudflare API token with Vectorize permissions",
|
|
23
|
+
},
|
|
24
|
+
]}
|
|
25
|
+
/>
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### createIndex()
|
|
30
|
+
|
|
31
|
+
<PropertiesTable
|
|
32
|
+
content={[
|
|
33
|
+
{
|
|
34
|
+
name: "indexName",
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Name of the index to create",
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
name: "dimension",
|
|
40
|
+
type: "number",
|
|
41
|
+
description: "Vector dimension (must match your embedding model)",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "metric",
|
|
45
|
+
type: "'cosine' | 'euclidean' | 'dotproduct'",
|
|
46
|
+
isOptional: true,
|
|
47
|
+
defaultValue: "cosine",
|
|
48
|
+
description:
|
|
49
|
+
"Distance metric for similarity search (dotproduct maps to dot-product)",
|
|
50
|
+
},
|
|
51
|
+
]}
|
|
52
|
+
/>
|
|
53
|
+
|
|
54
|
+
### upsert()
|
|
55
|
+
|
|
56
|
+
<PropertiesTable
|
|
57
|
+
content={[
|
|
58
|
+
{
|
|
59
|
+
name: "indexName",
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Name of the index to upsert into",
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "vectors",
|
|
65
|
+
type: "number[][]",
|
|
66
|
+
description: "Array of embedding vectors",
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
name: "metadata",
|
|
70
|
+
type: "Record<string, any>[]",
|
|
71
|
+
isOptional: true,
|
|
72
|
+
description: "Metadata for each vector",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
name: "ids",
|
|
76
|
+
type: "string[]",
|
|
77
|
+
isOptional: true,
|
|
78
|
+
description: "Optional vector IDs (auto-generated if not provided)",
|
|
79
|
+
},
|
|
80
|
+
]}
|
|
81
|
+
/>
|
|
82
|
+
|
|
83
|
+
### query()
|
|
84
|
+
|
|
85
|
+
<PropertiesTable
|
|
86
|
+
content={[
|
|
87
|
+
{
|
|
88
|
+
name: "indexName",
|
|
89
|
+
type: "string",
|
|
90
|
+
description: "Name of the index to query",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "queryVector",
|
|
94
|
+
type: "number[]",
|
|
95
|
+
description: "Query vector to find similar vectors",
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
name: "topK",
|
|
99
|
+
type: "number",
|
|
100
|
+
isOptional: true,
|
|
101
|
+
defaultValue: "10",
|
|
102
|
+
description: "Number of results to return",
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
name: "filter",
|
|
106
|
+
type: "Record<string, any>",
|
|
107
|
+
isOptional: true,
|
|
108
|
+
description: "Metadata filters for the query",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "includeVector",
|
|
112
|
+
type: "boolean",
|
|
113
|
+
isOptional: true,
|
|
114
|
+
defaultValue: "false",
|
|
115
|
+
description: "Whether to include vectors in the results",
|
|
116
|
+
},
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
### listIndexes()
|
|
121
|
+
|
|
122
|
+
Returns an array of index names as strings.
|
|
123
|
+
|
|
124
|
+
### describeIndex()
|
|
125
|
+
|
|
126
|
+
<PropertiesTable
|
|
127
|
+
content={[
|
|
128
|
+
{
|
|
129
|
+
name: "indexName",
|
|
130
|
+
type: "string",
|
|
131
|
+
description: "Name of the index to describe",
|
|
132
|
+
},
|
|
133
|
+
]}
|
|
134
|
+
/>
|
|
135
|
+
|
|
136
|
+
Returns:
|
|
137
|
+
|
|
138
|
+
```typescript copy
|
|
139
|
+
interface IndexStats {
|
|
140
|
+
dimension: number;
|
|
141
|
+
count: number;
|
|
142
|
+
metric: "cosine" | "euclidean" | "dotproduct";
|
|
143
|
+
}
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
### deleteIndex()
|
|
147
|
+
|
|
148
|
+
<PropertiesTable
|
|
149
|
+
content={[
|
|
150
|
+
{
|
|
151
|
+
name: "indexName",
|
|
152
|
+
type: "string",
|
|
153
|
+
description: "Name of the index to delete",
|
|
154
|
+
},
|
|
155
|
+
]}
|
|
156
|
+
/>
|
|
157
|
+
|
|
158
|
+
### createMetadataIndex()
|
|
159
|
+
|
|
160
|
+
Creates an index on a metadata field to enable filtering.
|
|
161
|
+
|
|
162
|
+
<PropertiesTable
|
|
163
|
+
content={[
|
|
164
|
+
{
|
|
165
|
+
name: "indexName",
|
|
166
|
+
type: "string",
|
|
167
|
+
description: "Name of the index containing the metadata field",
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "propertyName",
|
|
171
|
+
type: "string",
|
|
172
|
+
description: "Name of the metadata field to index",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "indexType",
|
|
176
|
+
type: "'string' | 'number' | 'boolean'",
|
|
177
|
+
description: "Type of the metadata field",
|
|
178
|
+
},
|
|
179
|
+
]}
|
|
180
|
+
/>
|
|
181
|
+
|
|
182
|
+
### deleteMetadataIndex()
|
|
183
|
+
|
|
184
|
+
Removes an index from a metadata field.
|
|
185
|
+
|
|
186
|
+
<PropertiesTable
|
|
187
|
+
content={[
|
|
188
|
+
{
|
|
189
|
+
name: "indexName",
|
|
190
|
+
type: "string",
|
|
191
|
+
description: "Name of the index containing the metadata field",
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
name: "propertyName",
|
|
195
|
+
type: "string",
|
|
196
|
+
description: "Name of the metadata field to remove indexing from",
|
|
197
|
+
},
|
|
198
|
+
]}
|
|
199
|
+
/>
|
|
200
|
+
|
|
201
|
+
### listMetadataIndexes()
|
|
202
|
+
|
|
203
|
+
Lists all metadata field indexes for an index.
|
|
204
|
+
|
|
205
|
+
<PropertiesTable
|
|
206
|
+
content={[
|
|
207
|
+
{
|
|
208
|
+
name: "indexName",
|
|
209
|
+
type: "string",
|
|
210
|
+
description: "Name of the index to list metadata indexes for",
|
|
211
|
+
},
|
|
212
|
+
]}
|
|
213
|
+
/>
|
|
214
|
+
|
|
215
|
+
### updateIndexById()
|
|
216
|
+
|
|
217
|
+
Updates a vector or metadata for a specific ID within an index.
|
|
218
|
+
|
|
219
|
+
<PropertiesTable
|
|
220
|
+
content={[
|
|
221
|
+
{
|
|
222
|
+
name: "indexName",
|
|
223
|
+
type: "string",
|
|
224
|
+
description: "Name of the index containing the ID to update",
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
name: "id",
|
|
228
|
+
type: "string",
|
|
229
|
+
description: "Unique identifier of the vector or metadata to update",
|
|
230
|
+
},
|
|
231
|
+
{
|
|
232
|
+
name: "update",
|
|
233
|
+
type: "{ vector?: number[]; metadata?: Record<string, any>; }",
|
|
234
|
+
description: "Object containing the vector and/or metadata to update",
|
|
235
|
+
},
|
|
236
|
+
]}
|
|
237
|
+
/>
|
|
238
|
+
|
|
239
|
+
### deleteIndexById()
|
|
240
|
+
|
|
241
|
+
Deletes a vector and its associated metadata for a specific ID within an index.
|
|
242
|
+
|
|
243
|
+
<PropertiesTable
|
|
244
|
+
content={[
|
|
245
|
+
{
|
|
246
|
+
name: "indexName",
|
|
247
|
+
type: "string",
|
|
248
|
+
description: "Name of the index containing the ID to delete",
|
|
249
|
+
},
|
|
250
|
+
{
|
|
251
|
+
name: "id",
|
|
252
|
+
type: "string",
|
|
253
|
+
description: "Unique identifier of the vector and metadata to delete",
|
|
254
|
+
},
|
|
255
|
+
]}
|
|
256
|
+
/>
|
|
257
|
+
|
|
258
|
+
## Response Types
|
|
259
|
+
|
|
260
|
+
Query results are returned in this format:
|
|
261
|
+
|
|
262
|
+
```typescript copy
|
|
263
|
+
interface QueryResult {
|
|
264
|
+
id: string;
|
|
265
|
+
score: number;
|
|
266
|
+
metadata: Record<string, any>;
|
|
267
|
+
vector?: number[];
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
## Error Handling
|
|
272
|
+
|
|
273
|
+
The store throws typed errors that can be caught:
|
|
274
|
+
|
|
275
|
+
```typescript copy
|
|
276
|
+
try {
|
|
277
|
+
await store.query({
|
|
278
|
+
indexName: "index_name",
|
|
279
|
+
queryVector: queryVector,
|
|
280
|
+
});
|
|
281
|
+
} catch (error) {
|
|
282
|
+
if (error instanceof VectorStoreError) {
|
|
283
|
+
console.log(error.code); // 'connection_failed' | 'invalid_dimension' | etc
|
|
284
|
+
console.log(error.details); // Additional error context
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
## Environment Variables
|
|
290
|
+
|
|
291
|
+
Required environment variables:
|
|
292
|
+
|
|
293
|
+
- `CLOUDFLARE_ACCOUNT_ID`: Your Cloudflare account ID
|
|
294
|
+
- `CLOUDFLARE_API_TOKEN`: Your Cloudflare API token with Vectorize permissions
|
|
295
|
+
|
|
296
|
+
## Related
|
|
297
|
+
|
|
298
|
+
- [Metadata Filters](./metadata-filters)
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "LibSQL Storage | Storage System | Mastra Core"
|
|
3
|
+
description: Documentation for the LibSQL storage implementation in Mastra.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# LibSQL Storage
|
|
7
|
+
|
|
8
|
+
The LibSQL storage implementation provides a SQLite-compatible storage solution that can run both in-memory and as a persistent database.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @mastra/storage-libsql
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript copy showLineNumbers
|
|
19
|
+
import { LibSQLStore } from "@mastra/core/storage/libsql";
|
|
20
|
+
|
|
21
|
+
// File database (development)
|
|
22
|
+
const storage = new LibSQLStore({
|
|
23
|
+
config: {
|
|
24
|
+
url: 'file:storage.db',
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
// Persistent database (production)
|
|
29
|
+
const storage = new LibSQLStore({
|
|
30
|
+
config: {
|
|
31
|
+
url: process.env.DATABASE_URL,
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Parameters
|
|
37
|
+
|
|
38
|
+
<PropertiesTable
|
|
39
|
+
content={[
|
|
40
|
+
{
|
|
41
|
+
name: "url",
|
|
42
|
+
type: "string",
|
|
43
|
+
description:
|
|
44
|
+
"Database URL. Use ':memory:' for in-memory database, 'file:filename.db' for a file database, or any LibSQL-compatible connection string for persistent storage.",
|
|
45
|
+
isOptional: false,
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "authToken",
|
|
49
|
+
type: "string",
|
|
50
|
+
description: "Authentication token for remote LibSQL databases.",
|
|
51
|
+
isOptional: true,
|
|
52
|
+
},
|
|
53
|
+
]}
|
|
54
|
+
/>
|
|
55
|
+
|
|
56
|
+
## Additional Notes
|
|
57
|
+
|
|
58
|
+
### In-Memory vs Persistent Storage
|
|
59
|
+
|
|
60
|
+
The file configuration (`file:storage.db`) is useful for:
|
|
61
|
+
|
|
62
|
+
- Development and testing
|
|
63
|
+
- Temporary storage
|
|
64
|
+
- Quick prototyping
|
|
65
|
+
|
|
66
|
+
For production use cases, use a persistent database URL: `libsql://your-database.turso.io`
|
|
67
|
+
|
|
68
|
+
### Schema Management
|
|
69
|
+
|
|
70
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
71
|
+
|
|
72
|
+
- `threads`: Stores conversation threads
|
|
73
|
+
- `messages`: Stores individual messages
|
|
74
|
+
- `metadata`: Stores additional metadata for threads and messages
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "PostgreSQL Storage | Storage System | Mastra Core"
|
|
3
|
+
description: Documentation for the PostgreSQL storage implementation in Mastra.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# PostgreSQL Storage
|
|
7
|
+
|
|
8
|
+
The PostgreSQL storage implementation provides a production-ready storage solution using PostgreSQL databases.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @mastra/pg
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript copy showLineNumbers
|
|
19
|
+
import { PostgresStore } from "@mastra/pg";
|
|
20
|
+
|
|
21
|
+
const storage = new PostgresStore({
|
|
22
|
+
connectionString: process.env.DATABASE_URL,
|
|
23
|
+
});
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Parameters
|
|
27
|
+
|
|
28
|
+
<PropertiesTable
|
|
29
|
+
content={[
|
|
30
|
+
{
|
|
31
|
+
name: "connectionString",
|
|
32
|
+
type: "string",
|
|
33
|
+
description:
|
|
34
|
+
"PostgreSQL connection string (e.g., postgresql://user:pass@host:5432/dbname)",
|
|
35
|
+
isOptional: false,
|
|
36
|
+
},
|
|
37
|
+
]}
|
|
38
|
+
/>
|
|
39
|
+
|
|
40
|
+
## Additional Notes
|
|
41
|
+
|
|
42
|
+
### Schema Management
|
|
43
|
+
|
|
44
|
+
The storage implementation handles schema creation and updates automatically. It creates the following tables:
|
|
45
|
+
|
|
46
|
+
- `threads`: Stores conversation threads
|
|
47
|
+
- `messages`: Stores individual messages
|
|
48
|
+
- `metadata`: Stores additional metadata for threads and messages
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Upstash Storage | Storage System | Mastra Core"
|
|
3
|
+
description: Documentation for the Upstash storage implementation in Mastra.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Upstash Storage
|
|
7
|
+
|
|
8
|
+
The Upstash storage implementation provides a serverless-friendly storage solution using Upstash's Redis-compatible key-value store.
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install @mastra/upstash
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```typescript copy showLineNumbers
|
|
19
|
+
import { UpstashStore } from "@mastra/upstash";
|
|
20
|
+
|
|
21
|
+
const storage = new UpstashStore({
|
|
22
|
+
url: process.env.UPSTASH_URL,
|
|
23
|
+
token: process.env.UPSTASH_TOKEN,
|
|
24
|
+
});
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Parameters
|
|
28
|
+
|
|
29
|
+
<PropertiesTable
|
|
30
|
+
content={[
|
|
31
|
+
{
|
|
32
|
+
name: "url",
|
|
33
|
+
type: "string",
|
|
34
|
+
description: "Upstash Redis URL",
|
|
35
|
+
isOptional: false,
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: "token",
|
|
39
|
+
type: "string",
|
|
40
|
+
description: "Upstash Redis authentication token",
|
|
41
|
+
isOptional: false,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "prefix",
|
|
45
|
+
type: "string",
|
|
46
|
+
description: "Key prefix for all stored items",
|
|
47
|
+
isOptional: true,
|
|
48
|
+
defaultValue: "mastra:",
|
|
49
|
+
},
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
## Additional Notes
|
|
54
|
+
|
|
55
|
+
### Key Structure
|
|
56
|
+
|
|
57
|
+
The Upstash storage implementation uses a key-value structure:
|
|
58
|
+
|
|
59
|
+
- Thread keys: `{prefix}thread:{threadId}`
|
|
60
|
+
- Message keys: `{prefix}message:{messageId}`
|
|
61
|
+
- Metadata keys: `{prefix}metadata:{entityId}`
|
|
62
|
+
|
|
63
|
+
### Serverless Benefits
|
|
64
|
+
|
|
65
|
+
Upstash storage is particularly well-suited for serverless deployments:
|
|
66
|
+
|
|
67
|
+
- No connection management needed
|
|
68
|
+
- Pay-per-request pricing
|
|
69
|
+
- Global replication options
|
|
70
|
+
- Edge-compatible
|
|
71
|
+
|
|
72
|
+
### Data Persistence
|
|
73
|
+
|
|
74
|
+
Upstash provides:
|
|
75
|
+
|
|
76
|
+
- Automatic data persistence
|
|
77
|
+
- Point-in-time recovery
|
|
78
|
+
- Cross-region replication options
|
|
79
|
+
|
|
80
|
+
### Performance Considerations
|
|
81
|
+
|
|
82
|
+
For optimal performance:
|
|
83
|
+
|
|
84
|
+
- Use appropriate key prefixes to organize data
|
|
85
|
+
- Monitor Redis memory usage
|
|
86
|
+
- Consider data expiration policies if needed
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: MastraMCPClient | Tool Discovery | Mastra Docs"
|
|
3
|
+
description: API Reference for MastraMCPClient - A client implementation for the Model Context Protocol.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# MastraMCPClient
|
|
7
|
+
|
|
8
|
+
The `MastraMCPClient` class provides a client implementation for interacting with Model Context Protocol (MCP) servers. It handles connection management, resource discovery, and tool execution through the MCP protocol.
|
|
9
|
+
|
|
10
|
+
## Constructor
|
|
11
|
+
|
|
12
|
+
Creates a new instance of the MastraMCPClient.
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
constructor({
|
|
16
|
+
name,
|
|
17
|
+
version = '1.0.0',
|
|
18
|
+
server,
|
|
19
|
+
capabilities = {},
|
|
20
|
+
timeout = 60000,
|
|
21
|
+
}: {
|
|
22
|
+
name: string;
|
|
23
|
+
server: StdioServerParameters | SSEClientParameters;
|
|
24
|
+
capabilities?: ClientCapabilities;
|
|
25
|
+
version?: string;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Parameters
|
|
31
|
+
|
|
32
|
+
<PropertiesTable
|
|
33
|
+
content={[
|
|
34
|
+
{
|
|
35
|
+
name: "name",
|
|
36
|
+
type: "string",
|
|
37
|
+
description: "The name identifier for this client instance.",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "version",
|
|
41
|
+
type: "string",
|
|
42
|
+
isOptional: true,
|
|
43
|
+
defaultValue: "1.0.0",
|
|
44
|
+
description: "The version of the client.",
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
name: "server",
|
|
48
|
+
type: "StdioServerParameters | SSEClientParameters",
|
|
49
|
+
description:
|
|
50
|
+
"Configuration parameters for either a stdio server connection or an SSE server connection.",
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
name: "capabilities",
|
|
54
|
+
type: "ClientCapabilities",
|
|
55
|
+
isOptional: true,
|
|
56
|
+
defaultValue: "{}",
|
|
57
|
+
description: "Optional capabilities configuration for the client.",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
name: "timeout",
|
|
61
|
+
type: "number",
|
|
62
|
+
isOptional: true,
|
|
63
|
+
defaultValue: 60000,
|
|
64
|
+
description: "The timeout duration, in milliseconds, for client tool calls.",
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
/>
|
|
68
|
+
|
|
69
|
+
## Methods
|
|
70
|
+
|
|
71
|
+
### connect()
|
|
72
|
+
|
|
73
|
+
Establishes a connection with the MCP server.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
async connect(): Promise<void>
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### disconnect()
|
|
80
|
+
|
|
81
|
+
Closes the connection with the MCP server.
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
async disconnect(): Promise<void>
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### resources()
|
|
88
|
+
|
|
89
|
+
Retrieves the list of available resources from the server.
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
async resources(): Promise<ListResourcesResult>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### tools()
|
|
96
|
+
|
|
97
|
+
Fetches and initializes available tools from the server, converting them into Mastra-compatible tool formats.
|
|
98
|
+
|
|
99
|
+
```typescript
|
|
100
|
+
async tools(): Promise<Record<string, Tool>>
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Returns an object mapping tool names to their corresponding Mastra tool implementations.
|
|
104
|
+
|
|
105
|
+
## Examples
|
|
106
|
+
|
|
107
|
+
### Using with Mastra Agent
|
|
108
|
+
|
|
109
|
+
#### Example with Stdio Server
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
import { Agent } from "@mastra/core/agent";
|
|
113
|
+
import { MastraMCPClient } from "@mastra/mcp";
|
|
114
|
+
import { openai } from "@ai-sdk/openai";
|
|
115
|
+
|
|
116
|
+
// Initialize the MCP client using mcp/fetch as an example https://hub.docker.com/r/mcp/fetch
|
|
117
|
+
// Visit https://github.com/docker/mcp-servers for other reference docker mcp servers
|
|
118
|
+
const fetchClient = new MastraMCPClient({
|
|
119
|
+
name: "fetch",
|
|
120
|
+
server: {
|
|
121
|
+
command: "docker",
|
|
122
|
+
args: ["run", "-i", "--rm", "mcp/fetch"],
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// Create a Mastra Agent
|
|
127
|
+
const agent = new Agent({
|
|
128
|
+
name: "Fetch agent",
|
|
129
|
+
instructions:
|
|
130
|
+
"You are able to fetch data from URLs on demand and discuss the response data with the user.",
|
|
131
|
+
model: openai("gpt-4o-mini"),
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
try {
|
|
135
|
+
// Connect to the MCP server
|
|
136
|
+
await fetchClient.connect();
|
|
137
|
+
|
|
138
|
+
// Gracefully handle process exits so the docker subprocess is cleaned up
|
|
139
|
+
process.on("exit", () => {
|
|
140
|
+
fetchClient.disconnect();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
// Get available tools
|
|
144
|
+
const tools = await fetchClient.tools();
|
|
145
|
+
|
|
146
|
+
// Use the agent with the MCP tools
|
|
147
|
+
const response = await agent.generate(
|
|
148
|
+
"Tell me about mastra.ai/docs. Tell me generally what this page is and the content it includes.",
|
|
149
|
+
{
|
|
150
|
+
toolsets: {
|
|
151
|
+
fetch: tools,
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
);
|
|
155
|
+
|
|
156
|
+
console.log("\n\n" + response.text);
|
|
157
|
+
} catch (error) {
|
|
158
|
+
console.error("Error:", error);
|
|
159
|
+
} finally {
|
|
160
|
+
// Always disconnect when done
|
|
161
|
+
await fetchClient.disconnect();
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
#### Example with SSE Server
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
// Initialize the MCP client using an SSE server
|
|
169
|
+
const sseClient = new MastraMCPClient({
|
|
170
|
+
name: "sse-client",
|
|
171
|
+
server: {
|
|
172
|
+
url: new URL("https://your-mcp-server.com/sse"),
|
|
173
|
+
// Optional fetch request configuration - Note: requestInit alone isn't enough for SSE
|
|
174
|
+
requestInit: {
|
|
175
|
+
headers: {
|
|
176
|
+
Authorization: "Bearer your-token",
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
// Required for SSE connections with custom headers
|
|
180
|
+
eventSourceInit: {
|
|
181
|
+
fetch(input: Request | URL | string, init?: RequestInit) {
|
|
182
|
+
const headers = new Headers(init?.headers || {});
|
|
183
|
+
headers.set('Authorization', 'Bearer your-token');
|
|
184
|
+
return fetch(input, {
|
|
185
|
+
...init,
|
|
186
|
+
headers,
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
},
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
// The rest of the usage is identical to the stdio example
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
### Important Note About SSE Authentication
|
|
197
|
+
|
|
198
|
+
When using SSE connections with authentication or custom headers, you need to configure both `requestInit` and `eventSourceInit`. This is because SSE connections use the browser's EventSource API, which doesn't support custom headers directly.
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
The `eventSourceInit` configuration allows you to customize the underlying fetch request used for the SSE connection, ensuring your authentication headers are properly included.
|
|
202
|
+
Without `eventSourceInit`, authentication headers specified in `requestInit` won't be included in the connection request, leading to 401 Unauthorized errors.
|
|
203
|
+
|
|
204
|
+
## Related Information
|
|
205
|
+
|
|
206
|
+
- For managing multiple MCP servers in your application, see the [MCPConfiguration documentation](./mcp-configuration)
|
|
207
|
+
- For more details about the Model Context Protocol, see the [@modelcontextprotocol/sdk documentation](https://github.com/modelcontextprotocol/typescript-sdk).
|