@mastra/mcp-docs-server 0.0.0-a2a-20250421213654
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 +253 -0
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +202 -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 +113 -0
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +281 -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 +302 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +302 -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 +426 -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 +331 -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 +288 -0
- package/.docs/raw/agents/adding-voice.mdx +200 -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/agents/runtime-variables.mdx +137 -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/overview.mdx +63 -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/model-capability.mdx +11 -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 +124 -0
- package/.docs/raw/mastra-cloud/deploying.mdx +136 -0
- package/.docs/raw/mastra-cloud/observability.mdx +163 -0
- package/.docs/raw/mastra-cloud/overview.mdx +57 -0
- package/.docs/raw/mastra-cloud/setting-up.mdx +122 -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 +126 -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 +212 -0
- package/.docs/raw/reference/deployer/deployer.mdx +159 -0
- package/.docs/raw/reference/deployer/netlify.mdx +116 -0
- package/.docs/raw/reference/deployer/vercel.mdx +122 -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 +249 -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 +501 -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/cloudflare-d1.mdx +89 -0
- package/.docs/raw/reference/storage/cloudflare.mdx +93 -0
- package/.docs/raw/reference/storage/libsql.mdx +74 -0
- package/.docs/raw/reference/storage/postgresql.mdx +93 -0
- package/.docs/raw/reference/storage/upstash.mdx +86 -0
- package/.docs/raw/reference/tools/client.mdx +321 -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 +222 -0
- package/.docs/raw/reference/tools/vector-query-tool.mdx +212 -0
- package/.docs/raw/reference/voice/azure.mdx +215 -0
- package/.docs/raw/reference/voice/cloudflare.mdx +152 -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 +432 -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.addInstructions.mdx +70 -0
- package/.docs/raw/reference/voice/voice.addTools.mdx +77 -0
- package/.docs/raw/reference/voice/voice.answer.mdx +69 -0
- package/.docs/raw/reference/voice/voice.close.mdx +56 -0
- package/.docs/raw/reference/voice/voice.connect.mdx +124 -0
- package/.docs/raw/reference/voice/voice.events.mdx +80 -0
- package/.docs/raw/reference/voice/voice.getSpeakers.mdx +283 -0
- package/.docs/raw/reference/voice/voice.listen.mdx +198 -0
- package/.docs/raw/reference/voice/voice.off.mdx +72 -0
- package/.docs/raw/reference/voice/voice.on.mdx +129 -0
- package/.docs/raw/reference/voice/voice.send.mdx +81 -0
- package/.docs/raw/reference/voice/voice.speak.mdx +203 -0
- package/.docs/raw/reference/voice/voice.updateConfig.mdx +87 -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 +816 -0
- package/.docs/raw/voice/speech-to-speech.mdx +73 -0
- package/.docs/raw/voice/speech-to-text.mdx +84 -0
- package/.docs/raw/voice/text-to-speech.mdx +89 -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 +170 -0
- package/.docs/raw/workflows/runtime-variables.mdx +153 -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 +140 -0
- package/dist/chunk-HYPVNJL7.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 +650 -0
- package/package.json +60 -0
|
@@ -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,321 @@
|
|
|
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: MastraMCPServerDefinition;
|
|
24
|
+
capabilities?: ClientCapabilities;
|
|
25
|
+
version?: string;
|
|
26
|
+
timeout?: number;
|
|
27
|
+
})
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
### Parameters
|
|
31
|
+
|
|
32
|
+
<br />
|
|
33
|
+
<PropertiesTable
|
|
34
|
+
content={[
|
|
35
|
+
{
|
|
36
|
+
name: "name",
|
|
37
|
+
type: "string",
|
|
38
|
+
description: "The name identifier for this client instance.",
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "version",
|
|
42
|
+
type: "string",
|
|
43
|
+
isOptional: true,
|
|
44
|
+
defaultValue: "1.0.0",
|
|
45
|
+
description: "The version of the client.",
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "server",
|
|
49
|
+
type: "MastraMCPServerDefinition",
|
|
50
|
+
description:
|
|
51
|
+
"Configuration parameters for either a stdio server connection or an SSE server connection. Can include log handler and server logs configuration.",
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "capabilities",
|
|
55
|
+
type: "ClientCapabilities",
|
|
56
|
+
isOptional: true,
|
|
57
|
+
defaultValue: "{}",
|
|
58
|
+
description: "Optional capabilities configuration for the client.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "timeout",
|
|
62
|
+
type: "number",
|
|
63
|
+
isOptional: true,
|
|
64
|
+
defaultValue: 60000,
|
|
65
|
+
description: "The timeout duration, in milliseconds, for client tool calls.",
|
|
66
|
+
},
|
|
67
|
+
]}
|
|
68
|
+
/>
|
|
69
|
+
|
|
70
|
+
### MastraMCPServerDefinition
|
|
71
|
+
|
|
72
|
+
MCP servers can be configured as either stdio-based or SSE-based servers. The configuration includes both server-specific settings and common options:
|
|
73
|
+
<br />
|
|
74
|
+
<PropertiesTable
|
|
75
|
+
content={[
|
|
76
|
+
{
|
|
77
|
+
name: "command",
|
|
78
|
+
type: "string",
|
|
79
|
+
isOptional: true,
|
|
80
|
+
description: "For stdio servers: The command to execute.",
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
name: "args",
|
|
84
|
+
type: "string[]",
|
|
85
|
+
isOptional: true,
|
|
86
|
+
description: "For stdio servers: Arguments to pass to the command.",
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
name: "env",
|
|
90
|
+
type: "Record<string, string>",
|
|
91
|
+
isOptional: true,
|
|
92
|
+
description: "For stdio servers: Environment variables to set for the command.",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
name: "url",
|
|
96
|
+
type: "URL",
|
|
97
|
+
isOptional: true,
|
|
98
|
+
description: "For SSE servers: The URL of the server.",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: "requestInit",
|
|
102
|
+
type: "RequestInit",
|
|
103
|
+
isOptional: true,
|
|
104
|
+
description: "For SSE servers: Request configuration for the fetch API.",
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: "eventSourceInit",
|
|
108
|
+
type: "EventSourceInit",
|
|
109
|
+
isOptional: true,
|
|
110
|
+
description: "For SSE servers: Custom fetch configuration for SSE connections. Required when using custom headers.",
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: "logger",
|
|
114
|
+
type: "LogHandler",
|
|
115
|
+
isOptional: true,
|
|
116
|
+
description: "Optional additional handler for logging.",
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: "timeout",
|
|
120
|
+
type: "number",
|
|
121
|
+
isOptional: true,
|
|
122
|
+
description: "Server-specific timeout in milliseconds.",
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: "capabilities",
|
|
126
|
+
type: "ClientCapabilities",
|
|
127
|
+
isOptional: true,
|
|
128
|
+
description: "Server-specific capabilities configuration.",
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: "enableServerLogs",
|
|
132
|
+
type: "boolean",
|
|
133
|
+
isOptional: true,
|
|
134
|
+
defaultValue: "true",
|
|
135
|
+
description: "Whether to enable logging for this server.",
|
|
136
|
+
},
|
|
137
|
+
]}
|
|
138
|
+
/>
|
|
139
|
+
|
|
140
|
+
### LogHandler
|
|
141
|
+
|
|
142
|
+
The `LogHandler` function takes a `LogMessage` object as its parameter and returns void. The `LogMessage` object has the following properties. The `LoggingLevel` type is a string enum with values: `debug`, `info`, `warn`, and `error`.
|
|
143
|
+
<br />
|
|
144
|
+
<PropertiesTable
|
|
145
|
+
content={[
|
|
146
|
+
{
|
|
147
|
+
name: "level",
|
|
148
|
+
type: "LoggingLevel",
|
|
149
|
+
description: "Log level (debug, info, warn, error)",
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: "message",
|
|
153
|
+
type: "string",
|
|
154
|
+
description: "Log message content",
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
name: "timestamp",
|
|
158
|
+
type: "Date",
|
|
159
|
+
description: "When the log was generated",
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "serverName",
|
|
163
|
+
type: "string",
|
|
164
|
+
description: "Name of the server that generated the log",
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "details",
|
|
168
|
+
type: "Record<string, any>",
|
|
169
|
+
isOptional: true,
|
|
170
|
+
description: "Optional additional log details",
|
|
171
|
+
},
|
|
172
|
+
]}
|
|
173
|
+
/>
|
|
174
|
+
|
|
175
|
+
## Methods
|
|
176
|
+
|
|
177
|
+
### connect()
|
|
178
|
+
|
|
179
|
+
Establishes a connection with the MCP server.
|
|
180
|
+
|
|
181
|
+
```typescript
|
|
182
|
+
async connect(): Promise<void>
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
### disconnect()
|
|
186
|
+
|
|
187
|
+
Closes the connection with the MCP server.
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
async disconnect(): Promise<void>
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
### resources()
|
|
194
|
+
|
|
195
|
+
Retrieves the list of available resources from the server.
|
|
196
|
+
|
|
197
|
+
```typescript
|
|
198
|
+
async resources(): Promise<ListResourcesResult>
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
### tools()
|
|
202
|
+
|
|
203
|
+
Fetches and initializes available tools from the server, converting them into Mastra-compatible tool formats.
|
|
204
|
+
|
|
205
|
+
```typescript
|
|
206
|
+
async tools(): Promise<Record<string, Tool>>
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
Returns an object mapping tool names to their corresponding Mastra tool implementations.
|
|
210
|
+
|
|
211
|
+
## Examples
|
|
212
|
+
|
|
213
|
+
### Using with Mastra Agent
|
|
214
|
+
|
|
215
|
+
#### Example with Stdio Server
|
|
216
|
+
|
|
217
|
+
```typescript
|
|
218
|
+
import { Agent } from "@mastra/core/agent";
|
|
219
|
+
import { MastraMCPClient } from "@mastra/mcp";
|
|
220
|
+
import { openai } from "@ai-sdk/openai";
|
|
221
|
+
|
|
222
|
+
// Initialize the MCP client using mcp/fetch as an example https://hub.docker.com/r/mcp/fetch
|
|
223
|
+
// Visit https://github.com/docker/mcp-servers for other reference docker mcp servers
|
|
224
|
+
const fetchClient = new MastraMCPClient({
|
|
225
|
+
name: "fetch",
|
|
226
|
+
server: {
|
|
227
|
+
command: "docker",
|
|
228
|
+
args: ["run", "-i", "--rm", "mcp/fetch"],
|
|
229
|
+
logger: (logMessage) => {
|
|
230
|
+
console.log(`[${logMessage.level}] ${logMessage.message}`);
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
// Create a Mastra Agent
|
|
236
|
+
const agent = new Agent({
|
|
237
|
+
name: "Fetch agent",
|
|
238
|
+
instructions:
|
|
239
|
+
"You are able to fetch data from URLs on demand and discuss the response data with the user.",
|
|
240
|
+
model: openai("gpt-4o-mini"),
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
try {
|
|
244
|
+
// Connect to the MCP server
|
|
245
|
+
await fetchClient.connect();
|
|
246
|
+
|
|
247
|
+
// Gracefully handle process exits so the docker subprocess is cleaned up
|
|
248
|
+
process.on("exit", () => {
|
|
249
|
+
fetchClient.disconnect();
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// Get available tools
|
|
253
|
+
const tools = await fetchClient.tools();
|
|
254
|
+
|
|
255
|
+
// Use the agent with the MCP tools
|
|
256
|
+
const response = await agent.generate(
|
|
257
|
+
"Tell me about mastra.ai/docs. Tell me generally what this page is and the content it includes.",
|
|
258
|
+
{
|
|
259
|
+
toolsets: {
|
|
260
|
+
fetch: tools,
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
);
|
|
264
|
+
|
|
265
|
+
console.log("\n\n" + response.text);
|
|
266
|
+
} catch (error) {
|
|
267
|
+
console.error("Error:", error);
|
|
268
|
+
} finally {
|
|
269
|
+
// Always disconnect when done
|
|
270
|
+
await fetchClient.disconnect();
|
|
271
|
+
}
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
### Example with SSE Server
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
// Initialize the MCP client using an SSE server
|
|
278
|
+
const sseClient = new MastraMCPClient({
|
|
279
|
+
name: "sse-client",
|
|
280
|
+
server: {
|
|
281
|
+
url: new URL("https://your-mcp-server.com/sse"),
|
|
282
|
+
// Optional fetch request configuration - Note: requestInit alone isn't enough for SSE
|
|
283
|
+
requestInit: {
|
|
284
|
+
headers: {
|
|
285
|
+
Authorization: "Bearer your-token",
|
|
286
|
+
},
|
|
287
|
+
},
|
|
288
|
+
// Required for SSE connections with custom headers
|
|
289
|
+
eventSourceInit: {
|
|
290
|
+
fetch(input: Request | URL | string, init?: RequestInit) {
|
|
291
|
+
const headers = new Headers(init?.headers || {});
|
|
292
|
+
headers.set('Authorization', 'Bearer your-token');
|
|
293
|
+
return fetch(input, {
|
|
294
|
+
...init,
|
|
295
|
+
headers,
|
|
296
|
+
});
|
|
297
|
+
},
|
|
298
|
+
},
|
|
299
|
+
// Optional additional logging configuration
|
|
300
|
+
logger: (logMessage) => {
|
|
301
|
+
console.log(`[${logMessage.level}] ${logMessage.serverName}: ${logMessage.message}`);
|
|
302
|
+
},
|
|
303
|
+
// Disable server logs
|
|
304
|
+
enableServerLogs: false
|
|
305
|
+
},
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
// The rest of the usage is identical to the stdio example
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Important Note About SSE Authentication
|
|
312
|
+
|
|
313
|
+
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.
|
|
314
|
+
|
|
315
|
+
The `eventSourceInit` configuration allows you to customize the underlying fetch request used for the SSE connection, ensuring your authentication headers are properly included.
|
|
316
|
+
Without `eventSourceInit`, authentication headers specified in `requestInit` won't be included in the connection request, leading to 401 Unauthorized errors.
|
|
317
|
+
|
|
318
|
+
## Related Information
|
|
319
|
+
|
|
320
|
+
- For managing multiple MCP servers in your application, see the [MCPConfiguration documentation](./mcp-configuration)
|
|
321
|
+
- For more details about the Model Context Protocol, see the [@modelcontextprotocol/sdk documentation](https://github.com/modelcontextprotocol/typescript-sdk).
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: createDocumentChunkerTool() | Tools | Mastra Docs"
|
|
3
|
+
description: Documentation for the Document Chunker Tool in Mastra, which splits documents into smaller chunks for efficient processing and retrieval.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# createDocumentChunkerTool()
|
|
7
|
+
|
|
8
|
+
The `createDocumentChunkerTool()` function creates a tool for splitting documents into smaller chunks for efficient processing and retrieval. It supports different chunking strategies and configurable parameters.
|
|
9
|
+
|
|
10
|
+
## Basic Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { createDocumentChunkerTool, MDocument } from "@mastra/rag";
|
|
14
|
+
|
|
15
|
+
const document = new MDocument({
|
|
16
|
+
text: "Your document content here...",
|
|
17
|
+
metadata: { source: "user-manual" }
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
const chunker = createDocumentChunkerTool({
|
|
21
|
+
doc: document,
|
|
22
|
+
params: {
|
|
23
|
+
strategy: "recursive",
|
|
24
|
+
size: 512,
|
|
25
|
+
overlap: 50,
|
|
26
|
+
separator: "\n"
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const { chunks } = await chunker.execute();
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Parameters
|
|
34
|
+
|
|
35
|
+
<PropertiesTable
|
|
36
|
+
content={[
|
|
37
|
+
{
|
|
38
|
+
name: "doc",
|
|
39
|
+
type: "MDocument",
|
|
40
|
+
description: "The document to be chunked",
|
|
41
|
+
isOptional: false,
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "params",
|
|
45
|
+
type: "ChunkParams",
|
|
46
|
+
description: "Configuration parameters for chunking",
|
|
47
|
+
isOptional: true,
|
|
48
|
+
defaultValue: "Default chunking parameters",
|
|
49
|
+
}
|
|
50
|
+
]}
|
|
51
|
+
/>
|
|
52
|
+
|
|
53
|
+
### ChunkParams
|
|
54
|
+
|
|
55
|
+
<PropertiesTable
|
|
56
|
+
content={[
|
|
57
|
+
{
|
|
58
|
+
name: "strategy",
|
|
59
|
+
type: "'recursive'",
|
|
60
|
+
description: "The chunking strategy to use",
|
|
61
|
+
isOptional: true,
|
|
62
|
+
defaultValue: "'recursive'",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "size",
|
|
66
|
+
type: "number",
|
|
67
|
+
description: "Target size of each chunk in tokens/characters",
|
|
68
|
+
isOptional: true,
|
|
69
|
+
defaultValue: "512",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "overlap",
|
|
73
|
+
type: "number",
|
|
74
|
+
description: "Number of overlapping tokens/characters between chunks",
|
|
75
|
+
isOptional: true,
|
|
76
|
+
defaultValue: "50",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "separator",
|
|
80
|
+
type: "string",
|
|
81
|
+
description: "Character(s) to use as chunk separator",
|
|
82
|
+
isOptional: true,
|
|
83
|
+
defaultValue: "'\\n'",
|
|
84
|
+
}
|
|
85
|
+
]}
|
|
86
|
+
/>
|
|
87
|
+
|
|
88
|
+
## Returns
|
|
89
|
+
|
|
90
|
+
<PropertiesTable
|
|
91
|
+
content={[
|
|
92
|
+
{
|
|
93
|
+
name: "chunks",
|
|
94
|
+
type: "DocumentChunk[]",
|
|
95
|
+
description: "Array of document chunks with their content and metadata",
|
|
96
|
+
}
|
|
97
|
+
]}
|
|
98
|
+
/>
|
|
99
|
+
|
|
100
|
+
## Example with Custom Parameters
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const technicalDoc = new MDocument({
|
|
104
|
+
text: longDocumentContent,
|
|
105
|
+
metadata: {
|
|
106
|
+
type: "technical",
|
|
107
|
+
version: "1.0"
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
const chunker = createDocumentChunkerTool({
|
|
112
|
+
doc: technicalDoc,
|
|
113
|
+
params: {
|
|
114
|
+
strategy: "recursive",
|
|
115
|
+
size: 1024, // Larger chunks
|
|
116
|
+
overlap: 100, // More overlap
|
|
117
|
+
separator: "\n\n" // Split on double newlines
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const { chunks } = await chunker.execute();
|
|
122
|
+
|
|
123
|
+
// Process the chunks
|
|
124
|
+
chunks.forEach((chunk, index) => {
|
|
125
|
+
console.log(`Chunk ${index + 1} length: ${chunk.content.length}`);
|
|
126
|
+
});
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Tool Details
|
|
130
|
+
|
|
131
|
+
The chunker is created as a Mastra tool with the following properties:
|
|
132
|
+
|
|
133
|
+
- **Tool ID**: `Document Chunker {strategy} {size}`
|
|
134
|
+
- **Description**: `Chunks document using {strategy} strategy with size {size} and {overlap} overlap`
|
|
135
|
+
- **Input Schema**: Empty object (no additional inputs required)
|
|
136
|
+
- **Output Schema**: Object containing the chunks array
|
|
137
|
+
|
|
138
|
+
## Related
|
|
139
|
+
|
|
140
|
+
- [MDocument](../rag/document.mdx)
|
|
141
|
+
- [createVectorQueryTool](./vector-query-tool)
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: createGraphRAGTool() | RAG | Mastra Tools Docs"
|
|
3
|
+
description: Documentation for the Graph RAG Tool in Mastra, which enhances RAG by building a graph of semantic relationships between documents.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# createGraphRAGTool()
|
|
7
|
+
|
|
8
|
+
The `createGraphRAGTool()` creates a tool that enhances RAG by building a graph of semantic relationships between documents. It uses the `GraphRAG` system under the hood to provide graph-based retrieval, finding relevant content through both direct similarity and connected relationships.
|
|
9
|
+
|
|
10
|
+
## Usage Example
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { openai } from "@ai-sdk/openai";
|
|
14
|
+
import { createGraphRAGTool } from "@mastra/rag";
|
|
15
|
+
|
|
16
|
+
const graphTool = createGraphRAGTool({
|
|
17
|
+
vectorStoreName: "pinecone",
|
|
18
|
+
indexName: "docs",
|
|
19
|
+
model: openai.embedding('text-embedding-3-small'),
|
|
20
|
+
graphOptions: {
|
|
21
|
+
dimension: 1536,
|
|
22
|
+
threshold: 0.7,
|
|
23
|
+
randomWalkSteps: 100,
|
|
24
|
+
restartProb: 0.15
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Parameters
|
|
30
|
+
|
|
31
|
+
<PropertiesTable
|
|
32
|
+
content={[
|
|
33
|
+
{
|
|
34
|
+
name: "vectorStoreName",
|
|
35
|
+
type: "string",
|
|
36
|
+
description: "Name of the vector store to query",
|
|
37
|
+
isOptional: false,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
name: "indexName",
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "Name of the index within the vector store",
|
|
43
|
+
isOptional: false,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
name: "model",
|
|
47
|
+
type: "EmbeddingModel",
|
|
48
|
+
description: "Embedding model to use for vector search",
|
|
49
|
+
isOptional: false,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "graphOptions",
|
|
53
|
+
type: "GraphOptions",
|
|
54
|
+
description: "Configuration for the graph-based retrieval",
|
|
55
|
+
isOptional: true,
|
|
56
|
+
defaultValue: "Default graph options",
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
name: "description",
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "Custom description for the tool. By default: 'Access and analyze relationships between information in the knowledge base to answer complex questions about connections and patterns'",
|
|
62
|
+
isOptional: true,
|
|
63
|
+
}
|
|
64
|
+
]}
|
|
65
|
+
/>
|
|
66
|
+
|
|
67
|
+
### GraphOptions
|
|
68
|
+
|
|
69
|
+
<PropertiesTable
|
|
70
|
+
content={[
|
|
71
|
+
{
|
|
72
|
+
name: "dimension",
|
|
73
|
+
type: "number",
|
|
74
|
+
description: "Dimension of the embedding vectors",
|
|
75
|
+
isOptional: true,
|
|
76
|
+
defaultValue: "1536",
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: "threshold",
|
|
80
|
+
type: "number",
|
|
81
|
+
description: "Similarity threshold for creating edges between nodes (0-1)",
|
|
82
|
+
isOptional: true,
|
|
83
|
+
defaultValue: "0.7",
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
name: "randomWalkSteps",
|
|
87
|
+
type: "number",
|
|
88
|
+
description: "Number of steps in random walk for graph traversal",
|
|
89
|
+
isOptional: true,
|
|
90
|
+
defaultValue: "100",
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
name: "restartProb",
|
|
94
|
+
type: "number",
|
|
95
|
+
description: "Probability of restarting random walk from query node",
|
|
96
|
+
isOptional: true,
|
|
97
|
+
defaultValue: "0.15",
|
|
98
|
+
}
|
|
99
|
+
]}
|
|
100
|
+
/>
|
|
101
|
+
|
|
102
|
+
## Returns
|
|
103
|
+
The tool returns an object with:
|
|
104
|
+
|
|
105
|
+
<PropertiesTable
|
|
106
|
+
content={[
|
|
107
|
+
{
|
|
108
|
+
name: "relevantContext",
|
|
109
|
+
type: "string",
|
|
110
|
+
description: "Combined text from the most relevant document chunks, retrieved using graph-based ranking",
|
|
111
|
+
}
|
|
112
|
+
]}
|
|
113
|
+
/>
|
|
114
|
+
|
|
115
|
+
## Default Tool Description
|
|
116
|
+
|
|
117
|
+
The default description focuses on:
|
|
118
|
+
- Analyzing relationships between documents
|
|
119
|
+
- Finding patterns and connections
|
|
120
|
+
- Answering complex queries
|
|
121
|
+
|
|
122
|
+
## Advanced Example
|
|
123
|
+
|
|
124
|
+
```typescript
|
|
125
|
+
const graphTool = createGraphRAGTool({
|
|
126
|
+
vectorStoreName: "pinecone",
|
|
127
|
+
indexName: "docs",
|
|
128
|
+
model: openai.embedding('text-embedding-3-small'),
|
|
129
|
+
graphOptions: {
|
|
130
|
+
dimension: 1536,
|
|
131
|
+
threshold: 0.8, // Higher similarity threshold
|
|
132
|
+
randomWalkSteps: 200, // More exploration steps
|
|
133
|
+
restartProb: 0.2 // Higher restart probability
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## Example with Custom Description
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
const graphTool = createGraphRAGTool({
|
|
142
|
+
vectorStoreName: "pinecone",
|
|
143
|
+
indexName: "docs",
|
|
144
|
+
model: openai.embedding('text-embedding-3-small'),
|
|
145
|
+
description: "Analyze document relationships to find complex patterns and connections in our company's historical data"
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
This example shows how to customize the tool description for a specific use case while maintaining its core purpose of relationship analysis.
|
|
150
|
+
|
|
151
|
+
## Related
|
|
152
|
+
|
|
153
|
+
- [createVectorQueryTool](./vector-query-tool)
|
|
154
|
+
- [GraphRAG](../rag/graph-rag)
|