@mastra/mcp-docs-server 0.13.10 → 0.13.11-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
  2. package/.docs/organized/changelogs/%40internal%2Ftypes-builder.md +2 -0
  3. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +26 -26
  4. package/.docs/organized/changelogs/%40mastra%2Fcore.md +30 -30
  5. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +20 -20
  6. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +20 -20
  7. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +20 -20
  8. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +30 -30
  9. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +13 -13
  10. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +9 -9
  11. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +26 -26
  12. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +21 -21
  13. package/.docs/organized/changelogs/%40mastra%2Fpg.md +9 -9
  14. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +21 -21
  15. package/.docs/organized/changelogs/%40mastra%2Frag.md +12 -12
  16. package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +7 -0
  17. package/.docs/organized/changelogs/%40mastra%2Fserver.md +26 -26
  18. package/.docs/organized/changelogs/create-mastra.md +11 -11
  19. package/.docs/organized/changelogs/mastra.md +31 -31
  20. package/.docs/organized/code-examples/agent-network.md +4 -3
  21. package/.docs/organized/code-examples/agent.md +33 -2
  22. package/.docs/raw/agents/overview.mdx +21 -1
  23. package/.docs/raw/getting-started/mcp-docs-server.mdx +2 -2
  24. package/.docs/raw/rag/chunking-and-embedding.mdx +11 -0
  25. package/.docs/raw/reference/agents/agent.mdx +64 -38
  26. package/.docs/raw/reference/agents/generate.mdx +206 -202
  27. package/.docs/raw/reference/agents/getAgent.mdx +23 -38
  28. package/.docs/raw/reference/agents/getDefaultGenerateOptions.mdx +62 -0
  29. package/.docs/raw/reference/agents/getDefaultStreamOptions.mdx +62 -0
  30. package/.docs/raw/reference/agents/getDefaultVNextStreamOptions.mdx +62 -0
  31. package/.docs/raw/reference/agents/getDescription.mdx +30 -0
  32. package/.docs/raw/reference/agents/getInstructions.mdx +36 -73
  33. package/.docs/raw/reference/agents/getLLM.mdx +69 -0
  34. package/.docs/raw/reference/agents/getMemory.mdx +42 -119
  35. package/.docs/raw/reference/agents/getModel.mdx +36 -75
  36. package/.docs/raw/reference/agents/getScorers.mdx +62 -0
  37. package/.docs/raw/reference/agents/getTools.mdx +36 -128
  38. package/.docs/raw/reference/agents/getVoice.mdx +36 -83
  39. package/.docs/raw/reference/agents/getWorkflows.mdx +37 -74
  40. package/.docs/raw/reference/agents/stream.mdx +263 -226
  41. package/.docs/raw/reference/agents/streamVNext.mdx +208 -402
  42. package/.docs/raw/reference/cli/build.mdx +1 -0
  43. package/.docs/raw/reference/rag/chunk.mdx +51 -2
  44. package/.docs/raw/reference/scorers/answer-relevancy.mdx +6 -6
  45. package/.docs/raw/reference/scorers/bias.mdx +6 -6
  46. package/.docs/raw/reference/scorers/completeness.mdx +2 -2
  47. package/.docs/raw/reference/scorers/content-similarity.mdx +1 -1
  48. package/.docs/raw/reference/scorers/create-scorer.mdx +445 -0
  49. package/.docs/raw/reference/scorers/faithfulness.mdx +6 -6
  50. package/.docs/raw/reference/scorers/hallucination.mdx +6 -6
  51. package/.docs/raw/reference/scorers/keyword-coverage.mdx +2 -2
  52. package/.docs/raw/reference/scorers/mastra-scorer.mdx +116 -158
  53. package/.docs/raw/reference/scorers/toxicity.mdx +2 -2
  54. package/.docs/raw/scorers/custom-scorers.mdx +166 -268
  55. package/.docs/raw/scorers/overview.mdx +21 -13
  56. package/.docs/raw/server-db/local-dev-playground.mdx +3 -3
  57. package/package.json +5 -5
  58. package/.docs/raw/reference/agents/createTool.mdx +0 -241
  59. package/.docs/raw/reference/scorers/custom-code-scorer.mdx +0 -155
  60. package/.docs/raw/reference/scorers/llm-scorer.mdx +0 -210
@@ -43,14 +43,14 @@ This function returns an instance of the MastraScorer class. The `.run()` method
43
43
  description: "The id of the run (optional).",
44
44
  },
45
45
  {
46
- name: "extractStepResult",
46
+ name: "preprocessStepResult",
47
47
  type: "object",
48
48
  description: "Object with extracted claims: { claims: string[] }",
49
49
  },
