@mastra/mcp-docs-server 0.13.2-alpha.2 → 0.13.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 +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare-d1.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fcloudflare.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-cloudflare.md +15 -15
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-netlify.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fdeployer-vercel.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fdynamodb.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fmcp-docs-server.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fmongodb.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +26 -26
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +7 -7
- package/.docs/organized/changelogs/%40mastra%2Fvectorize.md +8 -8
- package/.docs/organized/changelogs/%40mastra%2Fvoice-cloudflare.md +8 -8
- package/.docs/organized/changelogs/create-mastra.md +7 -7
- package/.docs/organized/changelogs/mastra.md +10 -10
- package/.docs/raw/course/01-first-agent/04-project-structure.md +8 -3
- package/.docs/raw/course/01-first-agent/07-creating-your-agent.md +5 -3
- package/.docs/raw/course/01-first-agent/08-exporting-your-agent.md +21 -6
- package/.docs/raw/course/01-first-agent/11-creating-transactions-tool.md +5 -3
- package/.docs/raw/course/01-first-agent/12-connecting-tool-to-agent.md +2 -2
- package/.docs/raw/course/04-workflows/01-introduction-to-workflows.md +44 -0
- package/.docs/raw/course/04-workflows/02-understanding-steps.md +53 -0
- package/.docs/raw/course/04-workflows/03-creating-your-first-step.md +57 -0
- package/.docs/raw/course/04-workflows/04-creating-a-second-step.md +58 -0
- package/.docs/raw/course/04-workflows/05-chaining-steps-together.md +57 -0
- package/.docs/raw/course/04-workflows/06-registering-with-mastra.md +24 -0
- package/.docs/raw/course/04-workflows/07-using-playground.md +58 -0
- package/.docs/raw/course/04-workflows/08-running-workflows-programmatically.md +77 -0
- package/.docs/raw/course/04-workflows/09-adding-a-third-step.md +70 -0
- package/.docs/raw/course/04-workflows/10-updating-the-workflow.md +55 -0
- package/.docs/raw/course/04-workflows/11-creating-an-ai-agent.md +67 -0
- package/.docs/raw/course/04-workflows/12-using-agent-in-workflow.md +91 -0
- package/.docs/raw/course/04-workflows/13-creating-ai-enhanced-workflow.md +75 -0
- package/.docs/raw/course/04-workflows/14-understanding-parallel-execution.md +38 -0
- package/.docs/raw/course/04-workflows/15-creating-parallel-steps.md +115 -0
- package/.docs/raw/course/04-workflows/16-building-parallel-workflow.md +100 -0
- package/.docs/raw/course/04-workflows/17-testing-parallel-performance.md +40 -0
- package/.docs/raw/course/04-workflows/18-understanding-conditional-branching.md +61 -0
- package/.docs/raw/course/04-workflows/19-creating-conditional-steps.md +128 -0
- package/.docs/raw/course/04-workflows/20-building-conditional-workflow.md +60 -0
- package/.docs/raw/course/04-workflows/21-testing-conditional-logic.md +58 -0
- package/.docs/raw/course/04-workflows/22-conclusion.md +58 -0
- package/package.json +4 -4
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Building Conditional Workflow
|
|
2
|
+
|
|
3
|
+
Now you'll create a workflow that uses conditional branching to route content through two different processing paths.
|
|
4
|
+
|
|
5
|
+
## Creating the Conditional Workflow
|
|
6
|
+
|
|
7
|
+
Add this workflow to your file:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
export const conditionalWorkflow = createWorkflow({
|
|
11
|
+
id: "conditional-workflow",
|
|
12
|
+
description: "Content processing with conditional branching",
|
|
13
|
+
inputSchema: z.object({
|
|
14
|
+
content: z.string(),
|
|
15
|
+
type: z.enum(["article", "blog", "social"]).default("article"),
|
|
16
|
+
}),
|
|
17
|
+
outputSchema: z.object({
|
|
18
|
+
processedContent: z.string(),
|
|
19
|
+
processingType: z.string(),
|
|
20
|
+
recommendations: z.array(z.string()),
|
|
21
|
+
}),
|
|
22
|
+
})
|
|
23
|
+
.then(assessContentStep)
|
|
24
|
+
.branch([
|
|
25
|
+
// Branch 1: Short and simple content
|
|
26
|
+
[
|
|
27
|
+
async ({ inputData }) =>
|
|
28
|
+
inputData.category === "short" && inputData.complexity === "simple",
|
|
29
|
+
quickProcessingStep,
|
|
30
|
+
],
|
|
31
|
+
// Branch 2: Everything else
|
|
32
|
+
[
|
|
33
|
+
async ({ inputData }) =>
|
|
34
|
+
!(inputData.category === "short" && inputData.complexity === "simple"),
|
|
35
|
+
generalProcessingStep,
|
|
36
|
+
],
|
|
37
|
+
])
|
|
38
|
+
.commit();
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
## Understanding the Conditions
|
|
42
|
+
|
|
43
|
+
1. **Short + Simple**: Quick processing with minimal recommendations
|
|
44
|
+
2. **Everything Else**: General processing with more suggestions
|
|
45
|
+
|
|
46
|
+
## Multiple Conditions
|
|
47
|
+
|
|
48
|
+
You can combine conditions using logical operators:
|
|
49
|
+
|
|
50
|
+
- **`&&`**: AND - both conditions must be true
|
|
51
|
+
- **`||`**: OR - either condition can be true
|
|
52
|
+
- **`!`**: NOT - condition must be false
|
|
53
|
+
|
|
54
|
+
## Condition Evaluation
|
|
55
|
+
|
|
56
|
+
- Conditions are checked in order
|
|
57
|
+
- Multiple conditions can be true (steps run in parallel)
|
|
58
|
+
- If no conditions match, the branch is skipped
|
|
59
|
+
|
|
60
|
+
Next, you'll test this conditional workflow with different types of content!
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Testing Conditional Logic
|
|
2
|
+
|
|
3
|
+
Let's test your conditional workflow with different types of content to see how it routes to different processing paths.
|
|
4
|
+
|
|
5
|
+
## Registering the New Workflow
|
|
6
|
+
|
|
7
|
+
Update your Mastra configuration to include your new workflow workflows:
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
// In src/mastra/index.ts
|
|
11
|
+
import {
|
|
12
|
+
contentWorkflow,
|
|
13
|
+
aiContentWorkflow,
|
|
14
|
+
parallelAnalysisWorkflow,
|
|
15
|
+
conditionalWorkflow,
|
|
16
|
+
} from "./workflows/content-workflow";
|
|
17
|
+
|
|
18
|
+
export const mastra = new Mastra({
|
|
19
|
+
workflows: {
|
|
20
|
+
contentWorkflow,
|
|
21
|
+
aiContentWorkflow,
|
|
22
|
+
parallelAnalysisWorkflow,
|
|
23
|
+
conditionalWorkflow, // Add the conditional workflow
|
|
24
|
+
},
|
|
25
|
+
// ... rest of configuration
|
|
26
|
+
});
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Testing the conditional workflow
|
|
30
|
+
|
|
31
|
+
You can now test this new conditional workflow in the playground. Be sure to test different content lengths and content types.
|
|
32
|
+
|
|
33
|
+
## Understanding the Flow
|
|
34
|
+
|
|
35
|
+
1. **Assessment step** analyzes content and determines category/complexity
|
|
36
|
+
2. **Branch conditions** are evaluated against the assessment results
|
|
37
|
+
3. **Matching step** executes based on which condition(s) are true
|
|
38
|
+
4. **Results** show which processing path was taken
|
|
39
|
+
|
|
40
|
+
## Debugging Conditions
|
|
41
|
+
|
|
42
|
+
If a condition isn't working as expected:
|
|
43
|
+
|
|
44
|
+
- Check the assessment step output
|
|
45
|
+
- Verify condition logic matches your expectations
|
|
46
|
+
- Test individual conditions in isolation
|
|
47
|
+
- Add console.log statements to track condition evaluation
|
|
48
|
+
|
|
49
|
+
## Branch Benefits
|
|
50
|
+
|
|
51
|
+
Conditional workflows provide:
|
|
52
|
+
|
|
53
|
+
- **Intelligent routing**: Right processing for right content
|
|
54
|
+
- **Performance optimization**: Skip heavy processing for simple content
|
|
55
|
+
- **Customized experience**: Different handling for different scenarios
|
|
56
|
+
- **Scalable logic**: Easy to add new conditions and processing paths
|
|
57
|
+
|
|
58
|
+
Next, you'll learn about streaming workflow results for better user experience!
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Conclusion
|
|
2
|
+
|
|
3
|
+
Congratulations! You've completed the Mastra Workflows course and learned how to build powerful, type-safe workflows that can handle complex automation tasks.
|
|
4
|
+
|
|
5
|
+
## What You've Accomplished
|
|
6
|
+
|
|
7
|
+
Throughout this course, you've learned to:
|
|
8
|
+
|
|
9
|
+
### Core Concepts
|
|
10
|
+
|
|
11
|
+
- **Understanding workflows**: How they break complex tasks into manageable steps
|
|
12
|
+
- **Creating steps**: Building reusable units with clear inputs and outputs
|
|
13
|
+
- **Schema validation**: Using Zod for type safety and runtime validation
|
|
14
|
+
- **Error handling**: Making workflows robust and user-friendly
|
|
15
|
+
|
|
16
|
+
### Building Workflows
|
|
17
|
+
|
|
18
|
+
- **Chaining steps**: Connecting steps to create complete workflows
|
|
19
|
+
- **Testing thoroughly**: Ensuring reliability with comprehensive tests
|
|
20
|
+
- **Registering with Mastra**: Integrating workflows into your application
|
|
21
|
+
- **Using the playground**: Visual testing and debugging
|
|
22
|
+
|
|
23
|
+
### Advanced Features
|
|
24
|
+
|
|
25
|
+
- **AI integration**: Combining workflows with agents for intelligent processing
|
|
26
|
+
- **Parallel execution**: Running multiple steps simultaneously for better performance
|
|
27
|
+
- **Conditional branching**: Creating smart workflows that adapt to different scenarios
|
|
28
|
+
|
|
29
|
+
## Key Workflows You Built
|
|
30
|
+
|
|
31
|
+
1. **Content Processing Workflow**: Validates, enhances, and summarizes content
|
|
32
|
+
2. **AI-Enhanced Workflow**: Adds intelligent analysis with AI agents
|
|
33
|
+
3. **Parallel Analysis Workflow**: Demonstrates high-performance parallel execution
|
|
34
|
+
4. **Conditional Workflow**: Shows intelligent routing based on content characteristics
|
|
35
|
+
|
|
36
|
+
## Next Steps
|
|
37
|
+
|
|
38
|
+
Now that you understand workflows, you can:
|
|
39
|
+
|
|
40
|
+
### Expand Your Skills
|
|
41
|
+
|
|
42
|
+
- **Explore more integrations**: Connect workflows with databases, APIs, and external services
|
|
43
|
+
- **Build complex automations**: Create multi-step business processes
|
|
44
|
+
- **Integrate with web applications**: Use workflows in your frontend applications
|
|
45
|
+
- **Scale for production**: Deploy workflows with proper monitoring and error handling
|
|
46
|
+
|
|
47
|
+
## Final Thoughts
|
|
48
|
+
|
|
49
|
+
Workflows are a powerful way to build reliable, maintainable automation systems. The patterns and principles you've learned in this course will help you tackle increasingly complex challenges as you build AI-powered applications.
|
|
50
|
+
|
|
51
|
+
Remember:
|
|
52
|
+
|
|
53
|
+
- **Start simple**: Begin with basic workflows and add complexity gradually
|
|
54
|
+
- **Test thoroughly**: Good testing prevents production issues
|
|
55
|
+
- **Think in steps**: Break complex problems into smaller, manageable pieces
|
|
56
|
+
- **Embrace type safety**: Let schemas catch errors early
|
|
57
|
+
|
|
58
|
+
Thank you for completing the Mastra Workflows lesson. Happy building! 🚀
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "0.13.2
|
|
3
|
+
"version": "0.13.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,7 +32,7 @@
|
|
|
32
32
|
"uuid": "^11.1.0",
|
|
33
33
|
"zod": "^3.25.67",
|
|
34
34
|
"zod-to-json-schema": "^3.24.5",
|
|
35
|
-
"@mastra/mcp": "^0.10.5
|
|
35
|
+
"@mastra/mcp": "^0.10.5"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@hono/node-server": "^1.14.4",
|
|
@@ -47,8 +47,8 @@
|
|
|
47
47
|
"tsx": "^4.19.4",
|
|
48
48
|
"typescript": "^5.8.3",
|
|
49
49
|
"vitest": "^3.2.3",
|
|
50
|
-
"@internal/lint": "0.0.
|
|
51
|
-
"@mastra/core": "0.10.7
|
|
50
|
+
"@internal/lint": "0.0.14",
|
|
51
|
+
"@mastra/core": "0.10.7"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@mastra/core": "^0.10.0-alpha.0"
|