@mastra/mcp-docs-server 1.2.8-alpha.7 → 1.2.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/docs/agent-builder/integrations.md +1 -3
- package/.docs/docs/agent-builder/overview.md +2 -0
- package/.docs/docs/agents/overview.md +17 -13
- package/.docs/docs/agents/skills.md +1 -3
- package/.docs/docs/agents/structured-output.md +2 -0
- package/.docs/docs/agents/using-tools.md +66 -49
- package/.docs/docs/browser/agent-browser.md +1 -0
- package/.docs/docs/browser/firecrawl.md +129 -0
- package/.docs/docs/browser/overview.md +16 -2
- package/.docs/docs/capabilities/channels/slack.md +111 -1
- package/.docs/docs/deployment/mastra-server.md +35 -0
- package/.docs/docs/deployment/monorepo.md +2 -0
- package/.docs/docs/deployment/overview.md +6 -0
- package/.docs/docs/deployment/sandbox.md +277 -0
- package/.docs/docs/editor/overview.md +2 -6
- package/.docs/docs/editor/tools.md +2 -6
- package/.docs/docs/evals/multi-turn.md +1 -1
- package/.docs/docs/evals/running-in-ci.md +3 -9
- package/.docs/docs/getting-started/build-with-ai.md +2 -6
- package/.docs/docs/getting-started/manual-install.md +1 -1
- package/.docs/docs/index.md +17 -13
- package/.docs/docs/long-running-agents/background-tasks.md +2 -2
- package/.docs/docs/long-running-agents/goals.md +3 -1
- package/.docs/docs/mastra-platform/database.md +12 -6
- package/.docs/docs/mastra-platform/deploy.md +14 -7
- package/.docs/docs/mastra-platform/environments.md +5 -4
- package/.docs/docs/mastra-platform/observability.md +4 -12
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/mastra-platform/regions.md +73 -0
- package/.docs/docs/mastra-platform/workspace.md +111 -0
- package/.docs/docs/memory/observational-memory.md +77 -2
- package/.docs/docs/memory/overview.md +4 -0
- package/.docs/docs/observability/feedback.md +4 -0
- package/.docs/docs/observability/integrations/bridges/otel.md +1 -3
- package/.docs/docs/observability/integrations/exporters/otel.md +1 -3
- package/.docs/docs/server/auth/fga.md +40 -0
- package/.docs/docs/server/auth/simple-auth.md +1 -3
- package/.docs/docs/studio/overview.md +2 -0
- package/.docs/docs/workflows/control-flow.md +1 -3
- package/.docs/docs/workspace/filesystem.md +1 -0
- package/.docs/docs/workspace/sandbox.md +1 -0
- package/.docs/guides/getting-started/quickstart.md +40 -25
- package/.docs/guides/index.md +1 -1
- package/.docs/guides/migrations/vnext-to-standard-apis.md +1 -3
- package/.docs/models/environment-variables.md +3 -0
- package/.docs/models/gateways/netlify.md +3 -6
- package/.docs/models/gateways/openrouter.md +343 -344
- package/.docs/models/gateways/vercel.md +11 -5
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/aki-io.md +78 -0
- package/.docs/models/providers/alibaba-token-plan-cn.md +22 -21
- package/.docs/models/providers/alibaba-token-plan.md +22 -21
- package/.docs/models/providers/ambient.md +12 -10
- package/.docs/models/providers/baseten.md +3 -2
- package/.docs/models/providers/cline-pass.md +82 -0
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/crossmodel.md +2 -1
- package/.docs/models/providers/deepinfra.md +4 -7
- package/.docs/models/providers/deepseek.md +3 -1
- package/.docs/models/providers/empiriolabs.md +2 -1
- package/.docs/models/providers/evroc.md +3 -2
- package/.docs/models/providers/google.md +4 -2
- package/.docs/models/providers/huggingface.md +2 -1
- package/.docs/models/providers/inferx.md +3 -3
- package/.docs/models/providers/kenari.md +44 -29
- package/.docs/models/providers/kimi-for-coding.md +7 -9
- package/.docs/models/providers/llmgateway.md +4 -1
- package/.docs/models/providers/moonshotai-cn.md +3 -2
- package/.docs/models/providers/moonshotai.md +3 -2
- package/.docs/models/providers/nebius.md +3 -1
- package/.docs/models/providers/novita-ai.md +3 -1
- package/.docs/models/providers/opencode-go.md +6 -3
- package/.docs/models/providers/opencode.md +4 -2
- package/.docs/models/providers/poolside.md +2 -2
- package/.docs/models/providers/thinkingmachines.md +73 -0
- package/.docs/models/providers/togetherai.md +2 -6
- package/.docs/models/providers/wandb.md +2 -1
- package/.docs/models/providers/zenmux.md +3 -1
- package/.docs/models/providers.md +3 -0
- package/.docs/reference/agent-controller/session.md +13 -0
- package/.docs/reference/agents/agent.md +13 -1
- package/.docs/reference/agents/generate.md +18 -0
- package/.docs/reference/browser/firecrawl-browser.md +71 -0
- package/.docs/reference/cli/create-mastra.md +118 -43
- package/.docs/reference/cli/mastra.md +59 -5
- package/.docs/reference/code-sdk/mount-agent-controller.md +4 -4
- package/.docs/reference/core/getMCPServer.md +1 -3
- package/.docs/reference/core/getMCPServerById.md +1 -3
- package/.docs/reference/core/getWorkflow.md +1 -3
- package/.docs/reference/core/listMCPServers.md +2 -6
- package/.docs/reference/datasets/addItem.md +1 -3
- package/.docs/reference/datasets/addItems.md +1 -3
- package/.docs/reference/datasets/compareExperiments.md +1 -3
- package/.docs/reference/datasets/create.md +1 -3
- package/.docs/reference/datasets/dataset.md +2 -6
- package/.docs/reference/datasets/datasets-manager.md +5 -15
- package/.docs/reference/datasets/delete.md +1 -3
- package/.docs/reference/datasets/deleteExperiment.md +1 -3
- package/.docs/reference/datasets/deleteItem.md +1 -3
- package/.docs/reference/datasets/deleteItems.md +1 -3
- package/.docs/reference/datasets/get.md +1 -3
- package/.docs/reference/datasets/getDetails.md +1 -3
- package/.docs/reference/datasets/getExperiment.md +1 -3
- package/.docs/reference/datasets/getItem.md +1 -3
- package/.docs/reference/datasets/getItemHistory.md +1 -3
- package/.docs/reference/datasets/list.md +1 -3
- package/.docs/reference/datasets/listExperimentResults.md +1 -3
- package/.docs/reference/datasets/listExperiments.md +1 -3
- package/.docs/reference/datasets/listItems.md +1 -3
- package/.docs/reference/datasets/listVersions.md +1 -3
- package/.docs/reference/datasets/startExperiment.md +1 -3
- package/.docs/reference/datasets/startExperimentAsync.md +1 -3
- package/.docs/reference/datasets/update.md +1 -3
- package/.docs/reference/datasets/updateItem.md +1 -3
- package/.docs/reference/editor/mastra-editor.md +1 -3
- package/.docs/reference/evals/context-recall.md +205 -0
- package/.docs/reference/evals/create-scorer.md +3 -9
- package/.docs/reference/evals/mastra-scorer.md +1 -3
- package/.docs/reference/file-based-agents/tools.md +7 -6
- package/.docs/reference/index.md +5 -0
- package/.docs/reference/memory/observational-memory.md +21 -0
- package/.docs/reference/observability/tracing/exporters/posthog.md +39 -1
- package/.docs/reference/observability/tracing/processors/sensitive-data-filter.md +1 -3
- package/.docs/reference/processors/token-limiter-processor.md +1 -3
- package/.docs/reference/rag/database-config.md +12 -0
- package/.docs/reference/streaming/agents/stream.md +2 -0
- package/.docs/reference/templates/overview.md +6 -32
- package/.docs/reference/tools/create-tool.md +78 -52
- package/.docs/reference/tools/mcp-client.md +8 -24
- package/.docs/reference/tools/mcp-server.md +143 -44
- package/.docs/reference/tools/tavily.md +1 -1
- package/.docs/reference/tools/vector-query-tool.md +22 -0
- package/.docs/reference/vectors/mongodb.md +2 -0
- package/.docs/reference/vectors/turbopuffer.md +4 -0
- package/.docs/reference/voice/mistral.md +127 -0
- package/.docs/reference/workspace/daytona-sandbox.md +2 -6
- package/.docs/reference/workspace/platform-filesystem.md +182 -0
- package/.docs/reference/workspace/platform-sandbox.md +200 -0
- package/.docs/reference/workspace/railway-sandbox.md +37 -1
- package/CHANGELOG.md +78 -0
- package/dist/{chunk-GLPCVXXO.js → chunk-HGADBLKG.js} +2 -2
- package/dist/{chunk-GLPCVXXO.js.map → chunk-HGADBLKG.js.map} +1 -1
- package/dist/index.js +1 -1
- package/dist/stdio.js +1 -1
- package/dist/tools/docs.d.ts.map +1 -1
- package/package.json +8 -8
|
@@ -14,9 +14,7 @@ To opt out or customize the auto-applied filter, use the `sensitiveDataFilter` o
|
|
|
14
14
|
import { Observability } from '@mastra/observability'
|
|
15
15
|
|
|
16
16
|
new Observability({
|
|
17
|
-
configs: {
|
|
18
|
-
/* ... */
|
|
19
|
-
},
|
|
17
|
+
configs: {/* ... */},
|
|
20
18
|
// disable the auto-applied filter
|
|
21
19
|
sensitiveDataFilter: false,
|
|
22
20
|
// or customize it
|
|
@@ -85,9 +85,7 @@ export const agent = new Agent({
|
|
|
85
85
|
name: 'context-limited-agent',
|
|
86
86
|
instructions: 'You are a helpful assistant',
|
|
87
87
|
model: 'openai/gpt-5.5',
|
|
88
|
-
memory: new Memory({
|
|
89
|
-
/* ... */
|
|
90
|
-
}),
|
|
88
|
+
memory: new Memory({/* ... */}),
|
|
91
89
|
inputProcessors: [
|
|
92
90
|
new TokenLimiterProcessor({ limit: 4000 }), // Limits historical messages to ~4000 tokens
|
|
93
91
|
],
|
|
@@ -11,6 +11,7 @@ export type DatabaseConfig = {
|
|
|
11
11
|
pinecone?: PineconeConfig
|
|
12
12
|
pgvector?: PgVectorConfig
|
|
13
13
|
chroma?: ChromaConfig
|
|
14
|
+
turbopuffer?: TurbopufferConfig
|
|
14
15
|
[key: string]: any // Extensible for future databases
|
|
15
16
|
}
|
|
16
17
|
```
|
|
@@ -90,6 +91,17 @@ whereDocument: { "$contains": "API documentation" }
|
|
|
90
91
|
- Content-based document filtering
|
|
91
92
|
- Complex query combinations
|
|
92
93
|
|
|
94
|
+
### `TurbopufferConfig`
|
|
95
|
+
|
|
96
|
+
Configuration options specific to Turbopuffer vector store.
|
|
97
|
+
|
|
98
|
+
**consistency** (`'strong' | 'eventual'`): The consistency level for queries. "strong" (default) guarantees queries see all data written before the query started, at the cost of higher latency. "eventual" offers lower latency, but recently written data may not be visible yet.
|
|
99
|
+
|
|
100
|
+
**Use Cases:**
|
|
101
|
+
|
|
102
|
+
- Latency-sensitive queries where slightly stale data is acceptable (`eventual`)
|
|
103
|
+
- Read-your-writes workflows that must see the latest data (`strong`)
|
|
104
|
+
|
|
93
105
|
## Usage examples
|
|
94
106
|
|
|
95
107
|
**Basic Usage**:
|
|
@@ -124,6 +124,8 @@ const stream = await agent.stream('message for agent')
|
|
|
124
124
|
|
|
125
125
|
**options.memory.options** (`MemoryConfig`): Configuration for memory behavior including lastMessages, readOnly, semanticRecall, workingMemory, and filterIncompleteToolCalls.
|
|
126
126
|
|
|
127
|
+
**options.memory.onTitleGenerated** (`(title: string) => void | Promise<void>`): Callback fired asynchronously when a thread title is generated and persisted to storage. Title generation runs in the background and may complete after the stream ends. Only fires when generateTitle is enabled in memory options and the thread has no existing title.
|
|
128
|
+
|
|
127
129
|
**options.onFinish** (`StreamTextOnFinishCallback<any> | StreamObjectOnFinishCallback<OUTPUT>`): Callback function called when streaming completes. Receives the final result.
|
|
128
130
|
|
|
129
131
|
**options.onStepFinish** (`StreamTextOnStepFinishCallback<any> | never`): Callback function called after each execution step. Receives step details as a JSON string. Unavailable for structured output
|
|
@@ -30,28 +30,28 @@ Install a template using the `create-mastra` command:
|
|
|
30
30
|
**npm**:
|
|
31
31
|
|
|
32
32
|
```sh
|
|
33
|
-
npx create-mastra@latest --template template-name
|
|
33
|
+
npx create-mastra@latest my-project --template template-name
|
|
34
34
|
```
|
|
35
35
|
|
|
36
36
|
**pnpm**:
|
|
37
37
|
|
|
38
38
|
```sh
|
|
39
|
-
pnpm dlx create-mastra@latest --template template-name
|
|
39
|
+
pnpm dlx create-mastra@latest my-project --template template-name
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
**Yarn**:
|
|
43
43
|
|
|
44
44
|
```sh
|
|
45
|
-
yarn dlx create-mastra@latest --template template-name
|
|
45
|
+
yarn dlx create-mastra@latest my-project --template template-name
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
**Bun**:
|
|
49
49
|
|
|
50
50
|
```sh
|
|
51
|
-
bun x create-mastra@latest --template template-name
|
|
51
|
+
bun x create-mastra@latest my-project --template template-name
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
This creates a complete project
|
|
54
|
+
This creates a complete project and installs its dependencies. The template author controls the models, provider dependencies, environment variables, and source code.
|
|
55
55
|
|
|
56
56
|
### Setup Process
|
|
57
57
|
|
|
@@ -71,33 +71,7 @@ After installation:
|
|
|
71
71
|
|
|
72
72
|
Edit `.env` with required API keys as documented in the template's README.
|
|
73
73
|
|
|
74
|
-
3. **
|
|
75
|
-
|
|
76
|
-
**npm**:
|
|
77
|
-
|
|
78
|
-
```sh
|
|
79
|
-
npm install
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
**pnpm**:
|
|
83
|
-
|
|
84
|
-
```sh
|
|
85
|
-
pnpm install
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
**Yarn**:
|
|
89
|
-
|
|
90
|
-
```sh
|
|
91
|
-
yarn install
|
|
92
|
-
```
|
|
93
|
-
|
|
94
|
-
**Bun**:
|
|
95
|
-
|
|
96
|
-
```sh
|
|
97
|
-
bun install
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
4. **Start development server**:
|
|
74
|
+
3. **Start development server**:
|
|
101
75
|
|
|
102
76
|
**npm**:
|
|
103
77
|
|
|
@@ -10,25 +10,29 @@ The `createTool()` function is used to define custom tools that your Mastra agen
|
|
|
10
10
|
import { createTool } from '@mastra/core/tools'
|
|
11
11
|
import { z } from 'zod'
|
|
12
12
|
|
|
13
|
-
export const
|
|
14
|
-
id: '
|
|
15
|
-
description: '
|
|
13
|
+
export const weatherTool = createTool({
|
|
14
|
+
id: 'weather-tool',
|
|
15
|
+
description: 'Get the current weather for a location',
|
|
16
16
|
inputSchema: z.object({
|
|
17
|
-
|
|
17
|
+
location: z.string(),
|
|
18
18
|
}),
|
|
19
19
|
outputSchema: z.object({
|
|
20
|
-
|
|
20
|
+
location: z.string(),
|
|
21
|
+
temperatureCelsius: z.number(),
|
|
22
|
+
conditions: z.string(),
|
|
21
23
|
}),
|
|
22
|
-
execute: async
|
|
23
|
-
const reversed = inputData.input.split('').reverse().join('')
|
|
24
|
-
|
|
24
|
+
execute: async ({ location }) => {
|
|
25
25
|
return {
|
|
26
|
-
|
|
26
|
+
location,
|
|
27
|
+
temperatureCelsius: 21,
|
|
28
|
+
conditions: 'sunny',
|
|
27
29
|
}
|
|
28
30
|
},
|
|
29
31
|
})
|
|
30
32
|
```
|
|
31
33
|
|
|
34
|
+
The first `execute` parameter is the validated value from `inputSchema`. Destructure schema fields directly in the function signature, as shown with `{ location }`. The optional second parameter contains the execution context.
|
|
35
|
+
|
|
32
36
|
## Parameters
|
|
33
37
|
|
|
34
38
|
**id** (`string`): A unique identifier for the tool.
|
|
@@ -112,10 +116,12 @@ export const weatherTool = createTool({
|
|
|
112
116
|
location: z.string(),
|
|
113
117
|
}),
|
|
114
118
|
outputSchema: z.object({
|
|
115
|
-
|
|
119
|
+
location: z.string(),
|
|
120
|
+
temperatureCelsius: z.number(),
|
|
121
|
+
conditions: z.string(),
|
|
116
122
|
}),
|
|
117
|
-
execute: async
|
|
118
|
-
|
|
123
|
+
execute: async ({ location }) => {
|
|
124
|
+
return { location, temperatureCelsius: 21, conditions: 'sunny' }
|
|
119
125
|
},
|
|
120
126
|
})
|
|
121
127
|
```
|
|
@@ -137,11 +143,13 @@ export const weatherTool = createTool({
|
|
|
137
143
|
),
|
|
138
144
|
outputSchema: toStandardJsonSchema(
|
|
139
145
|
v.object({
|
|
140
|
-
|
|
146
|
+
location: v.string(),
|
|
147
|
+
temperatureCelsius: v.number(),
|
|
148
|
+
conditions: v.string(),
|
|
141
149
|
}),
|
|
142
150
|
),
|
|
143
|
-
execute: async
|
|
144
|
-
|
|
151
|
+
execute: async ({ location }) => {
|
|
152
|
+
return { location, temperatureCelsius: 21, conditions: 'sunny' }
|
|
145
153
|
},
|
|
146
154
|
})
|
|
147
155
|
```
|
|
@@ -159,10 +167,12 @@ export const weatherTool = createTool({
|
|
|
159
167
|
location: 'string',
|
|
160
168
|
}),
|
|
161
169
|
outputSchema: type({
|
|
162
|
-
|
|
170
|
+
location: 'string',
|
|
171
|
+
temperatureCelsius: 'number',
|
|
172
|
+
conditions: 'string',
|
|
163
173
|
}),
|
|
164
|
-
execute: async
|
|
165
|
-
|
|
174
|
+
execute: async ({ location }) => {
|
|
175
|
+
return { location, temperatureCelsius: 21, conditions: 'sunny' }
|
|
166
176
|
},
|
|
167
177
|
})
|
|
168
178
|
```
|
|
@@ -176,18 +186,22 @@ import { createTool } from '@mastra/core/tools'
|
|
|
176
186
|
import { z } from 'zod'
|
|
177
187
|
|
|
178
188
|
export const weatherTool = createTool({
|
|
179
|
-
id: '
|
|
180
|
-
description: 'Get weather for a
|
|
189
|
+
id: 'weather-tool',
|
|
190
|
+
description: 'Get the current weather for a location',
|
|
181
191
|
strict: true,
|
|
182
192
|
inputSchema: z.object({
|
|
183
|
-
|
|
184
|
-
|
|
193
|
+
location: z.string(),
|
|
194
|
+
}),
|
|
195
|
+
outputSchema: z.object({
|
|
196
|
+
location: z.string(),
|
|
197
|
+
temperatureCelsius: z.number(),
|
|
198
|
+
conditions: z.string(),
|
|
185
199
|
}),
|
|
186
|
-
execute: async ({
|
|
200
|
+
execute: async ({ location }) => {
|
|
187
201
|
return {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
202
|
+
location,
|
|
203
|
+
temperatureCelsius: 21,
|
|
204
|
+
conditions: 'sunny',
|
|
191
205
|
}
|
|
192
206
|
},
|
|
193
207
|
})
|
|
@@ -204,28 +218,31 @@ import { createTool } from '@mastra/core/tools'
|
|
|
204
218
|
import { z } from 'zod'
|
|
205
219
|
|
|
206
220
|
export const weatherTool = createTool({
|
|
207
|
-
id: '
|
|
208
|
-
description: 'Get weather for a
|
|
221
|
+
id: 'weather-tool',
|
|
222
|
+
description: 'Get the current weather for a location',
|
|
209
223
|
inputSchema: z.object({
|
|
210
|
-
|
|
224
|
+
location: z.string(),
|
|
211
225
|
}),
|
|
212
226
|
outputSchema: z.object({
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
227
|
+
location: z.string(),
|
|
228
|
+
temperatureCelsius: z.number(),
|
|
229
|
+
conditions: z.string(),
|
|
216
230
|
radarImageUrl: z.string().url(),
|
|
217
231
|
}),
|
|
218
|
-
execute: async ({
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
232
|
+
execute: async ({ location }) => ({
|
|
233
|
+
location,
|
|
234
|
+
temperatureCelsius: 21,
|
|
235
|
+
conditions: 'sunny',
|
|
222
236
|
radarImageUrl: 'https://example.com/radar/seattle.png',
|
|
223
237
|
}),
|
|
224
238
|
toModelOutput: output => {
|
|
225
239
|
return {
|
|
226
240
|
type: 'content',
|
|
227
241
|
value: [
|
|
228
|
-
{
|
|
242
|
+
{
|
|
243
|
+
type: 'text',
|
|
244
|
+
text: `${output.location}: ${output.temperatureCelsius}°C and ${output.conditions}`,
|
|
245
|
+
},
|
|
229
246
|
{ type: 'image-url', url: output.radarImageUrl },
|
|
230
247
|
],
|
|
231
248
|
}
|
|
@@ -294,11 +311,16 @@ import { createTool } from '@mastra/core/tools'
|
|
|
294
311
|
import { z } from 'zod'
|
|
295
312
|
|
|
296
313
|
export const weatherTool = createTool({
|
|
297
|
-
id: '
|
|
298
|
-
description: 'Get current weather for a location',
|
|
314
|
+
id: 'weather-tool',
|
|
315
|
+
description: 'Get the current weather for a location',
|
|
299
316
|
inputSchema: z.object({
|
|
300
317
|
location: z.string().describe('City name or coordinates'),
|
|
301
318
|
}),
|
|
319
|
+
outputSchema: z.object({
|
|
320
|
+
location: z.string(),
|
|
321
|
+
temperatureCelsius: z.number(),
|
|
322
|
+
conditions: z.string(),
|
|
323
|
+
}),
|
|
302
324
|
// MCP-specific properties
|
|
303
325
|
mcp: {
|
|
304
326
|
// Annotations for client behavior hints
|
|
@@ -315,9 +337,11 @@ export const weatherTool = createTool({
|
|
|
315
337
|
category: 'weather',
|
|
316
338
|
},
|
|
317
339
|
},
|
|
318
|
-
execute: async
|
|
340
|
+
execute: async ({ location }) => {
|
|
319
341
|
return {
|
|
320
|
-
|
|
342
|
+
location,
|
|
343
|
+
temperatureCelsius: 21,
|
|
344
|
+
conditions: 'sunny',
|
|
321
345
|
}
|
|
322
346
|
},
|
|
323
347
|
})
|
|
@@ -334,19 +358,21 @@ import { createTool } from '@mastra/core/tools'
|
|
|
334
358
|
import { z } from 'zod'
|
|
335
359
|
|
|
336
360
|
export const weatherTool = createTool({
|
|
337
|
-
id: '
|
|
338
|
-
description: 'Get weather for a
|
|
361
|
+
id: 'weather-tool',
|
|
362
|
+
description: 'Get the current weather for a location',
|
|
339
363
|
inputSchema: z.object({
|
|
340
|
-
|
|
364
|
+
location: z.string(),
|
|
341
365
|
}),
|
|
342
366
|
outputSchema: z.object({
|
|
343
|
-
|
|
344
|
-
|
|
367
|
+
location: z.string(),
|
|
368
|
+
temperatureCelsius: z.number(),
|
|
369
|
+
conditions: z.string(),
|
|
345
370
|
}),
|
|
346
|
-
execute: async ({
|
|
371
|
+
execute: async ({ location }) => {
|
|
347
372
|
return {
|
|
348
|
-
|
|
349
|
-
|
|
373
|
+
location,
|
|
374
|
+
temperatureCelsius: 21,
|
|
375
|
+
conditions: 'sunny',
|
|
350
376
|
}
|
|
351
377
|
},
|
|
352
378
|
onInputStart: ({ toolCallId }) => {
|
|
@@ -356,10 +382,10 @@ export const weatherTool = createTool({
|
|
|
356
382
|
console.log(`Tool call ${toolCallId} received input chunk: ${inputTextDelta}`)
|
|
357
383
|
},
|
|
358
384
|
onInputAvailable: ({ input, toolCallId }) => {
|
|
359
|
-
console.log(`Tool call ${toolCallId} received
|
|
385
|
+
console.log(`Tool call ${toolCallId} received location: ${input.location}`)
|
|
360
386
|
},
|
|
361
387
|
onOutput: ({ output, toolCallId, toolName }) => {
|
|
362
|
-
console.log(`Tool ${toolName} call ${toolCallId} returned
|
|
388
|
+
console.log(`Tool ${toolName} call ${toolCallId} returned conditions: ${output.conditions}`)
|
|
363
389
|
},
|
|
364
390
|
})
|
|
365
391
|
```
|
|
@@ -403,7 +429,7 @@ export const tool = createTool({
|
|
|
403
429
|
id: 'example-tool',
|
|
404
430
|
description: 'Example tool with hooks',
|
|
405
431
|
inputSchema: z.object({
|
|
406
|
-
|
|
432
|
+
location: z.string(),
|
|
407
433
|
}),
|
|
408
434
|
onInputAvailable: ({ input, toolCallId, messages, abortSignal }) => {
|
|
409
435
|
console.log(`Tool received complete input:`, input)
|
|
@@ -280,9 +280,7 @@ This is useful for connecting external MCP servers that implement the MCP Apps e
|
|
|
280
280
|
The `MCPClient` instance has a `resources` property that provides access to resource-related operations.
|
|
281
281
|
|
|
282
282
|
```typescript
|
|
283
|
-
const mcpClient = new MCPClient({
|
|
284
|
-
/* ...servers configuration... */
|
|
285
|
-
})
|
|
283
|
+
const mcpClient = new MCPClient({/* ...servers configuration... */})
|
|
286
284
|
|
|
287
285
|
// Access resource methods via mcpClient.resources
|
|
288
286
|
const allResourcesByServer = await mcpClient.resources.list()
|
|
@@ -411,9 +409,7 @@ mcpClient.resources.onListChanged('myWeatherServer', () => {
|
|
|
411
409
|
The `MCPClient` instance has an `elicitation` property that provides access to elicitation-related operations. Elicitation allows MCP servers to request structured information from users.
|
|
412
410
|
|
|
413
411
|
```typescript
|
|
414
|
-
const mcpClient = new MCPClient({
|
|
415
|
-
/* ...servers configuration... */
|
|
416
|
-
})
|
|
412
|
+
const mcpClient = new MCPClient({/* ...servers configuration... */})
|
|
417
413
|
|
|
418
414
|
// Set up elicitation handler
|
|
419
415
|
mcpClient.elicitation.onRequest('serverName', async request => {
|
|
@@ -552,9 +548,7 @@ await mcpClient.elicitation.onRequest('interactiveServer', async request => {
|
|
|
552
548
|
The `MCPClient` instance has a `prompts` property that provides access to prompt-related operations.
|
|
553
549
|
|
|
554
550
|
```typescript
|
|
555
|
-
const mcpClient = new MCPClient({
|
|
556
|
-
/* ...servers configuration... */
|
|
557
|
-
})
|
|
551
|
+
const mcpClient = new MCPClient({/* ...servers configuration... */})
|
|
558
552
|
|
|
559
553
|
// Access prompt methods via mcpClient.prompts
|
|
560
554
|
const allPromptsByServer = await mcpClient.prompts.list()
|
|
@@ -980,9 +974,7 @@ class DatabaseOAuthStorage implements OAuthStorage {
|
|
|
980
974
|
|
|
981
975
|
const provider = new MCPOAuthClientProvider({
|
|
982
976
|
redirectUrl: 'http://localhost:3000/callback',
|
|
983
|
-
clientMetadata: {
|
|
984
|
-
/* ... */
|
|
985
|
-
},
|
|
977
|
+
clientMetadata: {/* ... */},
|
|
986
978
|
storage: new DatabaseOAuthStorage(db, 'user-123'),
|
|
987
979
|
})
|
|
988
980
|
```
|
|
@@ -1117,33 +1109,25 @@ For example, if you try to create multiple instances with the same configuration
|
|
|
1117
1109
|
```typescript
|
|
1118
1110
|
// First instance - OK
|
|
1119
1111
|
const mcp1 = new MCPClient({
|
|
1120
|
-
servers: {
|
|
1121
|
-
/* ... */
|
|
1122
|
-
},
|
|
1112
|
+
servers: {/* ... */},
|
|
1123
1113
|
})
|
|
1124
1114
|
|
|
1125
1115
|
// Second instance with same config - Will throw an error
|
|
1126
1116
|
const mcp2 = new MCPClient({
|
|
1127
|
-
servers: {
|
|
1128
|
-
/* ... */
|
|
1129
|
-
},
|
|
1117
|
+
servers: {/* ... */},
|
|
1130
1118
|
})
|
|
1131
1119
|
|
|
1132
1120
|
// To fix, either:
|
|
1133
1121
|
// 1. Add unique IDs
|
|
1134
1122
|
const mcp3 = new MCPClient({
|
|
1135
1123
|
id: 'instance-1',
|
|
1136
|
-
servers: {
|
|
1137
|
-
/* ... */
|
|
1138
|
-
},
|
|
1124
|
+
servers: {/* ... */},
|
|
1139
1125
|
})
|
|
1140
1126
|
|
|
1141
1127
|
// 2. Or disconnect before recreating
|
|
1142
1128
|
await mcp1.disconnect()
|
|
1143
1129
|
const mcp4 = new MCPClient({
|
|
1144
|
-
servers: {
|
|
1145
|
-
/* ... */
|
|
1146
|
-
},
|
|
1130
|
+
servers: {/* ... */},
|
|
1147
1131
|
})
|
|
1148
1132
|
```
|
|
1149
1133
|
|