50
50
  {
51
- name: "extractPrompt",
51
+ name: "preprocessPrompt",
52
52
  type: "string",
53
- description: "The prompt sent to the LLM for the extract step (optional).",
53
+ description: "The prompt sent to the LLM for the preprocess step (optional).",
54
54
  },
55
55
  {
56
56
  name: "analyzeStepResult",
@@ -73,9 +73,9 @@ This function returns an instance of the MastraScorer class. The `.run()` method
73
73
  description: "Detailed explanation of the score and identified contradictions.",
74
74
  },
75
75
  {
76
- name: "reasonPrompt",
76
+ name: "generateReasonPrompt",
77
77
  type: "string",
78
- description: "The prompt sent to the LLM for the reason step (optional).",
78
+ description: "The prompt sent to the LLM for the generateReason step (optional).",
79
79
  },
80
80
  ]}
81
81
  />
@@ -130,4 +130,4 @@ Final score: `(hallucinated_statements / total_statements) * scale`
130
130
  ## Related
131
131
 
132
132
  - [Faithfulness Scorer](./faithfulness)
133
- - [Answer Relevancy Scorer](./answer-relevancy)
133
+ - [Answer Relevancy Scorer](./answer-relevancy)
@@ -25,7 +25,7 @@ This function returns an instance of the MastraScorer class. See the [MastraScor
25
25
  description: "The id of the run (optional).",
26
26
  },
27
27
  {
28
- name: "extractStepResult",
28
+ name: "preprocessStepResult",
29
29
  type: "object",
30
30
  description: "Object with extracted keywords: { referenceKeywords: Set<string>, responseKeywords: Set<string> }",
31
31
  },
@@ -89,4 +89,4 @@ The scorer handles several special cases:
89
89
  - [Completeness Scorer](./completeness)
90
90
  - [Content Similarity Scorer](./content-similarity)
91
91
  - [Answer Relevancy Scorer](./answer-relevancy)
92
- - [Textual Difference Scorer](./textual-difference)
92
+ - [Textual Difference Scorer](./textual-difference)
@@ -5,178 +5,67 @@ description: Documentation for the MastraScorer base class in Mastra, which prov
5
5
 
6
6
  # MastraScorer
7
7
 
8
- The `MastraScorer` class is the base class for all scorers in Mastra. It provides a standard `.run()` method for evaluating input/output pairs and supports multi-step scoring workflows. Most users will use `createScorer` or `createLLMScorer`, but advanced users can subclass or instantiate `MastraScorer` directly for full control.
8
+ The `MastraScorer` class is the base class for all scorers in Mastra. It provides a standard `.run()` method for evaluating input/output pairs and supports multi-step scoring workflows with preprocess analyze generateScore generateReason execution flow.
9
9
 
10
- ## Constructor Options
10
+ **Note:** Most users should use [`createScorer`](./create-scorer) to create scorer instances. Direct instantiation of `MastraScorer` is not recommended.
11
11
 
12
- <PropertiesTable
13
- content={[
14
- {
15
- name: "name",
16
- type: "string",
17
- required: true,
18
- description: "Name of the scorer.",
19
- },
20
- {
21
- name: "description",
22
- type: "string",
23
- required: true,
24
- description: "Description of what the scorer does.",
25
- },
26
- {
27
- name: "extract",
28
- type: "function",
29
- required: false,
30
- description: "Optional extraction step. See extract step signature below.",
31
- },
32
- {
33
- name: "analyze",
34
- type: "function",
35
- required: true,
36
- description: "Main scoring logic. See analyze step signature below.",
37
- },
38
- {
39
- name: "reason",
40
- type: "function",
41
- required: false,
42
- description: "Optional reason/explanation step. See reason step signature below.",
43
- },
44
- {
45
- name: "metadata",
46
- type: "object",
47
- required: false,
48
- description: "Optional metadata for the scorer.",
49
- },
50
- {
51
- name: "isLLMScorer",
52
- type: "boolean",
53
- required: false,
54
- description: "(Internal) Used to distinguish LLM scorers.",
55
- },
56
- ]}
57
- />
12
+ ## How to Get a MastraScorer Instance
58
13
 
59
- ## Step Function Signatures
14
+ Use the `createScorer` factory function, which returns a `MastraScorer` instance:
60
15
 
