@mastra/mcp-docs-server 0.13.18-alpha.1 → 0.13.19-alpha.0
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/%40internal%2Fstorage-test-utils.md +17 -17
- package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
- package/.docs/organized/changelogs/%40mastra%2Fagent-builder.md +29 -0
- package/.docs/organized/changelogs/%40mastra%2Fai-sdk.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fastra.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fchroma.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fcloud.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +46 -46
- package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloud.md +31 -0
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +28 -28
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +43 -43
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +22 -22
- package/.docs/organized/changelogs/%40mastra%2Fevals.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +19 -19
- package/.docs/organized/changelogs/%40mastra%2Fgithub.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Flance.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Floggers.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fmem0.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +34 -34
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +35 -35
- package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Frag.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fragie.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fs3vectors.md +10 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +30 -30
- package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-gladia.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google-gemini-live.md +16 -0
- package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +17 -17
- package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +17 -17
- package/.docs/organized/changelogs/create-mastra.md +21 -21
- package/.docs/organized/changelogs/mastra.md +44 -44
- package/.docs/organized/code-examples/ai-sdk-v5.md +8 -8
- package/.docs/organized/code-examples/heads-up-game.md +5 -5
- package/.docs/raw/rag/retrieval.mdx +19 -2
- package/.docs/raw/rag/vector-databases.mdx +39 -3
- package/.docs/raw/reference/observability/providers/arize-ax.mdx +81 -0
- package/.docs/raw/reference/observability/providers/arize-phoenix.mdx +120 -0
- package/.docs/raw/reference/observability/providers/index.mdx +3 -1
- package/.docs/raw/reference/rag/metadata-filters.mdx +15 -0
- package/.docs/raw/reference/rag/s3vectors.mdx +386 -0
- package/.docs/raw/reference/tools/mcp-server.mdx +27 -26
- package/.docs/raw/tools-mcp/mcp-overview.mdx +5 -6
- package/CHANGELOG.md +25 -0
- package/package.json +5 -5
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Arize Phoenix Integration | Mastra Observability Docs"
|
|
3
|
+
description: Documentation for integrating Arize Phoenix with Mastra, an open-source AI observability platform for monitoring and evaluating LLM applications.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Arize Phoenix
|
|
7
|
+
|
|
8
|
+
Arize Phoenix is an open-source AI observability platform designed for monitoring, evaluating, and improving LLM applications. It can be self-hosted or used via Phoenix Cloud.
|
|
9
|
+
|
|
10
|
+
## Configuration
|
|
11
|
+
|
|
12
|
+
### Phoenix Cloud
|
|
13
|
+
|
|
14
|
+
If you're using Phoenix Cloud, configure these environment variables:
|
|
15
|
+
|
|
16
|
+
```env
|
|
17
|
+
PHOENIX_API_KEY="your-phoenix-api-key"
|
|
18
|
+
PHOENIX_COLLECTOR_ENDPOINT="your-phoenix-hostname"
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
#### Getting Your Credentials
|
|
22
|
+
|
|
23
|
+
1. Sign up for an Arize Phoenix account at [app.phoenix.arize.com](https://app.phoenix.arize.com/login)
|
|
24
|
+
2. Grab your API key from the Keys option on the left bar
|
|
25
|
+
3. Note your Phoenix hostname for the collector endpoint
|
|
26
|
+
|
|
27
|
+
### Self-Hosted Phoenix
|
|
28
|
+
|
|
29
|
+
If you're running a self-hosted Phoenix instance, configure:
|
|
30
|
+
|
|
31
|
+
```env
|
|
32
|
+
PHOENIX_COLLECTOR_ENDPOINT="http://localhost:6006"
|
|
33
|
+
# Optional: If authentication enabled
|
|
34
|
+
PHOENIX_API_KEY="your-api-key"
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Installation
|
|
38
|
+
|
|
39
|
+
Install the necessary packages:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install @arizeai/openinference-mastra@^2.2.0
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Implementation
|
|
46
|
+
|
|
47
|
+
Here's how to configure Mastra to use Phoenix with OpenTelemetry:
|
|
48
|
+
|
|
49
|
+
### Phoenix Cloud Configuration
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
import { Mastra } from "@mastra/core";
|
|
53
|
+
import {
|
|
54
|
+
OpenInferenceOTLPTraceExporter,
|
|
55
|
+
isOpenInferenceSpan,
|
|
56
|
+
} from "@arizeai/openinference-mastra";
|
|
57
|
+
|
|
58
|
+
export const mastra = new Mastra({
|
|
59
|
+
// ... other config
|
|
60
|
+
telemetry: {
|
|
61
|
+
serviceName: "my-mastra-app",
|
|
62
|
+
enabled: true,
|
|
63
|
+
export: {
|
|
64
|
+
type: "custom",
|
|
65
|
+
exporter: new OpenInferenceOTLPTraceExporter({
|
|
66
|
+
url: process.env.PHOENIX_COLLECTOR_ENDPOINT!,
|
|
67
|
+
headers: {
|
|
68
|
+
Authorization: `Bearer ${process.env.PHOENIX_API_KEY}`,
|
|
69
|
+
},
|
|
70
|
+
spanFilter: isOpenInferenceSpan,
|
|
71
|
+
}),
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Self-Hosted Phoenix Configuration
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
import { Mastra } from "@mastra/core";
|
|
81
|
+
import {
|
|
82
|
+
OpenInferenceOTLPTraceExporter,
|
|
83
|
+
isOpenInferenceSpan,
|
|
84
|
+
} from "@arizeai/openinference-mastra";
|
|
85
|
+
|
|
86
|
+
export const mastra = new Mastra({
|
|
87
|
+
// ... other config
|
|
88
|
+
telemetry: {
|
|
89
|
+
serviceName: "my-mastra-app",
|
|
90
|
+
enabled: true,
|
|
91
|
+
export: {
|
|
92
|
+
type: "custom",
|
|
93
|
+
exporter: new OpenInferenceOTLPTraceExporter({
|
|
94
|
+
url: process.env.PHOENIX_COLLECTOR_ENDPOINT!,
|
|
95
|
+
spanFilter: isOpenInferenceSpan,
|
|
96
|
+
}),
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
## What Gets Automatically Traced
|
|
103
|
+
|
|
104
|
+
Mastra's comprehensive tracing captures:
|
|
105
|
+
|
|
106
|
+
- **Agent Operations**: All agent generation, streaming, and interaction calls
|
|
107
|
+
- **LLM Interactions**: Complete model calls with input/output messages and metadata
|
|
108
|
+
- **Tool Executions**: Function calls made by agents with parameters and results
|
|
109
|
+
- **Workflow Runs**: Step-by-step workflow execution with timing and dependencies
|
|
110
|
+
- **Memory Operations**: Agent memory queries, updates, and retrieval operations
|
|
111
|
+
|
|
112
|
+
All traces follow OpenTelemetry standards and include relevant metadata such as model parameters, token usage, execution timing, and error details.
|
|
113
|
+
|
|
114
|
+
## Dashboard
|
|
115
|
+
|
|
116
|
+
Once configured, you can view your traces and analytics in Phoenix:
|
|
117
|
+
- **Phoenix Cloud**: [app.phoenix.arize.com](https://app.phoenix.arize.com)
|
|
118
|
+
- **Self-hosted**: Your Phoenix instance URL (e.g., `http://localhost:6006`)
|
|
119
|
+
|
|
120
|
+
For self-hosting options, see the [Phoenix self-hosting documentation](https://arize.com/docs/phoenix/self-hosting).
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Reference: Provider List | Observability | Mastra Docs"
|
|
3
|
-
description: Overview of observability providers supported by Mastra, including Dash0, SigNoz, Braintrust, Langfuse, and more.
|
|
3
|
+
description: Overview of observability providers supported by Mastra, including Arize AX, Arize Phoenix, Dash0, SigNoz, Braintrust, Langfuse, and more.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Observability Providers
|
|
7
7
|
|
|
8
8
|
Observability providers include:
|
|
9
9
|
|
|
10
|
+
- [Arize AX](./providers/arize-ax.mdx)
|
|
11
|
+
- [Arize Phoenix](./providers/arize-phoenix.mdx)
|
|
10
12
|
- [Braintrust](./providers/braintrust.mdx)
|
|
11
13
|
- [Dash0](./providers/dash0.mdx)
|
|
12
14
|
- [Laminar](./providers/laminar.mdx)
|
|
@@ -319,6 +319,20 @@ const results = await store.query({
|
|
|
319
319
|
### Couchbase
|
|
320
320
|
- Currently does not have support for metadata filters. Filtering must be done client-side after retrieving results or by using the Couchbase SDK's Search capabilities directly for more complex queries.
|
|
321
321
|
|
|
322
|
+
### Amazon S3 Vectors
|
|
323
|
+
|
|
324
|
+
* Equality values must be primitives (string/number/boolean). `null`/`undefined`, arrays, objects, and Date are not allowed for equality. Range operators accept numbers or Date (Dates are normalized to epoch ms).
|
|
325
|
+
* `$in`/`$nin` require **non-empty arrays of primitives**; Date elements are allowed and normalized to epoch ms. **Array equality** is not supported.
|
|
326
|
+
* Implicit AND is canonicalized (`{a:1,b:2}` → `{$and:[{a:1},{b:2}]}`). Logical operators must contain field conditions, use non-empty arrays, and appear only at the root or within other logical operators (not inside field values).
|
|
327
|
+
* Keys listed in `nonFilterableMetadataKeys` at index creation are stored but not filterable; this setting is immutable.
|
|
328
|
+
* $exists requires a boolean value.
|
|
329
|
+
* undefined/null/empty filters are treated as no filter.
|
|
330
|
+
* Each metadata key name limited to 63 characters.
|
|
331
|
+
* Total metadata per vector: Up to 40 KB (filterable + non-filterable)
|
|
332
|
+
* Total metadata keys per vector: Up to 10
|
|
333
|
+
* Filterable metadata per vector: Up to 2 KB
|
|
334
|
+
* Non-filterable metadata keys per vector index: Up to 10
|
|
335
|
+
|
|
322
336
|
## Related
|
|
323
337
|
|
|
324
338
|
- [Astra](./astra)
|
|
@@ -330,3 +344,4 @@ const results = await store.query({
|
|
|
330
344
|
- [Pinecone](./pinecone)
|
|
331
345
|
- [Qdrant](./qdrant)
|
|
332
346
|
- [Upstash](./upstash)
|
|
347
|
+
- [Amazon S3 Vectors](./s3vectors)
|
|
@@ -0,0 +1,386 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Reference: Amazon S3 Vectors Store | Vector Databases | RAG | Mastra Docs"
|
|
3
|
+
description: Documentation for the S3Vectors class in Mastra, which provides vector search using Amazon S3 Vectors (Preview).
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Amazon S3 Vectors Store
|
|
7
|
+
|
|
8
|
+
> ⚠️ Amazon S3 Vectors is a Preview service.
|
|
9
|
+
> Preview features may change or be removed without notice and are not covered by AWS SLAs.
|
|
10
|
+
> Behavior, limits, and regional availability can change at any time.
|
|
11
|
+
> This library may introduce breaking changes to stay aligned with AWS.
|
|
12
|
+
|
|
13
|
+
The `S3Vectors` class provides vector search using [Amazon S3 Vectors (Preview)](https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-vectors.html). It stores vectors in **vector buckets** and performs similarity search in **vector indexes**, with JSON-based metadata filters.
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash copy
|
|
18
|
+
npm install @mastra/s3vectors
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage Example
|
|
22
|
+
|
|
23
|
+
```typescript copy showLineNumbers
|
|
24
|
+
import { S3Vectors } from "@mastra/s3vectors";
|
|
25
|
+
|
|
26
|
+
const store = new S3Vectors({
|
|
27
|
+
vectorBucketName: process.env.S3_VECTORS_BUCKET_NAME!, // e.g. "my-vector-bucket"
|
|
28
|
+
clientConfig: {
|
|
29
|
+
region: process.env.AWS_REGION!, // credentials use the default AWS provider chain
|
|
30
|
+
},
|
|
31
|
+
// Optional: mark large/long-text fields as non-filterable at index creation time
|
|
32
|
+
nonFilterableMetadataKeys: ["content"],
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
// Create an index (names are normalized: "_" → "-" and lowercased)
|
|
36
|
+
await store.createIndex({
|
|
37
|
+
indexName: "my_index",
|
|
38
|
+
dimension: 1536,
|
|
39
|
+
metric: "cosine", // "euclidean" also supported; "dotproduct" is NOT supported
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
// Upsert vectors (ids auto-generated if omitted). Date values in metadata are serialized to epoch ms.
|
|
43
|
+
const ids = await store.upsert({
|
|
44
|
+
indexName: "my_index",
|
|
45
|
+
vectors: [
|
|
46
|
+
[0.1, 0.2 /* … */],
|
|
47
|
+
[0.3, 0.4 /* … */],
|
|
48
|
+
],
|
|
49
|
+
metadata: [
|
|
50
|
+
{ text: "doc1", genre: "documentary", year: 2023, createdAt: new Date("2024-01-01") },
|
|
51
|
+
{ text: "doc2", genre: "comedy", year: 2021 },
|
|
52
|
+
],
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
// Query with metadata filters (implicit AND is canonicalized)
|
|
56
|
+
const results = await store.query({
|
|
57
|
+
indexName: "my-index",
|
|
58
|
+
queryVector: [0.1, 0.2 /* … */],
|
|
59
|
+
topK: 10, // Service-side limits may apply (commonly 30)
|
|
60
|
+
filter: { genre: { $in: ["documentary", "comedy"] }, year: { $gte: 2020 } },
|
|
61
|
+
includeVector: false, // set true to include raw vectors (may trigger a secondary fetch)
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Clean up resources (closes the underlying HTTP handler)
|
|
65
|
+
await store.disconnect();
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Constructor Options
|
|
69
|
+
|
|
70
|
+
<PropertiesTable
|
|
71
|
+
content={[
|
|
72
|
+
{
|
|
73
|
+
name: "vectorBucketName",
|
|
74
|
+
type: "string",
|
|
75
|
+
description: "Target S3 Vectors vector bucket name.",
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: "clientConfig",
|
|
79
|
+
type: "S3VectorsClientConfig",
|
|
80
|
+
isOptional: true,
|
|
81
|
+
description: "AWS SDK v3 client options (e.g., `region`, `credentials`).",
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
name: "nonFilterableMetadataKeys",
|
|
85
|
+
type: "string[]",
|
|
86
|
+
isOptional: true,
|
|
87
|
+
description: "Metadata keys that should NOT be filterable (applied to the index at creation time). Use this for large text fields like `content`.",
|
|
88
|
+
},
|
|
89
|
+
]}
|
|
90
|
+
/>
|
|
91
|
+
|
|
92
|
+
## Methods
|
|
93
|
+
|
|
94
|
+
### createIndex()
|
|
95
|
+
|
|
96
|
+
Creates a new vector index in the configured vector bucket. If the index already exists, the call validates the schema and becomes a no-op (existing metric and dimension are preserved).
|
|
97
|
+
|
|
98
|
+
<PropertiesTable
|
|
99
|
+
content={[
|
|
100
|
+
{
|
|
101
|
+
name: "indexName",
|
|
102
|
+
type: "string",
|
|
103
|
+
description: "Logical index name. Normalized internally: underscores are replaced with hyphens and the name is lowercased.",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: "dimension",
|
|
107
|
+
type: "number",
|
|
108
|
+
description: "Vector dimension (must match your embedding model)",
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
name: "metric",
|
|
112
|
+
type: "'cosine' | 'euclidean'",
|
|
113
|
+
isOptional: true,
|
|
114
|
+
defaultValue: "cosine",
|
|
115
|
+
description: "Distance metric for similarity search. `dotproduct` is not supported by S3 Vectors.",
|
|
116
|
+
},
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
|
|
120
|
+
### upsert()
|
|
121
|
+
|
|
122
|
+
Adds or replaces vectors (full-record put). If `ids` are not provided, UUIDs are generated.
|
|
123
|
+
|
|
124
|
+
<PropertiesTable
|
|
125
|
+
content={[
|
|
126
|
+
{
|
|
127
|
+
name: "indexName",
|
|
128
|
+
type: "string",
|
|
129
|
+
description: "Name of the index to upsert into",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
name: "vectors",
|
|
133
|
+
type: "number[][]",
|
|
134
|
+
description: "Array of embedding vectors",
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
name: "metadata",
|
|
138
|
+
type: "Record<string, any>[]",
|
|
139
|
+
isOptional: true,
|
|
140
|
+
description: "Metadata for each vector",
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
name: "ids",
|
|
144
|
+
type: "string[]",
|
|
145
|
+
isOptional: true,
|
|
146
|
+
description: "Optional vector IDs (auto-generated if not provided)",
|
|
147
|
+
},
|
|
148
|
+
]}
|
|
149
|
+
/>
|
|
150
|
+
|
|
151
|
+
### query()
|
|
152
|
+
|
|
153
|
+
Searches for nearest neighbors with optional metadata filtering.
|
|
154
|
+
|
|
155
|
+
<PropertiesTable
|
|
156
|
+
content={[
|
|
157
|
+
{
|
|
158
|
+
name: "indexName",
|
|
159
|
+
type: "string",
|
|
160
|
+
description: "Name of the index to query",
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: "queryVector",
|
|
164
|
+
type: "number[]",
|
|
165
|
+
description: "Query vector to find similar vectors",
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: "topK",
|
|
169
|
+
type: "number",
|
|
170
|
+
isOptional: true,
|
|
171
|
+
defaultValue: "10",
|
|
172
|
+
description: "Number of results to return",
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
name: "filter",
|
|
176
|
+
type: "S3VectorsFilter",
|
|
177
|
+
isOptional: true,
|
|
178
|
+
description: "JSON-based metadata filter supporting `$and`, `$or`, `$eq`, `$ne`, `$gt`, `$gte`, `$lt`, `$lte`, `$in`, `$nin`, `$exists`.",
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
name: "includeVector",
|
|
182
|
+
type: "boolean",
|
|
183
|
+
isOptional: true,
|
|
184
|
+
defaultValue: "false",
|
|
185
|
+
description: "Whether to include vectors in the results",
|
|
186
|
+
},
|
|
187
|
+
]}
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
> **Scoring:** Results include `score = 1/(1 + distance)` so that higher is better while preserving the underlying distance ranking.
|
|
192
|
+
|
|
193
|
+
### describeIndex()
|
|
194
|
+
|
|
195
|
+
Returns information about the index.
|
|
196
|
+
|
|
197
|
+
<PropertiesTable
|
|
198
|
+
content={[
|
|
199
|
+
{
|
|
200
|
+
name: "indexName",
|
|
201
|
+
type: "string",
|
|
202
|
+
description: "Index name to describe.",
|
|
203
|
+
},
|
|
204
|
+
]}
|
|
205
|
+
/>
|
|
206
|
+
|
|
207
|
+
Returns:
|
|
208
|
+
|
|
209
|
+
```typescript copy
|
|
210
|
+
interface IndexStats {
|
|
211
|
+
dimension: number;
|
|
212
|
+
count: number; // computed via ListVectors pagination (O(n))
|
|
213
|
+
metric: "cosine" | "euclidean";
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
### deleteIndex()
|
|
218
|
+
|
|
219
|
+
Deletes an index and its data.
|
|
220
|
+
|
|
221
|
+
<PropertiesTable
|
|
222
|
+
content={[
|
|
223
|
+
{
|
|
224
|
+
name: "indexName",
|
|
225
|
+
type: "string",
|
|
226
|
+
description: "Index to delete.",
|
|
227
|
+
},
|
|
228
|
+
]}
|
|
229
|
+
/>
|
|
230
|
+
|
|
231
|
+
### listIndexes()
|
|
232
|
+
|
|
233
|
+
Lists all indexes in the configured vector bucket.
|
|
234
|
+
|
|
235
|
+
Returns: `Promise<string[]>`
|
|
236
|
+
|
|
237
|
+
### updateVector()
|
|
238
|
+
|
|
239
|
+
Updates a vector or metadata for a specific ID within an index.
|
|
240
|
+
|
|
241
|
+
<PropertiesTable
|
|
242
|
+
content={[
|
|
243
|
+
{
|
|
244
|
+
name: "indexName",
|
|
245
|
+
type: "string",
|
|
246
|
+
description: "Index containing the vector.",
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
name: "id",
|
|
250
|
+
type: "string",
|
|
251
|
+
description: "ID to update.",
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
name: "update",
|
|
255
|
+
type: "object",
|
|
256
|
+
description: "Update data containing vector and/or metadata",
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
name: "update.vector",
|
|
260
|
+
type: "number[]",
|
|
261
|
+
isOptional: true,
|
|
262
|
+
description: "New vector data to update",
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: "update.metadata",
|
|
266
|
+
type: "Record<string, any>",
|
|
267
|
+
isOptional: true,
|
|
268
|
+
description: "New metadata to update",
|
|
269
|
+
},
|
|
270
|
+
]}
|
|
271
|
+
/>
|
|
272
|
+
|
|
273
|
+
### deleteVector()
|
|
274
|
+
|
|
275
|
+
Deletes a specific vector by ID.
|
|
276
|
+
|
|
277
|
+
<PropertiesTable
|
|
278
|
+
content={[
|
|
279
|
+
{
|
|
280
|
+
name: "indexName",
|
|
281
|
+
type: "string",
|
|
282
|
+
description: "Index containing the vector.",
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: "id",
|
|
286
|
+
type: "string",
|
|
287
|
+
description: "ID to delete.",
|
|
288
|
+
},
|
|
289
|
+
]}
|
|
290
|
+
/>
|
|
291
|
+
|
|
292
|
+
### disconnect()
|
|
293
|
+
|
|
294
|
+
Closes the underlying AWS SDK HTTP handler to free sockets.
|
|
295
|
+
|
|
296
|
+
## Response Types
|
|
297
|
+
|
|
298
|
+
Query results are returned in this format:
|
|
299
|
+
|
|
300
|
+
```typescript copy
|
|
301
|
+
interface QueryResult {
|
|
302
|
+
id: string;
|
|
303
|
+
score: number; // 1/(1 + distance)
|
|
304
|
+
metadata: Record<string, any>;
|
|
305
|
+
vector?: number[]; // Only included if includeVector is true
|
|
306
|
+
}
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Filter Syntax
|
|
310
|
+
|
|
311
|
+
S3 Vectors supports a strict subset of operators and value types. The Mastra filter translator:
|
|
312
|
+
|
|
313
|
+
* **Canonicalizes implicit AND**: `{a:1,b:2}` → `{ $and: [{a:1},{b:2}] }`.
|
|
314
|
+
* **Normalizes Date values** to epoch ms for numeric comparisons and array elements.
|
|
315
|
+
* **Disallows Date** in equality positions (`field: value` or `$eq/$ne`); equality values must be **string | number | boolean**.
|
|
316
|
+
* **Rejects** null/undefined for equality; **array equality** is not supported (use `$in`/`$nin`).
|
|
317
|
+
* Only **`$and` / `$or`** are allowed as top-level logical operators.
|
|
318
|
+
* Logical operators must contain **field conditions** (not direct operators).
|
|
319
|
+
|
|
320
|
+
**Supported operators:**
|
|
321
|
+
|
|
322
|
+
* **Logical:** `$and`, `$or` (non-empty arrays)
|
|
323
|
+
* **Basic:** `$eq`, `$ne` (string | number | boolean)
|
|
324
|
+
* **Numeric:** `$gt`, `$gte`, `$lt`, `$lte` (number or `Date` → epoch ms)
|
|
325
|
+
* **Array:** `$in`, `$nin` (non-empty arrays of string | number | boolean; `Date` → epoch ms)
|
|
326
|
+
* **Element:** `$exists` (boolean)
|
|
327
|
+
|
|
328
|
+
**Unsupported / disallowed (rejected):** `$not`, `$nor`, `$regex`, `$all`, `$elemMatch`, `$size`, `$text`, etc.
|
|
329
|
+
|
|
330
|
+
**Examples:**
|
|
331
|
+
|
|
332
|
+
```typescript copy
|
|
333
|
+
// Implicit AND
|
|
334
|
+
{ genre: { $in: ["documentary", "comedy"] }, year: { $gte: 2020 } }
|
|
335
|
+
|
|
336
|
+
// Explicit logicals and ranges
|
|
337
|
+
{
|
|
338
|
+
$and: [
|
|
339
|
+
{ price: { $gte: 100, $lte: 1000 } },
|
|
340
|
+
{ $or: [{ stock: { $gt: 0 } }, { preorder: true }] }
|
|
341
|
+
]
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
// Dates in range (converted to epoch ms)
|
|
345
|
+
{ timestamp: { $gt: new Date("2024-01-01T00:00:00Z") } }
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
> **Non-filterable keys:** If you set `nonFilterableMetadataKeys` at index creation, those keys are stored but **cannot** be used in filters.
|
|
349
|
+
|
|
350
|
+
## Error Handling
|
|
351
|
+
|
|
352
|
+
The store throws typed errors that can be caught:
|
|
353
|
+
|
|
354
|
+
```typescript copy
|
|
355
|
+
try {
|
|
356
|
+
await store.query({
|
|
357
|
+
indexName: "index-name",
|
|
358
|
+
queryVector: queryVector,
|
|
359
|
+
});
|
|
360
|
+
} catch (error) {
|
|
361
|
+
if (error instanceof VectorStoreError) {
|
|
362
|
+
console.log(error.code); // 'connection_failed' | 'invalid_dimension' | etc
|
|
363
|
+
console.log(error.details); // Additional error context
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
## Environment Variables
|
|
369
|
+
|
|
370
|
+
Typical environment variables when wiring your app:
|
|
371
|
+
|
|
372
|
+
* `S3_VECTORS_BUCKET_NAME`: Your S3 **vector bucket** name (used to populate `vectorBucketName`).
|
|
373
|
+
* `AWS_REGION`: AWS region for the S3 Vectors bucket.
|
|
374
|
+
* **AWS credentials**: via the standard AWS SDK provider chain (`AWS_ACCESS_KEY_ID`, `AWS_SECRET_ACCESS_KEY`, `AWS_PROFILE`, etc.).
|
|
375
|
+
|
|
376
|
+
## Best Practices
|
|
377
|
+
|
|
378
|
+
* Choose the metric (`cosine` or `euclidean`) to match your embedding model; `dotproduct` is not supported.
|
|
379
|
+
* Keep **filterable** metadata small and structured (string/number/boolean). Store large text (e.g., `content`) as **non-filterable**.
|
|
380
|
+
* Use **dotted paths** for nested metadata and explicit `$and`/`$or` for complex logic.
|
|
381
|
+
* Avoid calling `describeIndex()` on hot paths—`count` is computed with paginated `ListVectors` (**O(n)**).
|
|
382
|
+
* Use `includeVector: true` only when you need raw vectors.
|
|
383
|
+
|
|
384
|
+
## Related
|
|
385
|
+
|
|
386
|
+
* [Metadata Filters](./metadata-filters)
|
|
@@ -18,7 +18,8 @@ To create a new `MCPServer`, you need to provide some basic information about yo
|
|
|
18
18
|
```typescript
|
|
19
19
|
import { openai } from "@ai-sdk/openai";
|
|
20
20
|
import { Agent } from "@mastra/core/agent";
|
|
21
|
-
import {
|
|
21
|
+
import { createTool } from "@mastra/core/tools";
|
|
22
|
+
import { MCPServer } from "@mastra/mcp";
|
|
22
23
|
import { z } from "zod";
|
|
23
24
|
import { dataProcessingWorkflow } from "../workflows/dataProcessingWorkflow";
|
|
24
25
|
|
|
@@ -29,7 +30,7 @@ const myAgent = new Agent({
|
|
|
29
30
|
model: openai("gpt-4o-mini"),
|
|
30
31
|
});
|
|
31
32
|
|
|
32
|
-
const weatherTool =
|
|
33
|
+
const weatherTool = createTool({
|
|
33
34
|
id: "getWeather",
|
|
34
35
|
description: "Gets the current weather for a location.",
|
|
35
36
|
inputSchema: z.object({ location: z.string() }),
|
|
@@ -68,10 +69,10 @@ The constructor accepts an `MCPServerConfig` object with the following propertie
|
|
|
68
69
|
},
|
|
69
70
|
{
|
|
70
71
|
name: "tools",
|
|
71
|
-
type: "
|
|
72
|
+
type: "ToolsInput",
|
|
72
73
|
isOptional: false,
|
|
73
74
|
description:
|
|
74
|
-
"An object where keys are tool names and values are tool definitions
|
|
75
|
+
"An object where keys are tool names and values are Mastra tool definitions (created with `createTool` or Vercel AI SDK). These tools will be directly exposed.",
|
|
75
76
|
},
|
|
76
77
|
{
|
|
77
78
|
name: "agents",
|
|
@@ -845,18 +846,17 @@ The `MCPServer` class automatically includes elicitation capabilities. Tools rec
|
|
|
845
846
|
When tools are executed within an MCP server context, they receive an additional `options` parameter:
|
|
846
847
|
|
|
847
848
|
```typescript
|
|
848
|
-
execute: async (
|
|
849
|
-
//
|
|
850
|
-
// elicitation
|
|
851
|
-
// extra contains MCP-specific context (auth, session, etc.)
|
|
849
|
+
execute: async ({ context }, options) => {
|
|
850
|
+
// context contains the tool's input parameters
|
|
851
|
+
// options contains server capabilities like elicitation and authentication info
|
|
852
852
|
|
|
853
853
|
// Access authentication information (when available)
|
|
854
|
-
if (extra?.authInfo) {
|
|
855
|
-
console.log('Authenticated request from:', extra.authInfo.clientId);
|
|
854
|
+
if (options.extra?.authInfo) {
|
|
855
|
+
console.log('Authenticated request from:', options.extra.authInfo.clientId);
|
|
856
856
|
}
|
|
857
857
|
|
|
858
858
|
// Use elicitation capabilities
|
|
859
|
-
const result = await elicitation.sendRequest({
|
|
859
|
+
const result = await options.elicitation.sendRequest({
|
|
860
860
|
message: "Please provide information",
|
|
861
861
|
requestedSchema: { /* schema */ }
|
|
862
862
|
});
|
|
@@ -881,28 +881,29 @@ A common use case is during tool execution. When a tool needs user input, it can
|
|
|
881
881
|
Here's an example of a tool that uses elicitation to collect user contact information:
|
|
882
882
|
|
|
883
883
|
```typescript
|
|
884
|
-
import { MCPServer
|
|
884
|
+
import { MCPServer } from "@mastra/mcp";
|
|
885
|
+
import { createTool } from "@mastra/core/tools";
|
|
885
886
|
import { z } from "zod";
|
|
886
887
|
|
|
887
888
|
const server = new MCPServer({
|
|
888
889
|
name: "Interactive Server",
|
|
889
890
|
version: "1.0.0",
|
|
890
891
|
tools: {
|
|
891
|
-
collectContactInfo:
|
|
892
|
+
collectContactInfo: createTool({
|
|
892
893
|
id: "collectContactInfo",
|
|
893
894
|
description: "Collects user contact information through elicitation",
|
|
894
895
|
inputSchema: z.object({
|
|
895
896
|
reason: z.string().optional().describe("Reason for collecting contact info"),
|
|
896
897
|
}),
|
|
897
|
-
execute: async (
|
|
898
|
-
const { reason } =
|
|
898
|
+
execute: async ({ context }, options) => {
|
|
899
|
+
const { reason } = context;
|
|
899
900
|
|
|
900
901
|
// Log session info if available
|
|
901
|
-
console.log('Request from session:', extra?.sessionId);
|
|
902
|
+
console.log('Request from session:', options.extra?.sessionId);
|
|
902
903
|
|
|
903
904
|
try {
|
|
904
905
|
// Request user input via elicitation
|
|
905
|
-
const result = await elicitation.sendRequest({
|
|
906
|
+
const result = await options.elicitation.sendRequest({
|
|
906
907
|
message: reason
|
|
907
908
|
? `Please provide your contact information. ${reason}`
|
|
908
909
|
: 'Please provide your contact information',
|
|
@@ -1009,17 +1010,17 @@ Tools should handle all three response types appropriately.
|
|
|
1009
1010
|
The elicitation functionality is available through the `options` parameter in tool execution:
|
|
1010
1011
|
|
|
1011
1012
|
```typescript
|
|
1012
|
-
// Within a tool's execute function
|
|
1013
|
-
execute: async (
|
|
1013
|
+
// Within a tool's execute function
|
|
1014
|
+
execute: async ({ context }, options) => {
|
|
1014
1015
|
// Use elicitation for user input
|
|
1015
|
-
const result = await elicitation.sendRequest({
|
|
1016
|
+
const result = await options.elicitation.sendRequest({
|
|
1016
1017
|
message: string, // Message to display to user
|
|
1017
1018
|
requestedSchema: object // JSON schema defining expected response structure
|
|
1018
1019
|
}): Promise<ElicitResult>
|
|
1019
1020
|
|
|
1020
1021
|
// Access authentication info if needed
|
|
1021
|
-
if (extra?.authInfo) {
|
|
1022
|
-
// Use extra.authInfo.token, etc.
|
|
1022
|
+
if (options.extra?.authInfo) {
|
|
1023
|
+
// Use options.extra.authInfo.token, etc.
|
|
1023
1024
|
}
|
|
1024
1025
|
}
|
|
1025
1026
|
```
|
|
@@ -1040,15 +1041,15 @@ type ElicitResult = {
|
|
|
1040
1041
|
Tools can access request metadata via `options.extra` when using HTTP-based transports:
|
|
1041
1042
|
|
|
1042
1043
|
```typescript
|
|
1043
|
-
execute: async (
|
|
1044
|
-
if (!extra?.authInfo?.token) {
|
|
1044
|
+
execute: async ({ context }, options) => {
|
|
1045
|
+
if (!options.extra?.authInfo?.token) {
|
|
1045
1046
|
return "Authentication required";
|
|
1046
1047
|
}
|
|
1047
1048
|
|
|
1048
1049
|
// Use the auth token
|
|
1049
1050
|
const response = await fetch('/api/data', {
|
|
1050
|
-
headers: { Authorization: `Bearer ${extra.authInfo.token}` },
|
|
1051
|
-
signal: extra.signal,
|
|
1051
|
+
headers: { Authorization: `Bearer ${options.extra.authInfo.token}` },
|
|
1052
|
+
signal: options.extra.signal,
|
|
1052
1053
|
});
|
|
1053
1054
|
|
|
1054
1055
|
return response.json();
|