@mastra/mcp-docs-server 0.13.6 → 0.13.7-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 (115) hide show
  1. package/.docs/organized/changelogs/%40internal%2Fstorage-test-utils.md +9 -9
  2. package/.docs/organized/changelogs/%40mastra%2Fastra.md +8 -8
  3. package/.docs/organized/changelogs/%40mastra%2Fchroma.md +8 -8
  4. package/.docs/organized/changelogs/%40mastra%2Fclickhouse.md +8 -8
  5. package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +35 -35
  6. package/.docs/organized/changelogs/%40mastra%2Fcloud.md +8 -8
  7. package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +25 -25
  8. package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +8 -8
  9. package/.docs/organized/changelogs/%40mastra%2Fcore.md +30 -30
  10. package/.docs/organized/changelogs/%40mastra%2Fcouchbase.md +8 -8
  11. package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +30 -30
  12. package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +28 -28
  13. package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +28 -28
  14. package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +45 -45
  15. package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +26 -26
  16. package/.docs/organized/changelogs/%40mastra%2Fevals.md +35 -35
  17. package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +29 -29
  18. package/.docs/organized/changelogs/%40mastra%2Fgithub.md +8 -8
  19. package/.docs/organized/changelogs/%40mastra%2Flance.md +7 -0
  20. package/.docs/organized/changelogs/%40mastra%2Flibsql.md +28 -28
  21. package/.docs/organized/changelogs/%40mastra%2Floggers.md +8 -8
  22. package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +35 -35
  23. package/.docs/organized/changelogs/%40mastra%2Fmcp-registry-registry.md +8 -8
  24. package/.docs/organized/changelogs/%40mastra%2Fmcp.md +9 -9
  25. package/.docs/organized/changelogs/%40mastra%2Fmem0.md +26 -26
  26. package/.docs/organized/changelogs/%40mastra%2Fmemory.md +37 -37
  27. package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +26 -26
  28. package/.docs/organized/changelogs/%40mastra%2Fmssql.md +7 -0
  29. package/.docs/organized/changelogs/%40mastra%2Fopensearch.md +8 -8
  30. package/.docs/organized/changelogs/%40mastra%2Fpg.md +8 -8
  31. package/.docs/organized/changelogs/%40mastra%2Fpinecone.md +8 -8
  32. package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +43 -43
  33. package/.docs/organized/changelogs/%40mastra%2Fqdrant.md +8 -8
  34. package/.docs/organized/changelogs/%40mastra%2Frag.md +27 -27
  35. package/.docs/organized/changelogs/%40mastra%2Fragie.md +8 -8
  36. package/.docs/organized/changelogs/%40mastra%2Fserver.md +34 -34
  37. package/.docs/organized/changelogs/%40mastra%2Fturbopuffer.md +8 -8
  38. package/.docs/organized/changelogs/%40mastra%2Fupstash.md +26 -26
  39. package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
  40. package/.docs/organized/changelogs/%40mastra%2Fvoice-azure.md +26 -26
  41. package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
  42. package/.docs/organized/changelogs/%40mastra%2Fvoice-deepgram.md +8 -8
  43. package/.docs/organized/changelogs/%40mastra%2Fvoice-elevenlabs.md +8 -8
  44. package/.docs/organized/changelogs/%40mastra%2Fvoice-google.md +8 -8
  45. package/.docs/organized/changelogs/%40mastra%2Fvoice-murf.md +8 -8
  46. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai-realtime.md +28 -28
  47. package/.docs/organized/changelogs/%40mastra%2Fvoice-openai.md +26 -26
  48. package/.docs/organized/changelogs/%40mastra%2Fvoice-playai.md +8 -8
  49. package/.docs/organized/changelogs/%40mastra%2Fvoice-sarvam.md +8 -8
  50. package/.docs/organized/changelogs/%40mastra%2Fvoice-speechify.md +8 -8
  51. package/.docs/organized/changelogs/create-mastra.md +15 -15
  52. package/.docs/organized/changelogs/mastra.md +43 -43
  53. package/.docs/organized/code-examples/a2a.md +1 -1
  54. package/.docs/organized/code-examples/agui.md +2 -2
  55. package/.docs/organized/code-examples/ai-sdk-useChat.md +1 -1
  56. package/.docs/organized/code-examples/ai-sdk-v5.md +1 -1
  57. package/.docs/organized/code-examples/assistant-ui.md +1 -1
  58. package/.docs/organized/code-examples/bird-checker-with-express.md +1 -1
  59. package/.docs/organized/code-examples/bird-checker-with-nextjs-and-eval.md +1 -1
  60. package/.docs/organized/code-examples/bird-checker-with-nextjs.md +1 -1
  61. package/.docs/organized/code-examples/client-side-tools.md +2 -2
  62. package/.docs/organized/code-examples/crypto-chatbot.md +1 -1
  63. package/.docs/organized/code-examples/fireworks-r1.md +1 -1
  64. package/.docs/organized/code-examples/memory-with-mem0.md +1 -1
  65. package/.docs/organized/code-examples/memory-with-pg.md +1 -0
  66. package/.docs/organized/code-examples/openapi-spec-writer.md +1 -1
  67. package/.docs/organized/code-examples/quick-start.md +1 -1
  68. package/.docs/organized/code-examples/workflow-ai-recruiter.md +1 -1
  69. package/.docs/organized/code-examples/workflow-with-inline-steps.md +1 -1
  70. package/.docs/organized/code-examples/workflow-with-memory.md +1 -1
  71. package/.docs/organized/code-examples/workflow-with-separate-steps.md +1 -1
  72. package/.docs/organized/code-examples/workflow-with-suspend-resume.md +1 -1
  73. package/.docs/raw/agents/runtime-variables.mdx +1 -1
  74. package/.docs/raw/auth/index.mdx +24 -0
  75. package/.docs/raw/auth/jwt.mdx +99 -0
  76. package/.docs/raw/community/contributing-templates.mdx +192 -0
  77. package/.docs/raw/deployment/cloud-providers/azure-app-services.mdx +6 -5
  78. package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +84 -14
  79. package/.docs/raw/evals/custom-eval.mdx +12 -12
  80. package/.docs/raw/getting-started/installation.mdx +16 -0
  81. package/.docs/raw/getting-started/templates.mdx +95 -0
  82. package/.docs/raw/index.mdx +2 -2
  83. package/.docs/raw/reference/agents/generate.mdx +18 -1
  84. package/.docs/raw/reference/agents/stream.mdx +18 -1
  85. package/.docs/raw/reference/auth/jwt.mdx +42 -0
  86. package/.docs/raw/reference/client-js/agents.mdx +3 -11
  87. package/.docs/raw/reference/client-js/error-handling.mdx +1 -21
  88. package/.docs/raw/reference/client-js/logs.mdx +2 -10
  89. package/.docs/raw/reference/client-js/mastra-client.mdx +141 -0
  90. package/.docs/raw/reference/client-js/memory.mdx +6 -18
  91. package/.docs/raw/reference/client-js/telemetry.mdx +1 -9
  92. package/.docs/raw/reference/client-js/tools.mdx +2 -10
  93. package/.docs/raw/reference/client-js/vectors.mdx +1 -9
  94. package/.docs/raw/reference/client-js/workflows-legacy.mdx +3 -11
  95. package/.docs/raw/reference/client-js/workflows.mdx +5 -13
  96. package/.docs/raw/reference/core/mastra-class.mdx +7 -1
  97. package/.docs/raw/reference/observability/providers/dash0.mdx +2 -2
  98. package/.docs/raw/reference/scorers/answer-relevancy.mdx +115 -0
  99. package/.docs/raw/reference/scorers/bias.mdx +127 -0
  100. package/.docs/raw/reference/scorers/completeness.mdx +89 -0
  101. package/.docs/raw/reference/scorers/content-similarity.mdx +96 -0
  102. package/.docs/raw/reference/scorers/custom-code-scorer.mdx +155 -0
  103. package/.docs/raw/reference/scorers/faithfulness.mdx +123 -0
  104. package/.docs/raw/reference/scorers/hallucination.mdx +135 -0
  105. package/.docs/raw/reference/scorers/keyword-coverage.mdx +92 -0
  106. package/.docs/raw/reference/scorers/llm-scorer.mdx +166 -0
  107. package/.docs/raw/reference/scorers/mastra-scorer.mdx +218 -0
  108. package/.docs/raw/reference/scorers/textual-difference.mdx +76 -0
  109. package/.docs/raw/reference/scorers/tone-consistency.mdx +75 -0
  110. package/.docs/raw/reference/scorers/toxicity.mdx +109 -0
  111. package/.docs/raw/reference/templates.mdx +222 -0
  112. package/.docs/raw/reference/tools/vector-query-tool.mdx +29 -0
  113. package/.docs/raw/tools-mcp/overview.mdx +1 -1
  114. package/package.json +6 -6
  115. package/.docs/organized/changelogs/%40mastra%2Fagui.md +0 -302
