@mastra/mcp-docs-server 0.13.5-alpha.0 → 0.13.5
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 +18 -18
- package/.docs/organized/changelogs/%40mastra%2Fcore.md +16 -16
- package/.docs/organized/changelogs/%40mastra%2Fdeployer.md +21 -21
- package/.docs/organized/changelogs/%40mastra%2Ffirecrawl.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fmcp.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fplayground-ui.md +23 -23
- package/.docs/organized/changelogs/%40mastra%2Frag.md +14 -14
- package/.docs/organized/changelogs/%40mastra%2Fschema-compat.md +6 -0
- package/.docs/organized/changelogs/%40mastra%2Fserver.md +18 -18
- package/.docs/organized/changelogs/create-mastra.md +8 -8
- package/.docs/organized/changelogs/mastra.md +17 -17
- package/.docs/raw/agents/overview.mdx +16 -33
- package/.docs/raw/community/licensing.mdx +27 -19
- package/.docs/raw/deployment/cloud-providers/digital-ocean.mdx +1 -1
- package/.docs/raw/deployment/server-deployment.mdx +56 -0
- package/.docs/raw/rag/retrieval.mdx +24 -5
- package/.docs/raw/reference/rag/rerankWithScorer.mdx +213 -0
- package/.docs/raw/server-db/production-server.mdx +66 -0
- package/.docs/raw/tools-mcp/mcp-overview.mdx +4 -6
- package/.docs/raw/workflows/control-flow.mdx +34 -34
- package/LICENSE.md +11 -42
- package/package.json +5 -5
- package/.docs/raw/deployment/server.mdx +0 -116
- /package/.docs/raw/{deployment → server-db}/custom-api-routes.mdx +0 -0
- /package/.docs/raw/{local-dev/mastra-dev.mdx → server-db/local-dev-playground.mdx} +0 -0
- /package/.docs/raw/{client-js/overview.mdx → server-db/mastra-client.mdx} +0 -0
- /package/.docs/raw/{deployment → server-db}/middleware.mdx +0 -0
- /package/.docs/raw/{storage/overview.mdx → server-db/storage.mdx} +0 -0
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
title: "Creating A Mastra Server"
|
|
3
|
-
description: "Configure and customize the Mastra server with middleware and other options"
|
|
4
|
-
---
|
|
5
|
-
|
|
6
|
-
# Creating A Mastra Server
|
|
7
|
-
|
|
8
|
-
While developing or when you deploy a Mastra application, it runs as an HTTP server that exposes your agents, workflows, and other functionality as API endpoints. This page explains how to configure and customize the server behavior.
|
|
9
|
-
|
|
10
|
-
## Server Architecture
|
|
11
|
-
|
|
12
|
-
Mastra uses [Hono](https://hono.dev) as its underlying HTTP server framework. When you build a Mastra application using `mastra build`, it generates a Hono-based HTTP server in the `.mastra` directory.
|
|
13
|
-
|
|
14
|
-
The server provides:
|
|
15
|
-
|
|
16
|
-
- API endpoints for all registered agents
|
|
17
|
-
- API endpoints for all registered workflows
|
|
18
|
-
- Custom api route supports
|
|
19
|
-
- Custom middleware support
|
|
20
|
-
- Configuration of timeout
|
|
21
|
-
- Configuration of port
|
|
22
|
-
- Configuration of body limit
|
|
23
|
-
|
|
24
|
-
See the [Middleware](/docs/deployment/middleware) and
|
|
25
|
-
[Custom API Routes](/docs/deployment/custom-api-routes) pages for details on
|
|
26
|
-
adding additional server behaviour.
|
|
27
|
-
|
|
28
|
-
## Server configuration
|
|
29
|
-
|
|
30
|
-
You can configure server `port` and `timeout` in the Mastra instance.
|
|
31
|
-
|
|
32
|
-
```typescript copy showLineNumbers
|
|
33
|
-
import { Mastra } from "@mastra/core";
|
|
34
|
-
|
|
35
|
-
export const mastra = new Mastra({
|
|
36
|
-
server: {
|
|
37
|
-
port: 3000, // Defaults to 4111
|
|
38
|
-
timeout: 10000, // Defaults to 30000 (30s)
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
The `method` option can be one of `"GET"`, `"POST"`, `"PUT"`,
|
|
44
|
-
`"DELETE"` or `"ALL"`. Using `"ALL"` will cause the handler to be
|
|
45
|
-
invoked for any HTTP method that matches the path.
|
|
46
|
-
|
|
47
|
-
## Custom CORS Config
|
|
48
|
-
|
|
49
|
-
Mastra allows you to configure CORS (Cross-Origin Resource Sharing) settings for your server.
|
|
50
|
-
|
|
51
|
-
```typescript copy showLineNumbers
|
|
52
|
-
import { Mastra } from "@mastra/core";
|
|
53
|
-
|
|
54
|
-
export const mastra = new Mastra({
|
|
55
|
-
server: {
|
|
56
|
-
cors: {
|
|
57
|
-
origin: ["https://example.com"], // Allow specific origins or '*' for all
|
|
58
|
-
allowMethods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],
|
|
59
|
-
allowHeaders: ["Content-Type", "Authorization"],
|
|
60
|
-
credentials: false,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
});
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
## Deployment
|
|
67
|
-
|
|
68
|
-
Since Mastra builds to a standard Node.js server, you can deploy to any platform that runs Node.js applications:
|
|
69
|
-
|
|
70
|
-
- Cloud VMs (AWS EC2, DigitalOcean Droplets, GCP Compute Engine)
|
|
71
|
-
- Container platforms (Docker, Kubernetes)
|
|
72
|
-
- Platform as a Service (Heroku, Railway)
|
|
73
|
-
- Self-hosted servers
|
|
74
|
-
|
|
75
|
-
### Building
|
|
76
|
-
|
|
77
|
-
Build the application:
|
|
78
|
-
|
|
79
|
-
```bash copy
|
|
80
|
-
# Build from current directory
|
|
81
|
-
mastra build
|
|
82
|
-
|
|
83
|
-
# Or specify a directory
|
|
84
|
-
mastra build --dir ./my-project
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
The build process:
|
|
88
|
-
|
|
89
|
-
1. Locates entry file (`src/mastra/index.ts` or `src/mastra/index.js`)
|
|
90
|
-
2. Creates `.mastra` output directory
|
|
91
|
-
3. Bundles code using Rollup with tree shaking and source maps
|
|
92
|
-
4. Generates [Hono](https://hono.dev) HTTP server
|
|
93
|
-
|
|
94
|
-
See [`mastra build`](/reference/cli/build) for all options.
|
|
95
|
-
|
|
96
|
-
### Running the Server
|
|
97
|
-
|
|
98
|
-
Start the HTTP server:
|
|
99
|
-
|
|
100
|
-
```bash copy
|
|
101
|
-
node .mastra/output/index.mjs
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
### Enable Telemetry for build output
|
|
105
|
-
|
|
106
|
-
Load instrumentation for the build output like so:
|
|
107
|
-
|
|
108
|
-
```bash copy
|
|
109
|
-
node --import=./.mastra/output/instrumentation.mjs .mastra/output/index.mjs
|
|
110
|
-
```
|
|
111
|
-
|
|
112
|
-
## Serverless Deployment
|
|
113
|
-
|
|
114
|
-
Mastra also supports serverless deployment on Cloudflare Workers, Vercel, and Netlify.
|
|
115
|
-
|
|
116
|
-
See our [Serverless Deployment](/docs/deployment/deployment) guide for setup instructions.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|