@mastra/mcp-docs-server 0.13.7-alpha.1 → 0.13.7-alpha.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.docs/organized/changelogs/%40mastra%2Fclient-js.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +37 -37
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +33 -33
- package/.docs/organized/changelogs/%40mastra%2Flibsql.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fmemory.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +20 -20
- package/.docs/organized/changelogs/%40mastra%2Fmssql.md +17 -0
- package/.docs/organized/changelogs/%40mastra%2Fpg.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fupstash.md +29 -29
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +18 -18
- package/.docs/organized/changelogs/mastra.md +21 -21
- package/.docs/organized/code-examples/agent.md +93 -3
- package/.docs/organized/code-examples/ai-sdk-v5.md +4 -4
- package/.docs/raw/agents/input-processors.mdx +268 -0
- package/.docs/raw/agents/using-tools-and-mcp.mdx +39 -0
- package/.docs/raw/community/contributing-templates.mdx +2 -2
- package/.docs/raw/observability/tracing.mdx +44 -0
- package/.docs/raw/reference/agents/agent.mdx +7 -0
- package/.docs/raw/reference/cli/dev.mdx +6 -0
- package/.docs/raw/reference/client-js/memory.mdx +18 -0
- package/.docs/raw/reference/memory/Memory.mdx +1 -0
- package/.docs/raw/reference/memory/deleteMessages.mdx +95 -0
- package/.docs/raw/reference/memory/getThreadsByResourceId.mdx +33 -1
- package/.docs/raw/reference/rag/upstash.mdx +112 -5
- package/.docs/raw/reference/scorers/answer-relevancy.mdx +0 -1
- package/.docs/raw/reference/scorers/faithfulness.mdx +0 -1
- package/.docs/raw/reference/scorers/hallucination.mdx +0 -2
- package/.docs/raw/reference/scorers/llm-scorer.mdx +45 -1
- package/.docs/raw/reference/storage/libsql.mdx +7 -4
- package/.docs/raw/reference/storage/mssql.mdx +7 -3
- package/.docs/raw/reference/storage/postgresql.mdx +7 -3
- package/.docs/raw/reference/templates.mdx +11 -5
- package/.docs/raw/scorers/custom-scorers.mdx +319 -0
- package/.docs/raw/scorers/off-the-shelf-scorers.mdx +30 -0
- package/.docs/raw/scorers/overview.mdx +124 -0
- package/package.json +6 -6
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Built-in Scorers"
|
|
3
|
+
description: "Overview of Mastra's ready-to-use scorers for evaluating AI outputs across quality, safety, and performance dimensions."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Built-in Scorers
|
|
7
|
+
|
|
8
|
+
Mastra provides a comprehensive set of built-in scorers for evaluating AI outputs. These scorers are optimized for common evaluation scenarios and are ready to use in your agents and workflows.
|
|
9
|
+
|
|
10
|
+
## Available Scorers
|
|
11
|
+
|
|
12
|
+
### Accuracy and Reliability
|
|
13
|
+
|
|
14
|
+
These scorers evaluate how correct, truthful, and complete your agent's answers are:
|
|
15
|
+
|
|
16
|
+
- [`answer-relevancy`](/reference/scorers/answer-relevancy): Evaluates how well responses address the input query (`0-1`, higher is better)
|
|
17
|
+
- [`faithfulness`](/reference/scorers/faithfulness): Measures how accurately responses represent provided context (`0-1`, higher is better)
|
|
18
|
+
- [`hallucination`](/reference/scorers/hallucination): Detects factual contradictions and unsupported claims (`0-1`, lower is better)
|
|
19
|
+
- [`completeness`](/reference/scorers/completeness): Checks if responses include all necessary information (`0-1`, higher is better)
|
|
20
|
+
- [`content-similarity`](/reference/scorers/content-similarity): Measures textual similarity using character-level matching (`0-1`, higher is better)
|
|
21
|
+
- [`textual-difference`](/reference/scorers/textual-difference): Measures textual differences between strings (`0-1`, higher means more similar)
|
|
22
|
+
|
|
23
|
+
### Output Quality
|
|
24
|
+
|
|
25
|
+
These scorers evaluate adherence to format, style, and safety requirements:
|
|
26
|
+
|
|
27
|
+
- [`tone-consistency`](/reference/scorers/tone-consistency): Measures consistency in formality, complexity, and style (`0-1`, higher is better)
|
|
28
|
+
- [`toxicity`](/reference/scorers/toxicity): Detects harmful or inappropriate content (`0-1`, lower is better)
|
|
29
|
+
- [`bias`](/reference/scorers/bias): Detects potential biases in the output (`0-1`, lower is better)
|
|
30
|
+
- [`keyword-coverage`](/reference/scorers/keyword-coverage): Assesses technical terminology usage (`0-1`, higher is better)
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Overview"
|
|
3
|
+
description: Overview of scorers in Mastra, detailing their capabilities for evaluating AI outputs and measuring performance.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Scorers overview
|
|
7
|
+
|
|
8
|
+
**Scorers** are evaluation tools that measure the quality, accuracy, or performance of AI-generated outputs. Scorers provide an automated way to assess whether your agents, workflows, or language models are producing the desired results by analyzing their responses against specific criteria.
|
|
9
|
+
|
|
10
|
+
**Scores** are numerical values (typically between 0 and 1) that quantify how well an output meets your evaluation criteria. These scores enable you to objectively track performance, compare different approaches, and identify areas for improvement in your AI systems.
|
|
11
|
+
|
|
12
|
+
## Evaluation pipeline
|
|
13
|
+
|
|
14
|
+
Mastra scorers follow an optional three-step pipeline that allows for evaluation workflows:
|
|
15
|
+
|
|
16
|
+
1. **Extract** (Optional): Identify and isolate relevant content for focused evaluation
|
|
17
|
+
2. **Analyze** (Required): Perform the core evaluation and generate a score
|
|
18
|
+
3. **Reason** (Optional): Provide explanations or justifications for the score
|
|
19
|
+
|
|
20
|
+
This modular structure enables both simple single-step evaluations and complex multi-stage analysis workflows, allowing you to build evaluations that match your specific needs.
|
|
21
|
+
|
|
22
|
+
### When to use each step
|
|
23
|
+
|
|
24
|
+
**Extract step** - Use when your content is complex or needs preprocessing:
|
|
25
|
+
- Separating facts from opinions in mixed responses
|
|
26
|
+
- Focusing evaluation on specific sections of long outputs
|
|
27
|
+
- Parsing multiple claims that need individual evaluation
|
|
28
|
+
- Example: Bias detection that first identifies opinion statements
|
|
29
|
+
|
|
30
|
+
**Analyze step** - Always required for core evaluation:
|
|
31
|
+
- Straightforward scenarios: Direct scoring of input/output pairs
|
|
32
|
+
- Complex scenarios: Evaluate preprocessed content and generate detailed results
|
|
33
|
+
- Applies your scoring criteria and calculates the numerical score
|
|
34
|
+
|
|
35
|
+
**Reason step** - Use when explanations are important:
|
|
36
|
+
- Users need to understand why a score was assigned
|
|
37
|
+
- Debugging and transparency are critical
|
|
38
|
+
- Compliance or auditing requires explanations
|
|
39
|
+
- Providing actionable feedback for improvement
|
|
40
|
+
|
|
41
|
+
To learn how to create your own Scorers, see [Creating Custom Scorers](/docs/scorers/custom-scorers).
|
|
42
|
+
|
|
43
|
+
## Live evaluations
|
|
44
|
+
|
|
45
|
+
**Live evaluations** allow you to automatically score AI outputs in real-time as your agents and workflows operate. Instead of running evaluations manually or in batches, scorers run asynchronously alongside your AI systems, providing continuous quality monitoring.
|
|
46
|
+
|
|
47
|
+
### Adding scorers to agents
|
|
48
|
+
|
|
49
|
+
You can add built-in scorers to your agents to automatically evaluate their outputs. See the [full list of built-in scorers](/docs/scorers/off-the-shelf-scorers) for all available options.
|
|
50
|
+
|
|
51
|
+
```typescript filename="src/mastra/agents/evaluated-agent.ts" showLineNumbers copy
|
|
52
|
+
import { Agent } from "@mastra/core/agent";
|
|
53
|
+
import { openai } from "@ai-sdk/openai";
|
|
54
|
+
import {
|
|
55
|
+
createAnswerRelevancyScorer,
|
|
56
|
+
createToxicityScorer
|
|
57
|
+
} from "@mastra/evals/scorers/llm";
|
|
58
|
+
|
|
59
|
+
export const evaluatedAgent = new Agent({
|
|
60
|
+
// ...
|
|
61
|
+
scorers: {
|
|
62
|
+
relevancy: {
|
|
63
|
+
scorer: createAnswerRelevancyScorer({ model: openai("gpt-4o-mini") }),
|
|
64
|
+
sampling: { type: "ratio", rate: 0.5 }
|
|
65
|
+
},
|
|
66
|
+
safety: {
|
|
67
|
+
scorer: createToxicityScorer({ model: openai("gpt-4o-mini") }),
|
|
68
|
+
sampling: { type: "ratio", rate: 1 }
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
### Adding scorers to workflow steps
|
|
75
|
+
|
|
76
|
+
You can also add scorers to individual workflow steps to evaluate outputs at specific points in your process:
|
|
77
|
+
|
|
78
|
+
```typescript filename="src/mastra/workflows/content-generation.ts" showLineNumbers copy
|
|
79
|
+
import { createWorkflow, createStep } from "@mastra/core/workflows";
|
|
80
|
+
import { z } from "zod";
|
|
81
|
+
import { customStepScorer } from "../scorers/custom-step-scorer";
|
|
82
|
+
|
|
83
|
+
const contentStep = createStep({
|
|
84
|
+
// ...
|
|
85
|
+
scorers: {
|
|
86
|
+
customStepScorer: {
|
|
87
|
+
scorer: customStepScorer(),
|
|
88
|
+
sampling: {
|
|
89
|
+
type: "ratio",
|
|
90
|
+
rate: 1, // Score every step execution
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
export const contentWorkflow = createWorkflow({ ... })
|
|
97
|
+
.then(contentStep)
|
|
98
|
+
.commit();
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### How live evaluations work
|
|
102
|
+
|
|
103
|
+
**Asynchronous execution**: Live evaluations run in the background without blocking your agent responses or workflow execution. This ensures your AI systems maintain their performance while still being monitored.
|
|
104
|
+
|
|
105
|
+
**Sampling control**: The `sampling.rate` parameter (0-1) controls what percentage of outputs get scored:
|
|
106
|
+
- `1.0`: Score every single response (100%)
|
|
107
|
+
- `0.5`: Score half of all responses (50%)
|
|
108
|
+
- `0.1`: Score 10% of responses
|
|
109
|
+
- `0.0`: Disable scoring
|
|
110
|
+
|
|
111
|
+
**Automatic storage**: All scoring results are automatically stored in the `mastra_scorers` table in your configured database, allowing you to analyze performance trends over time.
|
|
112
|
+
|
|
113
|
+
## Testing scorers locally
|
|
114
|
+
|
|
115
|
+
Mastra provides a CLI command `mastra dev` to test your scorers. The playground includes a scorers section where you can run individual scorers against test inputs and view detailed results.
|
|
116
|
+
|
|
117
|
+
For more details, see the [Local Dev Playground](/docs/server-db/local-dev-playground) docs.
|
|
118
|
+
|
|
119
|
+
## Next steps
|
|
120
|
+
|
|
121
|
+
- Learn how to create your own scorers in the [Creating Custom Scorers](/docs/scorers/custom-scorers) guide
|
|
122
|
+
- Explore built-in scorers in the [Off-the-shelf Scorers](/docs/scorers/off-the-shelf-scorers) section
|
|
123
|
+
- Test scorers with the [Local Dev Playground](/docs/server-db/local-dev-playground)
|
|
124
|
+
- See example scorers in the [Examples Overview](/examples) section
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.7-alpha.
|
|
3
|
+
"version": "0.13.7-alpha.2",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -32,8 +32,8 @@
|
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@mastra/
|
|
36
|
-
"@mastra/
|
|
35
|
+
"@mastra/core": "0.12.0-alpha.2",
|
|
36
|
+
"@mastra/mcp": "^0.10.7"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
39
|
"@hono/node-server": "^1.17.1",
|
|
@@ -43,13 +43,13 @@
|
|
|
43
43
|
"@wong2/mcp-cli": "^1.10.0",
|
|
44
44
|
"cross-env": "^7.0.3",
|
|
45
45
|
"eslint": "^9.30.1",
|
|
46
|
-
"hono": "^4.8.
|
|
46
|
+
"hono": "^4.8.9",
|
|
47
47
|
"tsup": "^8.5.0",
|
|
48
48
|
"tsx": "^4.19.4",
|
|
49
49
|
"typescript": "^5.8.3",
|
|
50
50
|
"vitest": "^3.2.4",
|
|
51
|
-
"@
|
|
52
|
-
"@
|
|
51
|
+
"@internal/lint": "0.0.23",
|
|
52
|
+
"@mastra/core": "0.12.0-alpha.2"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"prepare-docs": "cross-env PREPARE=true node dist/prepare-docs/prepare.js",
|