61
- ### extract
62
- <PropertiesTable
63
- content={[
64
- {
65
- name: "input",
66
- type: "Record<string, any>[]",
67
- required: false,
68
- description: "Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
69
- },
70
- {
71
- name: "output",
72
- type: "Record<string, any>",
73
- required: true,
74
- description: "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
75
- },
76
- ]}
77
- />
78
- Returns: `{ results: any }`
79
- The method must return an object with a `results` property. The value of `results` will be passed to the analyze function as `extractStepResult`.
16
+ ```typescript
17
+ const scorer = createScorer({
18
+ name: "My Custom Scorer",
19
+ description: "Evaluates responses based on custom criteria"
20
+ })
21
+ .generateScore(({ run, results }) => {
22
+ // scoring logic
23
+ return 0.85;
24
+ });
80
25
 
81
- ### analyze
82
- <PropertiesTable
83
- content={[
84
- {
85
- name: "input",
86
- type: "Record<string, any>[]",
87
- required: true,
88
- description: "Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
89
- },
90
- {
91
- name: "output",
92
- type: "Record<string, any>",
93
- required: true,
94
- description: "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
95
- },
96
- {
97
- name: "extractStepResult",
98
- type: "object",
99
- required: false,
100
- description: "Result of the extract step, if defined (optional).",
101
- },
102
- ]}
103
- />
104
- Returns: `{ score: number, results?: any }`
105
- The method must return an object with a `score` property (required). Optionally, it may return a `results` property. The value of `results` will be passed to the reason function as `analyzeStepResult`.
26
+ // scorer is now a MastraScorer instance
27
+ ```
106
28
 
107
- ### reason
108
- <PropertiesTable
109
- content={[
110
- {
111
- name: "input",
112
- type: "Record<string, any>[]",
113
- required: true,
114
- description: "Input records provided to the scorer. If the scorer is added to an agent, this will be an array of user messages, e.g. `[{ role: 'user', content: 'hello world' }]`. If the scorer is used in a workflow, this will be the input of the workflow.",
115
- },
116
- {
117
- name: "output",
118
- type: "Record<string, any>",
119
- required: true,
120
- description: "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
121
- },
122
- {
123
- name: "score",
124
- type: "number",
125
- required: true,
126
- description: "Score computed by the analyze step.",
127
- },
128
- {
129
- name: "analyzeStepResult",
130
- type: "object",
131
- required: true,
132
- description: "Result of the analyze step.",
133
- },
134
- {
135
- name: "extractStepResult",
136
- type: "object",
137
- required: false,
138
- description: "Result of the extract step, if defined (optional).",
139
- },
140
- ]}
141
- />
142
- Returns: `{ reason: string }`
143
- The method must return an object with a `reason` property, which should be a string explaining the score.
29
+ ## .run() Method
30
+
31
+ The `.run()` method is the primary way to execute your scorer and evaluate input/output pairs. It processes the data through your defined steps (preprocess → analyze → generateScore → generateReason) and returns a comprehensive result object with the score, reasoning, and intermediate results.
144
32
 
145
- All step functions can be async.
33
+ ```typescript
34
+ const result = await scorer.run({
35
+ input: "What is machine learning?",
36
+ output: "Machine learning is a subset of artificial intelligence...",
37
+ runId: "optional-run-id",
38
+ runtimeContext: { /* optional context */ }
39
+ });
40
+ ```
146
41
 
147
42
  ## .run() Input
148
43
 
149
44
  <PropertiesTable
150
45
  content={[
151
- {
152
- name: "runId",
153
- type: "string",
154
- required: false,
155
- description: "The id of the run (optional).",
156
- },
157
46
  {
158
47
  name: "input",
159
- type: "Record<string, any>[]",
48
+ type: "any",
160
49
  required: true,
161
- description: "An array of records. This should contain user messages or the data to be evaluated.",
50
+ description: "Input data to be evaluated. Can be any type depending on your scorer's requirements.",
162
51
  },
163
52
  {
164
53
  name: "output",
165
- type: "Record<string, any>",
54
+ type: "any",
166
55
  required: true,
167
- description: "A record. This should contain the output to be evaluated.",
56
+ description: "Output data to be evaluated. Can be any type depending on your scorer's requirements.",
168
57
  },
169
58
  {
170
- name: "additionalContext",
171
- type: "Record<string, any>",
59
+ name: "runId",
60
+ type: "string",
172
61
  required: false,
173
- description: "Additional context for the run (optional).",
62
+ description: "Optional unique identifier for this scoring run.",
174
63
  },
175
64
  {
176
65
  name: "runtimeContext",
177
- type: "Record<string, any>",
66
+ type: "any",
178
67
  required: false,
179
- description: "Runtime context for the run (optional).",
68
+ description: "Optional runtime context from the agent or workflow step being evaluated.",
180
69
  },
181
70
  ]}
182
71
  />
