@mastra/mcp-docs-server 1.1.21-alpha.3 → 1.1.21-alpha.6
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/docs/agents/channels.md +170 -0
- package/.docs/docs/agents/overview.md +1 -0
- package/.docs/models/gateways/openrouter.md +2 -1
- package/.docs/models/index.md +1 -1
- package/.docs/models/providers/anthropic.md +1 -2
- package/.docs/models/providers/cortecs.md +2 -1
- package/.docs/models/providers/opencode-go.md +3 -1
- package/.docs/models/providers/opencode.md +1 -3
- package/.docs/models/providers/poe.md +3 -1
- package/.docs/reference/agents/channels.md +164 -0
- package/.docs/reference/index.md +1 -0
- package/CHANGELOG.md +7 -0
- package/package.json +4 -4
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
# Channels
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.22.0`
|
|
4
|
+
|
|
5
|
+
Channels connect your agents to messaging platforms like Slack, Discord, and Telegram. When a user sends a message on a platform, the agent receives it, processes it through the normal agent pipeline, and streams the response back to the conversation.
|
|
6
|
+
|
|
7
|
+
## When to use channels
|
|
8
|
+
|
|
9
|
+
Use channels when you want your agent to:
|
|
10
|
+
|
|
11
|
+
- Respond to messages in Slack workspaces, Discord servers, or Telegram chats
|
|
12
|
+
- Handle both direct messages and mentions in group conversations
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
Configure channels directly on your agent using adapters from the [Chat SDK](https://chat-sdk.dev/adapters):
|
|
17
|
+
|
|
18
|
+
```typescript
|
|
19
|
+
import { Agent } from '@mastra/core/agent'
|
|
20
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
21
|
+
|
|
22
|
+
export const supportAgent = new Agent({
|
|
23
|
+
id: 'support-agent',
|
|
24
|
+
name: 'Support Agent',
|
|
25
|
+
instructions: 'You are a helpful support assistant.',
|
|
26
|
+
model: 'openai/gpt-5.4',
|
|
27
|
+
channels: {
|
|
28
|
+
adapters: {
|
|
29
|
+
slack: createSlackAdapter(),
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
})
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
Register the agent in your Mastra instance with storage so channel state persists across restarts:
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
import { Mastra } from '@mastra/core'
|
|
39
|
+
import { LibSQLStore } from '@mastra/libsql'
|
|
40
|
+
import { supportAgent } from './agents/support-agent'
|
|
41
|
+
|
|
42
|
+
export const mastra = new Mastra({
|
|
43
|
+
agents: { supportAgent },
|
|
44
|
+
storage: new LibSQLStore({
|
|
45
|
+
url: process.env.DATABASE_URL,
|
|
46
|
+
}),
|
|
47
|
+
})
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Each adapter reads credentials from environment variables by default.
|
|
51
|
+
|
|
52
|
+
## Platform setup
|
|
53
|
+
|
|
54
|
+
Each platform requires credentials and event configuration. See the Chat SDK adapter docs for full setup: [Slack](https://chat-sdk.dev/adapters/slack), [Discord](https://chat-sdk.dev/adapters/discord), [Telegram](https://chat-sdk.dev/adapters/telegram).
|
|
55
|
+
|
|
56
|
+
Mastra generates a webhook route for each platform at:
|
|
57
|
+
|
|
58
|
+
```text
|
|
59
|
+
/api/agents/{agentId}/channels/{platform}/webhook
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
For example: `/api/agents/support-agent/channels/slack/webhook`
|
|
63
|
+
|
|
64
|
+
Point your platform's webhook or interactions URL to this path.
|
|
65
|
+
|
|
66
|
+
### Local development
|
|
67
|
+
|
|
68
|
+
Platform webhooks need a public URL to reach your local server. Use a tunnel to expose `localhost:4111`:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
# ngrok
|
|
72
|
+
ngrok http 4111
|
|
73
|
+
|
|
74
|
+
# cloudflared
|
|
75
|
+
cloudflared tunnel --url http://localhost:4111
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Copy the generated URL and use it as the base for your webhook paths (e.g. `https://abc123.ngrok.io/api/agents/support-agent/channels/slack/webhook`).
|
|
79
|
+
|
|
80
|
+
## Thread context
|
|
81
|
+
|
|
82
|
+
When a user mentions the agent mid-conversation in a channel thread, the agent may not have prior context. By default, Mastra fetches the last 10 messages from the platform on the first mention.
|
|
83
|
+
|
|
84
|
+
1. On the **first mention** in a thread, the agent fetches recent messages from the platform.
|
|
85
|
+
2. These messages are prepended to the user's message as conversation context.
|
|
86
|
+
3. After responding, the agent subscribes to the thread and has full history via Mastra's memory.
|
|
87
|
+
4. Subsequent messages in that thread do **not** re-fetch from the platform.
|
|
88
|
+
|
|
89
|
+
Set `threadContext: { maxMessages: 0 }` to disable this behavior. This only applies to non-DM threads.
|
|
90
|
+
|
|
91
|
+
## Tool approval
|
|
92
|
+
|
|
93
|
+
Tools with `requireApproval: true` render as interactive cards with Approve and Deny buttons:
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { createTool } from '@mastra/core/tools'
|
|
97
|
+
import { z } from 'zod'
|
|
98
|
+
|
|
99
|
+
const deleteFile = createTool({
|
|
100
|
+
id: 'delete-file',
|
|
101
|
+
description: 'Delete a file from the system',
|
|
102
|
+
inputSchema: z.object({
|
|
103
|
+
path: z.string().describe('Path to the file to delete'),
|
|
104
|
+
}),
|
|
105
|
+
requireApproval: true,
|
|
106
|
+
execute: async ({ path }) => {
|
|
107
|
+
await fs.unlink(path)
|
|
108
|
+
return { deleted: path }
|
|
109
|
+
},
|
|
110
|
+
})
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
When the agent calls this tool, users see a card with the tool name, arguments, and Approve/Deny buttons. The tool only executes after approval.
|
|
114
|
+
|
|
115
|
+
Set `cards: false` on an adapter to render tool calls as plain text instead of interactive cards. When cards are disabled and a tool requires approval, the agent uses `autoResumeSuspendedTools` to let the LLM decide based on the conversation context.
|
|
116
|
+
|
|
117
|
+
## Multi-user awareness
|
|
118
|
+
|
|
119
|
+
In group conversations, Mastra automatically prefixes each message with the sender's name and platform ID so the agent can distinguish between speakers:
|
|
120
|
+
|
|
121
|
+
```text
|
|
122
|
+
[Alice (@U123ABC)]: Can you help me with this?
|
|
123
|
+
[Bob (@U456DEF)]: I have a question too.
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Multimodal content
|
|
127
|
+
|
|
128
|
+
Models like Gemini can natively process images, video, and audio. Combine `inlineMedia` and `inlineLinks` to let users share rich content with your agent across platforms:
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { Agent } from '@mastra/core/agent'
|
|
132
|
+
import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
133
|
+
import { google } from '@ai-sdk/google'
|
|
134
|
+
|
|
135
|
+
export const visionAgent = new Agent({
|
|
136
|
+
name: 'Vision Agent',
|
|
137
|
+
instructions: 'You can see images, watch videos, and listen to audio.',
|
|
138
|
+
model: google('gemini-3.1-flash-image-preview'),
|
|
139
|
+
channels: {
|
|
140
|
+
adapters: {
|
|
141
|
+
discord: createDiscordAdapter(),
|
|
142
|
+
},
|
|
143
|
+
inlineMedia: ['image/*', 'video/*', 'audio/*'],
|
|
144
|
+
inlineLinks: [
|
|
145
|
+
// Gemini treats YouTube URLs as native video file parts
|
|
146
|
+
{ match: 'youtube.com', mimeType: 'video/*' },
|
|
147
|
+
{ match: 'youtu.be', mimeType: 'video/*' },
|
|
148
|
+
'imgur.com', // HEAD-check imgur links; inline as file part if mimeType matches inlineMedia
|
|
149
|
+
],
|
|
150
|
+
},
|
|
151
|
+
})
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
With this configuration:
|
|
155
|
+
|
|
156
|
+
- A user uploads a screenshot and the agent describes what it sees
|
|
157
|
+
- A user uploads an `.mp4` clip and the agent summarizes the video
|
|
158
|
+
- A user pastes a YouTube link and the agent watches and discusses the video
|
|
159
|
+
- A user pastes an imgur link and the agent sees the image directly
|
|
160
|
+
|
|
161
|
+
By default, only images are sent inline (`inlineMedia: ['image/*']`). Unsupported types are described as text summaries so the agent knows about the file without crashing models that reject them.
|
|
162
|
+
|
|
163
|
+
> **Note:** See [Channels reference](https://mastra.ai/reference/agents/channels) for all `inlineMedia` patterns and [inlineLinks reference](https://mastra.ai/reference/agents/channels) for domain matching, HEAD detection, and forced mime types.
|
|
164
|
+
|
|
165
|
+
## Related
|
|
166
|
+
|
|
167
|
+
- [Agent overview](https://mastra.ai/docs/agents/overview)
|
|
168
|
+
- [Tool approval](https://mastra.ai/docs/agents/agent-approval)
|
|
169
|
+
- [Channels reference](https://mastra.ai/reference/agents/channels)
|
|
170
|
+
- [Chat SDK adapters](https://chat-sdk.dev/adapters)
|
|
@@ -87,6 +87,7 @@ Once your agent is running, use this table to find the right page for what you w
|
|
|
87
87
|
| Keep your agent safe | [Guardrails](https://mastra.ai/docs/agents/guardrails) |
|
|
88
88
|
| Swap instructions or models based on request context | [Dynamic configuration](https://mastra.ai/docs/server/request-context) |
|
|
89
89
|
| Add speech-to-text or text-to-speech | [Voice](https://mastra.ai/docs/agents/adding-voice) |
|
|
90
|
+
| Connect to Slack, Discord, or Telegram | [Channels](https://mastra.ai/docs/agents/channels) |
|
|
90
91
|
|
|
91
92
|
## Multi-agent systems
|
|
92
93
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenRouter
|
|
2
2
|
|
|
3
|
-
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access
|
|
3
|
+
OpenRouter aggregates models from multiple providers with enhanced features like rate limiting and failover. Access 168 models through Mastra's model router.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenRouter documentation](https://openrouter.ai/models).
|
|
6
6
|
|
|
@@ -173,6 +173,7 @@ ANTHROPIC_API_KEY=ant-...
|
|
|
173
173
|
| `qwen/qwen3.5-397b-a17b` |
|
|
174
174
|
| `qwen/qwen3.5-plus-02-15` |
|
|
175
175
|
| `qwen/qwen3.6-plus-preview:free` |
|
|
176
|
+
| `qwen/qwen3.6-plus:free` |
|
|
176
177
|
| `sourceful/riverflow-v2-fast-preview` |
|
|
177
178
|
| `sourceful/riverflow-v2-max-preview` |
|
|
178
179
|
| `sourceful/riverflow-v2-standard-preview` |
|
package/.docs/models/index.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Model Providers
|
|
2
2
|
|
|
3
|
-
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to
|
|
3
|
+
Mastra provides a unified interface for working with LLMs across multiple providers, giving you access to 3581 models from 95 providers through a single API.
|
|
4
4
|
|
|
5
5
|
## Features
|
|
6
6
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Anthropic
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 22 Anthropic models through Mastra's model router. Authentication is handled automatically using the `ANTHROPIC_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models).
|
|
6
6
|
|
|
@@ -37,7 +37,6 @@ for await (const chunk of stream) {
|
|
|
37
37
|
| `anthropic/claude-3-5-sonnet-20240620` | 200K | | | | | | $3 | $15 |
|
|
38
38
|
| `anthropic/claude-3-5-sonnet-20241022` | 200K | | | | | | $3 | $15 |
|
|
39
39
|
| `anthropic/claude-3-7-sonnet-20250219` | 200K | | | | | | $3 | $15 |
|
|
40
|
-
| `anthropic/claude-3-7-sonnet-latest` | 200K | | | | | | $3 | $15 |
|
|
41
40
|
| `anthropic/claude-3-haiku-20240307` | 200K | | | | | | $0.25 | $1 |
|
|
42
41
|
| `anthropic/claude-3-opus-20240229` | 200K | | | | | | $15 | $75 |
|
|
43
42
|
| `anthropic/claude-3-sonnet-20240229` | 200K | | | | | | $3 | $15 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Cortecs
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 29 Cortecs models through Mastra's model router. Authentication is handled automatically using the `CORTECS_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Cortecs documentation](https://cortecs.ai).
|
|
6
6
|
|
|
@@ -48,6 +48,7 @@ for await (const chunk of stream) {
|
|
|
48
48
|
| `cortecs/glm-4.5-air` | 131K | | | | | | $0.22 | $1 |
|
|
49
49
|
| `cortecs/glm-4.7` | 198K | | | | | | $0.45 | $2 |
|
|
50
50
|
| `cortecs/glm-4.7-flash` | 203K | | | | | | $0.09 | $0.53 |
|
|
51
|
+
| `cortecs/glm-5` | 203K | | | | | | $1 | $3 |
|
|
51
52
|
| `cortecs/gpt-4.1` | 1.0M | | | | | | $2 | $9 |
|
|
52
53
|
| `cortecs/gpt-oss-120b` | 128K | | | | | | — | — |
|
|
53
54
|
| `cortecs/intellect-3` | 128K | | | | | | $0.22 | $1 |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenCode Go
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 6 OpenCode Go models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenCode Go documentation](https://opencode.ai/docs/zen).
|
|
6
6
|
|
|
@@ -36,6 +36,8 @@ for await (const chunk of stream) {
|
|
|
36
36
|
| -------------------------- | ------- | ----- | --------- | ----- | ----- | ----- | ---------- | ----------- |
|
|
37
37
|
| `opencode-go/glm-5` | 205K | | | | | | $1 | $3 |
|
|
38
38
|
| `opencode-go/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
39
|
+
| `opencode-go/mimo-v2-omni` | 262K | | | | | | $0.40 | $2 |
|
|
40
|
+
| `opencode-go/mimo-v2-pro` | 1.0M | | | | | | $1 | $3 |
|
|
39
41
|
| `opencode-go/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
40
42
|
| `opencode-go/minimax-m2.7` | 205K | | | | | | $0.30 | $1 |
|
|
41
43
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# OpenCode Zen
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 32 OpenCode Zen models through Mastra's model router. Authentication is handled automatically using the `OPENCODE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [OpenCode Zen documentation](https://opencode.ai/docs/zen).
|
|
6
6
|
|
|
@@ -62,8 +62,6 @@ for await (const chunk of stream) {
|
|
|
62
62
|
| `opencode/gpt-5.4-nano` | 400K | | | | | | $0.20 | $1 |
|
|
63
63
|
| `opencode/gpt-5.4-pro` | 1.1M | | | | | | $30 | $180 |
|
|
64
64
|
| `opencode/kimi-k2.5` | 262K | | | | | | $0.60 | $3 |
|
|
65
|
-
| `opencode/mimo-v2-omni-free` | 262K | | | | | | — | — |
|
|
66
|
-
| `opencode/mimo-v2-pro-free` | 1.0M | | | | | | — | — |
|
|
67
65
|
| `opencode/minimax-m2.5` | 205K | | | | | | $0.30 | $1 |
|
|
68
66
|
| `opencode/minimax-m2.5-free` | 205K | | | | | | — | — |
|
|
69
67
|
| `opencode/nemotron-3-super-free` | 205K | | | | | | — | — |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Poe
|
|
2
2
|
|
|
3
|
-
Access
|
|
3
|
+
Access 126 Poe models through Mastra's model router. Authentication is handled automatically using the `POE_API_KEY` environment variable.
|
|
4
4
|
|
|
5
5
|
Learn more in the [Poe documentation](https://creator.poe.com/docs/external-applications/openai-compatible-api).
|
|
6
6
|
|
|
@@ -55,6 +55,7 @@ for await (const chunk of stream) {
|
|
|
55
55
|
| `poe/elevenlabs/elevenlabs-music` | 2K | | | | | | — | — |
|
|
56
56
|
| `poe/elevenlabs/elevenlabs-v2.5-turbo` | 128K | | | | | | — | — |
|
|
57
57
|
| `poe/elevenlabs/elevenlabs-v3` | 128K | | | | | | — | — |
|
|
58
|
+
| `poe/fireworks-ai/kimi-k2.5-fw` | 262K | | | | | | — | — |
|
|
58
59
|
| `poe/google/gemini-2.0-flash` | 990K | | | | | | $0.10 | $0.42 |
|
|
59
60
|
| `poe/google/gemini-2.0-flash-lite` | 990K | | | | | | $0.05 | $0.21 |
|
|
60
61
|
| `poe/google/gemini-2.5-flash` | 1.1M | | | | | | $0.21 | $2 |
|
|
@@ -124,6 +125,7 @@ for await (const chunk of stream) {
|
|
|
124
125
|
| `poe/openai/gpt-5.2-instant` | 128K | | | | | | $2 | $13 |
|
|
125
126
|
| `poe/openai/gpt-5.2-pro` | 400K | | | | | | $19 | $150 |
|
|
126
127
|
| `poe/openai/gpt-5.3-codex` | 400K | | | | | | $2 | $13 |
|
|
128
|
+
| `poe/openai/gpt-5.3-codex-spark` | 128K | | | | | | — | — |
|
|
127
129
|
| `poe/openai/gpt-5.3-instant` | 128K | | | | | | $2 | $13 |
|
|
128
130
|
| `poe/openai/gpt-5.4` | 1.1M | | | | | | $2 | $14 |
|
|
129
131
|
| `poe/openai/gpt-5.4-mini` | 400K | | | | | | $0.68 | $4 |
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
# Channels
|
|
2
|
+
|
|
3
|
+
**Added in:** `@mastra/core@1.22.0`
|
|
4
|
+
|
|
5
|
+
Channels connect agents to messaging platforms. Configure them via the `channels` property on the `Agent` constructor. See the [Channels guide](https://mastra.ai/docs/agents/channels) for concepts and platform setup instructions.
|
|
6
|
+
|
|
7
|
+
## Usage example
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
import { Agent } from '@mastra/core/agent'
|
|
11
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
12
|
+
import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
13
|
+
|
|
14
|
+
export const supportAgent = new Agent({
|
|
15
|
+
id: 'support-agent',
|
|
16
|
+
name: 'Support Agent',
|
|
17
|
+
instructions: 'You are a helpful support assistant.',
|
|
18
|
+
model: 'openai/gpt-5.4',
|
|
19
|
+
channels: {
|
|
20
|
+
adapters: {
|
|
21
|
+
slack: createSlackAdapter(),
|
|
22
|
+
discord: createDiscordAdapter(),
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Parameters
|
|
29
|
+
|
|
30
|
+
**adapters** (`Record<string, Adapter | ChannelAdapterConfig>`): Platform adapters keyed by name (e.g. \`slack\`, \`discord\`). Pass an \`Adapter\` directly for defaults, or a \`ChannelAdapterConfig\` object to customize per-adapter options.
|
|
31
|
+
|
|
32
|
+
**handlers** (`ChannelHandlers`): Override default message handlers for DMs, mentions, and subscribed threads.
|
|
33
|
+
|
|
34
|
+
**inlineMedia** (`string[] | ((mimeType: string) => boolean)`): Controls which attachment types are sent as file parts to the model. Types that do not match are described as text summaries. Accepts an array of mime type globs or a predicate function. (Default: `['image/*']`)
|
|
35
|
+
|
|
36
|
+
**inlineLinks** (`InlineLinkEntry[]`): Promote URLs found in message text to file parts so the model can process linked content. Each entry matches a domain. Disabled by default.
|
|
37
|
+
|
|
38
|
+
**tools** (`boolean`): Include channel-specific tools (\`add\_reaction\`, \`remove\_reaction\`). Set to \`false\` for models that do not support function calling. (Default: `true`)
|
|
39
|
+
|
|
40
|
+
**state** (`StateAdapter`): State adapter for subscriptions and deduplication. Defaults to \`MastraStateAdapter\` backed by the Mastra instance storage. Channels require storage to be configured. (Default: `MastraStateAdapter (from Mastra storage)`)
|
|
41
|
+
|
|
42
|
+
**userName** (`string`): Bot display name shown in platform messages. Defaults to the agent's \`name\`, or \`'Mastra'\` if no name is set. (Default: `` agent's `name` ``)
|
|
43
|
+
|
|
44
|
+
**threadContext** (`{ maxMessages?: number }`): Fetch recent messages from the platform when the agent is first mentioned in a thread. Set \`maxMessages: 0\` to disable. Only applies to non-DM threads. (Default: `{ maxMessages: 10 }`)
|
|
45
|
+
|
|
46
|
+
**chatOptions** (`Omit<ChatConfig, 'adapters' | 'state' | 'userName'>`): Additional options passed directly to the \[Chat SDK]\(https\://chat-sdk.dev/docs/usage). Use for advanced configuration such as \`dedupeTtlMs\`, \`fallbackStreamingPlaceholderText\`, \`lockScope\`, and \`messageHistory\`.
|
|
47
|
+
|
|
48
|
+
## Per-adapter options
|
|
49
|
+
|
|
50
|
+
Wrap an adapter in a `ChannelAdapterConfig` object to set per-adapter options:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { Agent } from '@mastra/core/agent'
|
|
54
|
+
import { createDiscordAdapter } from '@chat-adapter/discord'
|
|
55
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
56
|
+
|
|
57
|
+
const agent = new Agent({
|
|
58
|
+
name: 'Example',
|
|
59
|
+
instructions: '...',
|
|
60
|
+
model: 'openai/gpt-5.4',
|
|
61
|
+
channels: {
|
|
62
|
+
adapters: {
|
|
63
|
+
discord: {
|
|
64
|
+
adapter: createDiscordAdapter(),
|
|
65
|
+
cards: false,
|
|
66
|
+
gateway: false,
|
|
67
|
+
},
|
|
68
|
+
slack: createSlackAdapter(), // Plain adapter uses defaults
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
})
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**adapter** (`Adapter`): The Chat SDK adapter instance for this platform.
|
|
75
|
+
|
|
76
|
+
**gateway** (`boolean`): Start a persistent Gateway WebSocket listener for receiving DMs, @mentions, and reactions. Set to \`false\` for serverless deployments that only need webhook-based interactions. (Default: `true`)
|
|
77
|
+
|
|
78
|
+
**cards** (`boolean`): Render tool calls as interactive rich cards with buttons. Set to \`false\` to use plain text formatting instead. When disabled and a tool requires approval, the agent uses \`autoResumeSuspendedTools\` to let the LLM decide based on conversation context. (Default: `true`)
|
|
79
|
+
|
|
80
|
+
**formatToolCall** (`(info: { toolName, args, result, isError? }) => PostableMessage | null`): Override how tool calls are rendered in the chat. Called once per tool invocation after the result is available. Return \`null\` to suppress the message entirely.
|
|
81
|
+
|
|
82
|
+
**formatError** (`(error: Error) => PostableMessage`): Override how errors are rendered in the chat. Return a user-friendly message instead of exposing the raw error. (Default: `"❌ Error: <error.message>"`)
|
|
83
|
+
|
|
84
|
+
## Handlers
|
|
85
|
+
|
|
86
|
+
Override built-in event handlers. Each handler can be:
|
|
87
|
+
|
|
88
|
+
- **Omitted**: uses the default Mastra handler (routes to `agent.stream` and posts the response)
|
|
89
|
+
- **`false`**: disables the handler entirely
|
|
90
|
+
- **A function** `(thread, message, defaultHandler) => Promise<void>`: wraps or replaces the default
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
import { Agent } from '@mastra/core/agent'
|
|
94
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
95
|
+
|
|
96
|
+
const agent = new Agent({
|
|
97
|
+
name: 'Custom Handler Agent',
|
|
98
|
+
instructions: '...',
|
|
99
|
+
model: 'openai/gpt-5.4',
|
|
100
|
+
channels: {
|
|
101
|
+
adapters: {
|
|
102
|
+
slack: createSlackAdapter(),
|
|
103
|
+
},
|
|
104
|
+
handlers: {
|
|
105
|
+
onMention: async (thread, message, defaultHandler) => {
|
|
106
|
+
console.log('Received mention:', message.text)
|
|
107
|
+
await defaultHandler(thread, message)
|
|
108
|
+
},
|
|
109
|
+
onDirectMessage: false,
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
**onDirectMessage** (`ChannelHandler | false`): Called when the bot receives a direct message.
|
|
116
|
+
|
|
117
|
+
**onMention** (`ChannelHandler | false`): Called when the bot is @mentioned in a channel or thread.
|
|
118
|
+
|
|
119
|
+
**onSubscribedMessage** (`ChannelHandler | false`): Called for messages in threads the agent has subscribed to.
|
|
120
|
+
|
|
121
|
+
The `ChannelHandler` function signature:
|
|
122
|
+
|
|
123
|
+
```typescript
|
|
124
|
+
type ChannelHandler = (
|
|
125
|
+
thread: Thread,
|
|
126
|
+
message: Message,
|
|
127
|
+
defaultHandler: (thread: Thread, message: Message) => Promise<void>,
|
|
128
|
+
) => Promise<void>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Inline media
|
|
132
|
+
|
|
133
|
+
Controls which attachment types (images, video, PDFs, etc.) are sent as file parts to the model. Types that do not match are described as text summaries so the agent knows about the file without crashing models that reject unsupported types.
|
|
134
|
+
|
|
135
|
+
Supported glob patterns:
|
|
136
|
+
|
|
137
|
+
| Pattern | Matches |
|
|
138
|
+
| ----------------- | ------------------------------------------------- |
|
|
139
|
+
| `image/*` | All image types (`image/png`, `image/jpeg`, etc.) |
|
|
140
|
+
| `video/*` | All video types |
|
|
141
|
+
| `*` or `*/*` | All types |
|
|
142
|
+
| `application/pdf` | Exact type match |
|
|
143
|
+
|
|
144
|
+
For platforms with private CDNs (e.g. Slack), attachments are fetched with authenticated credentials from the Chat SDK. For platforms with public CDNs (e.g. Discord), the URL is passed directly to the model.
|
|
145
|
+
|
|
146
|
+
## Inline links
|
|
147
|
+
|
|
148
|
+
Promotes URLs found in message text to file parts so the model can process linked content instead of seeing raw URL text. Each entry can be a string (domain pattern) or an object with a forced mime type.
|
|
149
|
+
|
|
150
|
+
**String entries** match a domain and perform a HEAD request to detect the Content-Type. The resolved type is checked against `inlineMedia` and only matching types become file parts.
|
|
151
|
+
|
|
152
|
+
**Object entries** match a domain and force a specific mime type, skipping the HEAD request and bypassing the `inlineMedia` check. This is useful for sites like YouTube where a HEAD request returns `text/html`, but the model treats the URL as video content.
|
|
153
|
+
|
|
154
|
+
```typescript
|
|
155
|
+
type InlineLinkEntry =
|
|
156
|
+
| string // Domain pattern (HEAD determines mime type)
|
|
157
|
+
| { match: string; mimeType: string } // Domain + forced mime type (skips HEAD)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Related
|
|
161
|
+
|
|
162
|
+
- [Channels guide](https://mastra.ai/docs/agents/channels) — concepts, quickstart, and platform setup
|
|
163
|
+
- [Agent class](https://mastra.ai/reference/agents/agent) — constructor parameters and methods
|
|
164
|
+
- [Chat SDK adapters](https://chat-sdk.dev/adapters) — adapter configuration and platform setup
|
package/.docs/reference/index.md
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
The Reference section provides documentation of Mastra's API, including parameters, types and usage examples.
|
|
4
4
|
|
|
5
5
|
- [Agent Class](https://mastra.ai/reference/agents/agent)
|
|
6
|
+
- [Channels](https://mastra.ai/reference/agents/channels)
|
|
6
7
|
- [.generate()](https://mastra.ai/reference/agents/generate)
|
|
7
8
|
- [.generateLegacy()](https://mastra.ai/reference/agents/generateLegacy)
|
|
8
9
|
- [.getDefaultGenerateOptionsLegacy()](https://mastra.ai/reference/agents/getDefaultGenerateOptions)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.21-alpha.4
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`cb15509`](https://github.com/mastra-ai/mastra/commit/cb15509b58f6a83e11b765c945082afc027db972), [`80c5668`](https://github.com/mastra-ai/mastra/commit/80c5668e365470d3a96d3e953868fd7a643ff67c), [`3d478c1`](https://github.com/mastra-ai/mastra/commit/3d478c1e13f17b80f330ac49d7aa42ef929b93ff), [`6039f17`](https://github.com/mastra-ai/mastra/commit/6039f176f9c457304825ff1df8c83b8e457376c0), [`06b928d`](https://github.com/mastra-ai/mastra/commit/06b928dfc2f5630d023467476cc5919dfa858d0a), [`6a8d984`](https://github.com/mastra-ai/mastra/commit/6a8d9841f2933456ee1598099f488d742b600054)]:
|
|
8
|
+
- @mastra/core@1.22.0-alpha.2
|
|
9
|
+
|
|
3
10
|
## 1.1.21-alpha.2
|
|
4
11
|
|
|
5
12
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp-docs-server",
|
|
3
|
-
"version": "1.1.21-alpha.
|
|
3
|
+
"version": "1.1.21-alpha.6",
|
|
4
4
|
"description": "MCP server for accessing Mastra.ai documentation, changelogs, and news.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"jsdom": "^26.1.0",
|
|
30
30
|
"local-pkg": "^1.1.2",
|
|
31
31
|
"zod": "^4.3.6",
|
|
32
|
-
"@mastra/core": "1.22.0-alpha.
|
|
32
|
+
"@mastra/core": "1.22.0-alpha.2",
|
|
33
33
|
"@mastra/mcp": "^1.4.1"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"tsx": "^4.21.0",
|
|
47
47
|
"typescript": "^5.9.3",
|
|
48
48
|
"vitest": "4.0.18",
|
|
49
|
+
"@internal/lint": "0.0.78",
|
|
49
50
|
"@internal/types-builder": "0.0.53",
|
|
50
|
-
"@mastra/core": "1.22.0-alpha.
|
|
51
|
-
"@internal/lint": "0.0.78"
|
|
51
|
+
"@mastra/core": "1.22.0-alpha.2"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|