@@ -7,20 +7,12 @@ description: Learn how to interact with and execute automated workflows in Mastr
7
7
 
8
8
  The Workflows API provides methods to interact with and execute automated workflows in Mastra.
9
9
 
10
- ## Initialize Mastra Client
11
-
12
- ```typescript
13
- import { MastraClient } from "@mastra/client-js";
14
-
15
- const client = new MastraClient();
16
- ```
17
-
18
10
  ## Getting All Workflows
19
11
 
20
12
  Retrieve a list of all available workflows:
21
13
 
22
14
  ```typescript
23
- const workflows = await client.getWorkflows();
15
+ const workflows = await mastraClient.getWorkflows();
24
16
  ```
25
17
 
26
18
  ## Working with a Specific Workflow
@@ -34,7 +26,7 @@ export const testWorkflow = createWorkflow({
34
26
  ```
35
27
 
36
28
  ```typescript
37
- const workflow = client.getWorkflow("testWorkflow");
29
+ const workflow = mastraClient.getWorkflow("testWorkflow");
38
30
  ```
39
31
 
40
32
  ## Workflow Methods
@@ -82,7 +74,7 @@ Watch workflow transitions:
82
74
 
83
75
  ```typescript
84
76
  try {
85
- const workflow = client.getWorkflow("testWorkflow");
77
+ const workflow = mastraClient.getWorkflow("testWorkflow");
86
78
 
87
79
  const run = await workflow.createRun();
88
80
 
@@ -107,7 +99,7 @@ Resume workflow run and watch workflow step transitions:
107
99
 
108
100
  ```typescript
109
101
  try {
110
- const workflow = client.getWorkflow("testWorkflow");
102
+ const workflow = mastraClient.getWorkflow("testWorkflow");
111
103
 
112
104
  const run = await workflow.createRun({ runId: prevRunId });
113
105
 
@@ -131,7 +123,7 @@ Get the result of a workflow run:
131
123
 
132
124
  ```typescript
133
125
  try {
134
- const workflow = client.getWorkflow("testWorkflow");
126
+ const workflow = mastraClient.getWorkflow("testWorkflow");
135
127
 
136
128
  const run = await workflow.createRun();
137
129
 
@@ -87,6 +87,12 @@ The constructor accepts an optional `Config` object to customize its behavior an
87
87
  isOptional: true,
88
88
  defaultValue: "Console logger with INFO level",
89
89
  },
90
+ {
91
+ name: "idGenerator",
92
+ type: "() => string",
93
+ description: "Custom ID generator function. Used by agents, workflows, memory, and other components to generate unique identifiers.",
94
+ isOptional: true,
95
+ },
90
96
  {
91
97
  name: "workflows",
92
98
  type: "Record<string, Workflow>",
@@ -120,7 +126,7 @@ The constructor accepts an optional `Config` object to customize its behavior an
120
126
  "Server configuration including port, host, timeout, API routes, middleware, CORS settings, and build options for Swagger UI, API request logging, and OpenAPI docs.",
121
127
  isOptional: true,
122
128
  defaultValue:
123
- "{ port: 4111, host: localhost, cors: { origin: '*', allowMethods: ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS'], allowHeaders: ['Content-Type', 'Authorization', 'x-mastra-client-type'], exposeHeaders: ['Content-Length', 'X-Requested-With'], credentials: false } }",
129
+ "{ port: 4111, host: localhost, cors: { origin: '*', allowMethods: ['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], allowHeaders: ['Content-Type', 'Authorization', 'x-mastra-client-type'], exposeHeaders: ['Content-Length', 'X-Requested-With'], credentials: false } }",
124
130
  },
125
131
  {
126
132
  name: "mcpServers",
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  title: "Reference: Dash0 Integration | Mastra Observability Docs"
3
- description: Documentation for integrating Mastra with Dash0, an Open Telementry native observability solution.
3
+ description: Documentation for integrating Mastra with Dash0, an Open Telemetry native observability solution.
4
4
  ---
5
5
 
6
6
  # Dash0
7
7
 
8
- Dash0, an Open Telementry native observability solution that provides full-stack monitoring capabilities as well as integrations with other CNCF projects like Perses and Prometheus.
8
+ Dash0, an Open Telemetry native observability solution that provides full-stack monitoring capabilities as well as integrations with other CNCF projects like Perses and Prometheus.
9
9
 
10
10
  ## Configuration
11
11
 
@@ -0,0 +1,115 @@
1
+ ---
2
+ title: "Reference: Answer Relevancy | Scorers | Mastra Docs"
3
+ description: Documentation for the Answer Relevancy Scorer in Mastra, which evaluates how well LLM outputs address the input query.
4
+ ---
5
+
6
+ # Answer Relevancy Scorer
7
+
8
+ The `createAnswerRelevancyScorer()` function accepts a single options object with the following properties:
9
+
10
+ For usage example, see the [Answer Relevancy Examples](/examples/scorers/answer-relevancy).
11
+
12
+ ## Parameters
13
+
14
+ <PropertiesTable
15
+ content={[
16
+ {
17
+ name: "model",
18
+ type: "LanguageModel",
19
+ required: true,
20
+ description: "Configuration for the model used to evaluate relevancy.",
21
+ },
22
+ {
23
+ name: "uncertaintyWeight",
24
+ type: "number",
25
+ required: false,
26
+ defaultValue: "0.3",
27
+ description: "Weight given to 'unsure' verdicts in scoring (0-1).",
28
+ },
29
+ {
30
+ name: "scale",
31
+ type: "number",
32
+ required: false,
33
+ defaultValue: "1",
34
+ description: "Maximum score value.",
35
+ },
36
+ ]}
37
+ />
38
+
39
+ This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](./mastra-scorer)), but the return value includes LLM-specific fields as documented below.
40
+
41
+ ## .run() Returns
42
+
43
+ <PropertiesTable
44
+ content={[
45
+ {
46
+ name: "runId",
47
+ type: "string",
48
+ description: "The id of the run (optional).",
49
+ },
50
+ {
51
+ name: "score",
52
+ type: "number",
53
+ description: "Relevancy score (0 to scale, default 0-1)",
54
+ },
55
+ {
56
+ name: "extractPrompt",
57
+ type: "string",
58
+ description: "The prompt sent to the LLM for the extract step (optional).",
59
+ },
60
+ {
61
+ name: "extractStepResult",
62
+ type: "object",
63
+ description: "Object with extracted statements: { statements: string[] }",
64
+ },
65
+ {
66
+ name: "analyzePrompt",
67
+ type: "string",
68
+ description: "The prompt sent to the LLM for the analyze step (optional).",
69
+ },
70
+ {
71
+ name: "analyzeStepResult",
72
+ type: "object",
73
+ description: "Object with results: { results: Array<{ result: 'yes' | 'unsure' | 'no', reason: string }> }",
74
+ },
75
+ {
76
+ name: "reasonPrompt",
77
+ type: "string",
78
+ description: "The prompt sent to the LLM for the reason step (optional).",
79
+ },
80
+ {
81
+ name: "reason",
82
+ type: "string",
83
+ description: "Explanation of the score.",
84
+ },
85
+ ]}
86
+ />
87
+
88
+ ## Scoring Details
89
+
90
+ The scorer evaluates relevancy through query-answer alignment, considering completeness and detail level, but not factual correctness.
91
+
92
+ ### Scoring Process
93
+
94
+ 1. **Statement Extraction:**
95
+ - Breaks output into meaningful statements while preserving context.
96
+ 2. **Relevance Analysis:**
97
+ - Each statement is evaluated as:
98
+ - "yes": Full weight for direct matches
99
+ - "unsure": Partial weight (default: 0.3) for approximate matches
100
+ - "no": Zero weight for irrelevant content
101
+ 3. **Score Calculation:**
102
+ - `((direct + uncertainty * partial) / total_statements) * scale`
103
+
104
+ ### Score Interpretation
105
+
106
+ - 1.0: Perfect relevance - complete and accurate
107
+ - 0.7-0.9: High relevance - minor gaps or imprecisions
108
+ - 0.4-0.6: Moderate relevance - significant gaps
109
+ - 0.1-0.3: Low relevance - major issues
110
+ - 0.0: No relevance - incorrect or off-topic
111
+
112
+ ## Related
113
+
114
+ - [Prompt Alignment Scorer](./prompt-alignment)
115
+ - [Faithfulness Scorer](./faithfulness)
@@ -0,0 +1,127 @@
1
+ ---
2
+ title: "Reference: Bias | Scorers | Mastra Docs"
3
+ description: Documentation for the Bias Scorer in Mastra, which evaluates LLM outputs for various forms of bias, including gender, political, racial/ethnic, or geographical bias.
4
+ ---
5
+
6
+ # Bias Scorer
7
+ The `createBiasScorer()` function accepts a single options object with the following properties:
8
+
9
+ For a usage example, see the [Bias Examples](/examples/scorers/bias).
10
+
11
+ ## Parameters
12
+
13
+
14
+ <PropertiesTable
15
+ content={[
16
+ {
17
+ name: "model",
18
+ type: "LanguageModel",
19
+ required: true,
20
+ description: "Configuration for the model used to evaluate bias.",
21
+ },
22
+ {
23
+ name: "scale",
24
+ type: "number",
25
+ required: false,
26
+ defaultValue: "1",
27
+ description: "Maximum score value.",
28
+ },
29
+ ]}
30
+ />
31
+
32
+ This function returns an instance of the MastraScorer class. The `.run()` method accepts the same input as other scorers (see the [MastraScorer reference](./mastra-scorer)), but the return value includes LLM-specific fields as documented below.
33
+
34
+ ## .run() Returns
35
+
36
+ <PropertiesTable
37
+ content={[
38
+ {
39
+ name: "runId",
40
+ type: "string",
41
+ description: "The id of the run (optional).",
42
+ },
43
+ {
44
+ name: "extractStepResult",
45
+ type: "object",
46
+ description: "Object with extracted opinions: { opinions: string[] }",
47
+ },
48
+ {
49
+ name: "extractPrompt",
50
+ type: "string",
51
+ description: "The prompt sent to the LLM for the extract step (optional).",
52
+ },
53
+ {
54
+ name: "analyzeStepResult",
55
+ type: "object",
56
+ description: "Object with results: { results: Array<{ result: 'yes' | 'no', reason: string }> }",
57
+ },
58
+ {
59
+ name: "analyzePrompt",
60
+ type: "string",
61
+ description: "The prompt sent to the LLM for the analyze step (optional).",
62
+ },
63
+ {
64
+ name: "score",
65
+ type: "number",
66
+ description: "Bias score (0 to scale, default 0-1). Higher scores indicate more bias.",
67
+ },
68
+ {
69
+ name: "reason",
70
+ type: "string",
71
+ description: "Explanation of the score.",
72
+ },
73
+ {
74
+ name: "reasonPrompt",
75
+ type: "string",
76
+ description: "The prompt sent to the LLM for the reason step (optional).",
77
+ },
78
+ ]}
79
+ />
80
+
81
+ ## Bias Categories
82
+
83
+ The scorer evaluates several types of bias:
84
+
85
+ 1. **Gender Bias**: Discrimination or stereotypes based on gender
86
+ 2. **Political Bias**: Prejudice against political ideologies or beliefs
87
+ 3. **Racial/Ethnic Bias**: Discrimination based on race, ethnicity, or national origin
88
+ 4. **Geographical Bias**: Prejudice based on location or regional stereotypes
89
+
90
+ ## Scoring Details
91
+
92
+ The scorer evaluates bias through opinion analysis based on:
93
+
94
+ - Opinion identification and extraction
95
+ - Presence of discriminatory language
96
+ - Use of stereotypes or generalizations
97
+ - Balance in perspective presentation
98
+ - Loaded or prejudicial terminology
99
+
100
+ ### Scoring Process
101
+
102
+ 1. Extracts opinions from text:
103
+ - Identifies subjective statements
104
+ - Excludes factual claims
105
+ - Includes cited opinions
106
+ 2. Evaluates each opinion:
107
+ - Checks for discriminatory language
108
+ - Assesses stereotypes and generalizations
109
+ - Analyzes perspective balance
110
+
111
+ Final score: `(biased_opinions / total_opinions) * scale`
112
+
113
+ ### Score interpretation
114
+
115
+ (0 to scale, default 0-1)
116
+
117
+ - 1.0: Complete bias - all opinions contain bias
118
+ - 0.7-0.9: Significant bias - majority of opinions show bias
119
+ - 0.4-0.6: Moderate bias - mix of biased and neutral opinions
120
+ - 0.1-0.3: Minimal bias - most opinions show balanced perspective
121
+ - 0.0: No detectable bias - opinions are balanced and neutral
122
+
123
+ ## Related
124
+
125
+ - [Toxicity Scorer](./toxicity)
126
+ - [Faithfulness Scorer](./faithfulness)
127
+ - [Hallucination Scorer](./hallucination)
@@ -0,0 +1,89 @@
1
+ ---
2
+ title: "Reference: Completeness | Scorers | Mastra Docs"
3
+ description: Documentation for the Completeness Scorer in Mastra, which evaluates how thoroughly LLM outputs cover key elements present in the input.
4
+ ---
5
+
6
+ # Completeness Scorer
7
+
8
+ The `createCompletenessScorer()` function evaluates how thoroughly an LLM's output covers the key elements present in the input. It analyzes nouns, verbs, topics, and terms to determine coverage and provides a detailed completeness score.
9
+
10
+ For a usage example, see the [Completeness Examples](/examples/scorers/completeness).
11
+
12
+ ## Parameters
13
+
14
+ The `createCompletenessScorer()` function does not take any options.
15
+
16
+ This function returns an instance of the MastraScorer class. See the [MastraScorer reference](./mastra-scorer) for details on the `.run()` method and its input/output.
17
+
18
+ ## .run() Returns
19
+
20
+ <PropertiesTable
21
+ content={[
22
+ {
23
+ name: "runId",
24
+ type: "string",
25
+ description: "The id of the run (optional).",
26
+ },
27
+ {
28
+ name: "extractStepResult",
29
+ type: "object",
30
+ description: "Object with extracted elements and coverage details: { inputElements: string[], outputElements: string[], missingElements: string[], elementCounts: { input: number, output: number } }",
31
+ },
32
+ {
33
+ name: "score",
34
+ type: "number",
35
+ description: "Completeness score (0-1) representing the proportion of input elements covered in the output.",
36
+ },
37
+ ]}
38
+ />
39
+
40
+ ## Element Extraction Details
41
+
42
+ The scorer extracts and analyzes several types of elements:
43
+
44
+ - Nouns: Key objects, concepts, and entities
45
+ - Verbs: Actions and states (converted to infinitive form)
46
+ - Topics: Main subjects and themes
47
+ - Terms: Individual significant words
48
+
49
+ The extraction process includes:
50
+
51
+ - Normalization of text (removing diacritics, converting to lowercase)
52
+ - Splitting camelCase words
53
+ - Handling of word boundaries
54
+ - Special handling of short words (3 characters or less)
55
+ - Deduplication of elements
56
+
57
+ ## Scoring Details
58
+
59
+ The scorer evaluates completeness through linguistic element coverage analysis.
60
+
61
+ ### Scoring Process
62
+
63
+ 1. Extracts key elements:
64
+ - Nouns and named entities
65
+ - Action verbs
66
+ - Topic-specific terms
67
+ - Normalized word forms
68
+ 2. Calculates coverage of input elements:
69
+ - Exact matches for short terms (≤3 chars)
70
+ - Substantial overlap (>60%) for longer terms
71
+
72
+ Final score: `(covered_elements / total_input_elements) * scale`
73
+
74
+ ### Score interpretation
75
+
76
+ (0 to scale, default 0-1)
77
+
78
+ - 1.0: Complete coverage - contains all input elements
79
+ - 0.7-0.9: High coverage - includes most key elements
80
+ - 0.4-0.6: Partial coverage - contains some key elements
81
+ - 0.1-0.3: Low coverage - missing most key elements
82
+ - 0.0: No coverage - output lacks all input elements
83
+
84
+ ## Related
85
+
86
+ - [Answer Relevancy Scorer](./answer-relevancy)
87
+ - [Content Similarity Scorer](./content-similarity)
88
+ - [Textual Difference Scorer](./textual-difference)
89
+ - [Keyword Coverage Scorer](./keyword-coverage)
@@ -0,0 +1,96 @@
1
+ ---
2
+ title: "Reference: Content Similarity | Scorers | Mastra Docs"
3
+ description: Documentation for the Content Similarity Scorer in Mastra, which measures textual similarity between strings and provides a matching score.
4
+ ---
5
+
6
+ # Content Similarity Scorer
7
+
8
+ The `createContentSimilarityScorer()` function measures the textual similarity between two strings, providing a score that indicates how closely they match. It supports configurable options for case sensitivity and whitespace handling.
9
+
10
+ For a usage example, see the [Content Similarity Examples](/examples/scorers/content-similarity).
11
+
12
+ ## Parameters
13
+
14
+ The `createContentSimilarityScorer()` function accepts a single options object with the following properties:
15
+
16
+ <PropertiesTable
17
+ content={[
18
+ {
19
+ name: "ignoreCase",
20
+ type: "boolean",
21
+ required: false,
22
+ defaultValue: "true",
23
+ description: "Whether to ignore case differences when comparing strings.",
24
+ },
25
+ {
26
+ name: "ignoreWhitespace",
27
+ type: "boolean",
28
+ required: false,
29
+ defaultValue: "true",
30
+ description: "Whether to normalize whitespace when comparing strings.",
31
+ },
32
+ ]}
33
+ />
34
+
35
+ This function returns an instance of the MastraScorer class. See the [MastraScorer reference](./mastra-scorer) for details on the `.run()` method and its input/output.
36
+
37
+ ## .run() Returns
38
+
39
+ <PropertiesTable
40
+ content={[
41
+ {
42
+ name: "runId",
43
+ type: "string",
44
+ description: "The id of the run (optional).",
45
+ },
46
+ {
47
+ name: "extractStepResult",
48
+ type: "object",
49
+ description: "Object with processed input and output: { processedInput: string, processedOutput: string }",
50
+ },
51
+ {
52
+ name: "analyzeStepResult",
53
+ type: "object",
54
+ description: "Object with similarity: { similarity: number }",
55
+ },
56
+ {
57
+ name: "score",
58
+ type: "number",
59
+ description: "Similarity score (0-1) where 1 indicates perfect similarity.",
60
+ },
61
+ ]}
62
+ />
63
+
64
+ ## Scoring Details
65
+
66
+ The scorer evaluates textual similarity through character-level matching and configurable text normalization.
67
+
68
+ ### Scoring Process
69
+
70
+ 1. Normalizes text:
71
+ - Case normalization (if ignoreCase: true)
72
+ - Whitespace normalization (if ignoreWhitespace: true)
73
+ 2. Compares processed strings using string-similarity algorithm:
74
+ - Analyzes character sequences
75
+ - Aligns word boundaries
76
+ - Considers relative positions
77
+ - Accounts for length differences
78
+
79
+ Final score: `similarity_value * scale`
80
+
81
+ ### Score interpretation
82
+
83
+ (0 to scale, default 0-1)
84
+
85
+ - 1.0: Perfect match - identical texts
86
+ - 0.7-0.9: High similarity - mostly matching content
87
+ - 0.4-0.6: Moderate similarity - partial matches
88
+ - 0.1-0.3: Low similarity - few matching patterns
89
+ - 0.0: No similarity - completely different texts
90
+
91
+ ## Related
92
+
93
+ - [Completeness Scorer](./completeness)
94
+ - [Textual Difference Scorer](./textual-difference)
95
+ - [Answer Relevancy Scorer](./answer-relevancy)
96
+ - [Keyword Coverage Scorer](./keyword-coverage)
@@ -0,0 +1,155 @@
1
+ ---
2
+ title: "Reference: Create Custom Scorer | Scorers | Mastra Docs"
3
+ description: Documentation for creating custom code scorers in Mastra, allowing users to define their own evaluation logic.
4
+ ---
5
+
6
+ # createScorer
7
+
8
+ Mastra allows you to define your own custom code scorers for evaluating input/output pairs using any logic you choose. Custom scorers integrate seamlessly with the Mastra scoring framework and can be used anywhere built-in scorers are used.
9
+
10
+ For a usage example, see the [Custom Code Scorer Examples](/examples/scorers/custom-native-javascript-eval).
11
+
12
+ ## How to Create a Custom Scorer
13
+
14
+ Use the `createScorer` factory to define your scorer. You must provide at least a `name`, `description`, and an `analyze` function. Optionally, you can provide `extract` and `reason` functions for multi-step or more advanced logic.
15
+
16
+ ## createScorer Options
17
+
18
+ <PropertiesTable
19
+ content={[
20
+ {
21
+ name: "name",
22
+ type: "string",
23
+ required: true,
24
+ description: "Name of the scorer.",
25
+ },
26
+ {
27
+ name: "description",
28
+ type: "string",
29
+ required: true,
30
+ description: "Description of what the scorer does.",
31
+ },
32
+ {
33
+ name: "analyze",
34
+ type: "function",
35
+ required: true,
36
+ description: "Main scoring logic",
37
+ },
38
+ {
39
+ name: "extract",
40
+ type: "function",
41
+ required: false,
42
+ description: "Optional pre-processing step.",
43
+ },
44
+ {
45
+ name: "reason",
46
+ type: "function",
47
+ required: false,
48
+ description: "Optional reason/explanation step.",
49
+ },
50
+ {
51
+ name: "metadata",
52
+ type: "object",
53
+ required: false,
54
+ description: "Optional metadata for the scorer.",
55
+ },
56
+ ]}
57
+ />
58
+
59
+ This function returns an instance of the MastraScorer class. See the [MastraScorer reference](./mastra-scorer) for details on the `.run()` method and its input/output.
60
+
61
+ ## Step Function Signatures
62
+
63
+
64
+ ### extract
65
+ <PropertiesTable
66
+ content={[
67
+ {
68
+ name: "input",
69
+ type: "Record<string, any>[]",
70
+ required: false,
71
+ description:
72
+ "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.",
73
+ },
74
+ {
75
+ name: "output",
76
+ type: "Record<string, any>",
77
+ required: true,
78
+ description:
79
+ "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
80
+ },
81
+ ]}
82
+ />
83
+ Returns: `{ results: any }`
84
+ The method must return an object with a `results` property. The value of `results` will be passed to the analyze function as `extractStepResult`.
85
+
86
+ ### analyze
87
+ <PropertiesTable
88
+ content={[
89
+ {
90
+ name: "input",
91
+ type: "Record<string, any>[]",
92
+ required: true,
93
+ description:
94
+ "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.",
95
+ },
96
+ {
97
+ name: "output",
98
+ type: "Record<string, any>",
99
+ required: true,
100
+ description:
101
+ "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
102
+ },
103
+ {
104
+ name: "extractStepResult",
105
+ type: "object",
106
+ required: false,
107
+ description: "Result of the extract step, if defined (optional).",
108
+ },
109
+ ]}
110
+ />
111
+ Returns: `{ score: number, results?: any }`
112
+ 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`.
113
+
114
+
115
+ ### reason
116
+ <PropertiesTable
117
+ content={[
118
+ {
119
+ name: "input",
120
+ type: "Record<string, any>[]",
121
+ required: true,
122
+ description:
123
+ "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.",
124
+ },
125
+ {
126
+ name: "output",
127
+ type: "Record<string, any>",
128
+ required: true,
129
+ description:
130
+ "Output record provided to the scorer. For agents, this is usually the agent's response. For workflows, this is the workflow's output.",
131
+ },
132
+ {
133
+ name: "score",
134
+ type: "number",
135
+ required: true,
136
+ description: "Score computed by the analyze step.",
137
+ },
138
+ {
139
+ name: "analyzeStepResult",
140
+ type: "object",
141
+ required: true,
142
+ description: "Result of the analyze step.",
143
+ },
144
+ {
145
+ name: "extractStepResult",
146
+ type: "object",
147
+ required: false,
148
+ description: "Result of the extract step, if defined (optional).",
149
+ },
150
+ ]}
151
+ />
152
+ Returns: `{ reason: string }`
153
+ The method must return an object with a `reason` property, which should be a string explaining the score.
154
+
155
+ All step functions can be async.