@@ -188,31 +77,100 @@ All step functions can be async.
188
77
  {
189
78
  name: "runId",
190
79
  type: "string",
191
- description: "The id of the run (optional).",
80
+ description: "The unique identifier for this scoring run.",
81
+ },
82
+ {
83
+ name: "score",
84
+ type: "number",
85
+ description: "Numerical score computed by the generateScore step.",
86
+ },
87
+ {
88
+ name: "reason",
89
+ type: "string",
90
+ description: "Explanation for the score, if generateReason step was defined (optional).",
192
91
  },
193
92
  {
194
- name: "extractStepResult",
195
- type: "object",
196
- description: "Result of the extract step, if defined (optional).",
93
+ name: "preprocessStepResult",
94
+ type: "any",
95
+ description: "Result of the preprocess step, if defined (optional).",
197
96
  },
198
97
  {
199
98
  name: "analyzeStepResult",
200
- type: "object",
201
- description: "Result of the analyze step (custom structure defined by your scorer).",
99
+ type: "any",
100
+ description: "Result of the analyze step, if defined (optional).",
202
101
  },
203
102
  {
204
- name: "score",
205
- type: "number",
206
- description: "Score computed by your analyze function.",
103
+ name: "preprocessPrompt",
104
+ type: "string",
105
+ description: "Preprocess prompt, if defined (optional).",
207
106
  },
208
107
  {
209
- name: "reason",
108
+ name: "analyzePrompt",
210
109
  type: "string",
211
- description: "Reason/explanation for the score, if defined (optional).",
110
+ description: "Analyze prompt, if defined (optional).",
111
+ },
112
+ {
113
+ name: "generateScorePrompt",
114
+ type: "string",
115
+ description: "Generate score prompt, if defined (optional).",
116
+ },
117
+ {
118
+ name: "generateReasonPrompt",
119
+ type: "string",
120
+ description: "Generate reason prompt, if defined (optional).",
212
121
  },
213
122
  ]}
214
123
  />
215
124
 
125
+ ## Step Execution Flow
126
+
127
+ When you call `.run()`, the MastraScorer executes the defined steps in this order:
128
+
129
+ 1. **preprocess** (optional) - Extracts or transforms data
130
+ 2. **analyze** (optional) - Processes the input/output and preprocessed data
131
+ 3. **generateScore** (required) - Computes the numerical score
132
+ 4. **generateReason** (optional) - Provides explanation for the score
133
+
134
+ Each step receives the results from previous steps, allowing you to build complex evaluation pipelines.
135
+
136
+ ## Usage Example
137
+
138
+ ```typescript
139
+ const scorer = createScorer({
140
+ name: "Quality Scorer",
141
+ description: "Evaluates response quality"
142
+ })
143
+ .preprocess(({ run }) => {
144
+ // Extract key information
145
+ return { wordCount: run.output.split(' ').length };
146
+ })
147
+ .analyze(({ run, results }) => {
148
+ // Analyze the response
149
+ const hasSubstance = results.preprocessStepResult.wordCount > 10;
150
+ return { hasSubstance };
151
+ })
152
+ .generateScore(({ results }) => {
153
+ // Calculate score
154
+ return results.analyzeStepResult.hasSubstance ? 1.0 : 0.0;
155
+ })
156
+ .generateReason(({ score, results }) => {
157
+ // Explain the score
158
+ const wordCount = results.preprocessStepResult.wordCount;
159
+ return `Score: ${score}. Response has ${wordCount} words.`;
160
+ });
161
+
162
+ // Use the scorer
163
+ const result = await scorer.run({
164
+ input: "What is machine learning?",
165
+ output: "Machine learning is a subset of artificial intelligence..."
166
+ });
167
+
168
+ console.log(result.score); // 1.0
169
+ console.log(result.reason); // "Score: 1.0. Response has 12 words."
170
+ ```
171
+
216
172
  ## Integration
217
173
 
218
- MastraScorer instances can be used for agents and workflow steps
174
+ MastraScorer instances can be used for agents and workflow steps
175
+
176
+ See the [createScorer reference](./create-scorer) for detailed information on defining custom scoring logic.
@@ -63,9 +63,9 @@ This function returns an instance of the MastraScorer class. The `.run()` method
63
63
  description: "Detailed explanation of the toxicity assessment.",
64
64
  },
65
65
  {
66
- name: "reasonPrompt",
66
+ name: "generateReasonPrompt",
67
67
  type: "string",
68
- description: "The prompt sent to the LLM for the reason step (optional).",
68
+ description: "The prompt sent to the LLM for the generateReason step (optional).",
69
69
  },
70
70
  ]}
71
71
  />