@mastra/mcp-docs-server 1.2.7-alpha.10 → 1.2.7-alpha.3

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 (157) hide show
  1. package/.docs/docs/agent-builder/overview.md +3 -4
  2. package/.docs/docs/agent-builder/skill-registries.md +3 -1
  3. package/.docs/docs/agent-controller/overview.md +2 -3
  4. package/.docs/docs/agent-controller/session.md +3 -1
  5. package/.docs/docs/agents/a2a.md +1 -2
  6. package/.docs/docs/agents/channels.md +225 -0
  7. package/.docs/docs/agents/code-mode.md +1 -1
  8. package/.docs/docs/agents/file-based-agents.md +297 -0
  9. package/.docs/docs/agents/guardrails.md +9 -10
  10. package/.docs/docs/agents/overview.md +4 -4
  11. package/.docs/docs/agents/skills.md +5 -3
  12. package/.docs/docs/agents/structured-output.md +1 -1
  13. package/.docs/docs/agents/supervisor-agents.md +4 -3
  14. package/.docs/docs/agents/using-tools.md +4 -2
  15. package/.docs/docs/browser/agent-browser.md +3 -1
  16. package/.docs/docs/browser/browser-viewer.md +3 -1
  17. package/.docs/docs/browser/overview.md +1 -2
  18. package/.docs/docs/browser/stagehand.md +1 -1
  19. package/.docs/docs/deployment/mastra-server.md +4 -2
  20. package/.docs/docs/editor/overview.md +6 -2
  21. package/.docs/docs/editor/prompts.md +1 -1
  22. package/.docs/docs/editor/tools.md +3 -1
  23. package/.docs/docs/evals/custom-scorers.md +3 -1
  24. package/.docs/docs/evals/datasets/overview.md +5 -4
  25. package/.docs/docs/evals/datasets/running-experiments.md +2 -4
  26. package/.docs/docs/evals/evals-with-memory.md +3 -1
  27. package/.docs/docs/evals/gates-and-verdicts.md +3 -1
  28. package/.docs/docs/evals/overview.md +1 -4
  29. package/.docs/docs/evals/quick-checks.md +3 -1
  30. package/.docs/docs/long-running-agents/background-tasks.md +1 -1
  31. package/.docs/docs/long-running-agents/durable-agents.md +5 -3
  32. package/.docs/docs/long-running-agents/goals.md +3 -1
  33. package/.docs/docs/long-running-agents/signal-providers.md +3 -1
  34. package/.docs/docs/long-running-agents/signals.md +22 -11
  35. package/.docs/docs/mastra-platform/observability.md +1 -5
  36. package/.docs/docs/mcp/mcp-apps.md +3 -3
  37. package/.docs/docs/mcp/overview.md +10 -6
  38. package/.docs/docs/memory/observational-memory.md +1 -2
  39. package/.docs/docs/memory/overview.md +4 -6
  40. package/.docs/docs/memory/semantic-recall.md +1 -1
  41. package/.docs/docs/memory/working-memory.md +3 -3
  42. package/.docs/docs/observability/integrations/exporters/mastra-platform.md +3 -1
  43. package/.docs/docs/observability/logging.md +1 -1
  44. package/.docs/docs/observability/tracing/overview.md +1 -1
  45. package/.docs/docs/server/auth/auth0.md +1 -1
  46. package/.docs/docs/server/auth/better-auth.md +2 -2
  47. package/.docs/docs/server/auth/clerk.md +1 -1
  48. package/.docs/docs/server/auth/firebase.md +1 -1
  49. package/.docs/docs/server/auth/google.md +2 -2
  50. package/.docs/docs/server/auth/jwt.md +2 -2
  51. package/.docs/docs/server/auth/okta.md +2 -2
  52. package/.docs/docs/server/auth/workos.md +1 -1
  53. package/.docs/docs/server/mastra-client.md +1 -1
  54. package/.docs/docs/server/mastra-server.md +1 -1
  55. package/.docs/docs/server/pubsub.md +1 -1
  56. package/.docs/docs/server/request-context.md +4 -4
  57. package/.docs/docs/server/server-adapters.md +8 -8
  58. package/.docs/docs/studio/auth.md +3 -1
  59. package/.docs/docs/studio/overview.md +1 -1
  60. package/.docs/docs/voice/livekit.md +3 -100
  61. package/.docs/docs/workflows/agents-and-tools.md +5 -3
  62. package/.docs/docs/workflows/control-flow.md +3 -1
  63. package/.docs/docs/workflows/overview.md +7 -6
  64. package/.docs/docs/workspace/overview.md +1 -2
  65. package/.docs/docs/workspace/sandbox.md +0 -2
  66. package/.docs/guides/build-your-ui/assistant-ui.md +1 -1
  67. package/.docs/guides/build-your-ui/copilotkit/overview.md +1 -1
  68. package/.docs/guides/concepts/streaming.md +3 -3
  69. package/.docs/guides/getting-started/quickstart.md +1 -3
  70. package/.docs/guides/guide/chef-michel.md +2 -0
  71. package/.docs/guides/guide/slack-assistant.md +2 -2
  72. package/.docs/guides/guide/stock-agent.md +2 -0
  73. package/.docs/models/environment-variables.md +0 -3
  74. package/.docs/models/gateways/netlify.md +1 -4
  75. package/.docs/models/gateways/openrouter.md +6 -10
  76. package/.docs/models/gateways/vercel.md +1 -7
  77. package/.docs/models/index.md +1 -1
  78. package/.docs/models/providers/google.md +1 -2
  79. package/.docs/models/providers/llmgateway.md +181 -184
  80. package/.docs/models/providers/nano-gpt.md +2 -2
  81. package/.docs/models/providers/neon.md +29 -40
  82. package/.docs/models/providers/openai.md +1 -5
  83. package/.docs/models/providers/opencode.md +1 -2
  84. package/.docs/models/providers/poolside.md +5 -6
  85. package/.docs/models/providers/routing-run.md +34 -20
  86. package/.docs/models/providers/the-grid-ai.md +3 -3
  87. package/.docs/models/providers/wandb.md +14 -21
  88. package/.docs/models/providers/xai.md +1 -2
  89. package/.docs/models/providers.md +0 -3
  90. package/.docs/reference/agents/channels.md +2 -2
  91. package/.docs/reference/channels/channel-provider.md +1 -1
  92. package/.docs/reference/channels/slack-provider.md +2 -2
  93. package/.docs/reference/cli/mastra.md +10 -117
  94. package/.docs/reference/evals/create-scorer.md +0 -8
  95. package/.docs/reference/index.md +0 -15
  96. package/.docs/reference/memory/memory-class.md +1 -1
  97. package/.docs/reference/memory/serialized-memory-config.md +1 -1
  98. package/.docs/reference/project-structure.md +1 -1
  99. package/.docs/reference/pubsub/lease-provider.md +1 -1
  100. package/.docs/reference/server/express-adapter.md +3 -1
  101. package/.docs/reference/server/fastify-adapter.md +3 -1
  102. package/.docs/reference/server/hono-adapter.md +3 -1
  103. package/.docs/reference/server/koa-adapter.md +3 -1
  104. package/.docs/reference/server/nestjs-adapter.md +3 -1
  105. package/.docs/reference/storage/clickhouse.md +0 -32
  106. package/.docs/reference/storage/composite.md +1 -27
  107. package/.docs/reference/storage/retention.md +0 -11
  108. package/.docs/reference/tools/mcp-client.md +0 -22
  109. package/.docs/reference/tools/mcp-server.md +4 -161
  110. package/.docs/reference/voice/livekit.md +8 -272
  111. package/.docs/reference/workspace/agentcore-runtime-sandbox.md +3 -1
  112. package/.docs/reference/workspace/agentfs-filesystem.md +3 -1
  113. package/.docs/reference/workspace/apple-container-sandbox.md +3 -1
  114. package/.docs/reference/workspace/archil-filesystem.md +3 -1
  115. package/.docs/reference/workspace/azure-blob-filesystem.md +3 -1
  116. package/.docs/reference/workspace/blaxel-sandbox.md +3 -1
  117. package/.docs/reference/workspace/daytona-sandbox.md +3 -1
  118. package/.docs/reference/workspace/docker-sandbox.md +3 -1
  119. package/.docs/reference/workspace/e2b-sandbox.md +3 -1
  120. package/.docs/reference/workspace/files-sdk-filesystem.md +3 -1
  121. package/.docs/reference/workspace/gcs-filesystem.md +3 -1
  122. package/.docs/reference/workspace/google-drive-filesystem.md +3 -1
  123. package/.docs/reference/workspace/local-filesystem.md +3 -1
  124. package/.docs/reference/workspace/local-sandbox.md +3 -1
  125. package/.docs/reference/workspace/modal-sandbox.md +3 -1
  126. package/.docs/reference/workspace/railway-sandbox.md +3 -1
  127. package/.docs/reference/workspace/s3-filesystem.md +3 -1
  128. package/.docs/reference/workspace/vercel-sandbox.md +7 -5
  129. package/.docs/reference/workspace/vercel-serverless.md +3 -1
  130. package/CHANGELOG.md +0 -22
  131. package/package.json +5 -5
  132. package/.docs/docs/capabilities/channels/discord.md +0 -98
  133. package/.docs/docs/capabilities/channels/other-adapters.md +0 -68
  134. package/.docs/docs/capabilities/channels/overview.md +0 -255
  135. package/.docs/docs/capabilities/channels/slack.md +0 -225
  136. package/.docs/docs/capabilities/channels/teams.md +0 -100
  137. package/.docs/docs/capabilities/channels/telegram.md +0 -98
  138. package/.docs/docs/capabilities/channels/whatsapp.md +0 -99
  139. package/.docs/docs/getting-started/file-based-agents.md +0 -114
  140. package/.docs/models/providers/crossmodel.md +0 -109
  141. package/.docs/models/providers/meta.md +0 -101
  142. package/.docs/models/providers/zenifra.md +0 -73
  143. package/.docs/reference/file-based-agents/config.md +0 -97
  144. package/.docs/reference/file-based-agents/instructions.md +0 -54
  145. package/.docs/reference/file-based-agents/memory.md +0 -58
  146. package/.docs/reference/file-based-agents/observability.md +0 -32
  147. package/.docs/reference/file-based-agents/processors.md +0 -56
  148. package/.docs/reference/file-based-agents/server.md +0 -37
  149. package/.docs/reference/file-based-agents/skills.md +0 -56
  150. package/.docs/reference/file-based-agents/storage.md +0 -30
  151. package/.docs/reference/file-based-agents/studio.md +0 -56
  152. package/.docs/reference/file-based-agents/subagents.md +0 -123
  153. package/.docs/reference/file-based-agents/tools.md +0 -63
  154. package/.docs/reference/file-based-agents/workflows.md +0 -52
  155. package/.docs/reference/file-based-agents/workspace.md +0 -74
  156. package/.docs/reference/memory/summarizeConversation.md +0 -99
  157. package/.docs/reference/memory/summarizeThread.md +0 -93
@@ -1,98 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Discord
4
-
5
- Discord channels let a Mastra agent receive Discord interactions and bot messages. Mastra handles the agent wiring and webhook route; the Chat SDK Discord adapter docs cover Discord application setup, bot permissions, and Gateway behavior.
6
-
7
- ## Install the adapter
8
-
9
- Install the Discord adapter from the Chat SDK:
10
-
11
- **npm**:
12
-
13
- ```bash
14
- npm install @chat-adapter/discord
15
- ```
16
-
17
- **pnpm**:
18
-
19
- ```bash
20
- pnpm add @chat-adapter/discord
21
- ```
22
-
23
- **Yarn**:
24
-
25
- ```bash
26
- yarn add @chat-adapter/discord
27
- ```
28
-
29
- **Bun**:
30
-
31
- ```bash
32
- bun add @chat-adapter/discord
33
- ```
34
-
35
- ## Agent configuration
36
-
37
- Add `createDiscordAdapter()` to the agent's `channels.adapters` object:
38
-
39
- ```typescript
40
- import { Agent } from '@mastra/core/agent'
41
- import { createDiscordAdapter } from '@chat-adapter/discord'
42
-
43
- export const discordAgent = new Agent({
44
- id: 'discord-agent',
45
- name: 'Discord Agent',
46
- instructions: 'Answer questions and help with tasks in Discord.',
47
- model: 'openai/gpt-5.5',
48
- channels: {
49
- adapters: {
50
- discord: createDiscordAdapter(),
51
- },
52
- },
53
- })
54
- ```
55
-
56
- Register the agent on the Mastra instance:
57
-
58
- ```typescript
59
- import { Mastra } from '@mastra/core'
60
- import { discordAgent } from './agents/discord-agent'
61
-
62
- export const mastra = new Mastra({
63
- agents: { discordAgent },
64
- })
65
- ```
66
-
67
- ## Adapter setup
68
-
69
- Follow the [Chat SDK Discord adapter docs](https://chat-sdk.dev/adapters/official/discord) for Discord-specific setup, including application creation, bot tokens, interaction endpoints, permissions, and Gateway behavior.
70
-
71
- The adapter reads Discord credentials from environment variables such as:
72
-
73
- ```bash
74
- DISCORD_BOT_TOKEN=your-discord-bot-token
75
- DISCORD_PUBLIC_KEY=your-discord-application-public-key
76
- DISCORD_APPLICATION_ID=your-discord-application-id
77
- ```
78
-
79
- ## Webhook URL
80
-
81
- Mastra generates the Discord webhook route from the agent ID and adapter key:
82
-
83
- ```text
84
- /api/agents/discord-agent/channels/discord/webhook
85
- ```
86
-
87
- Use your public Mastra server URL as the base URL:
88
-
89
- ```text
90
- https://your-app.example.com/api/agents/discord-agent/channels/discord/webhook
91
- ```
92
-
93
- Use this URL anywhere the Discord adapter docs ask for the interactions endpoint or webhook URL. Discord regular message events may require Gateway setup outside the generated webhook route; follow the Chat SDK adapter docs for that path.
94
-
95
- ## Related
96
-
97
- - [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
98
- - [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
@@ -1,68 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # More
4
-
5
- Mastra channels use Chat SDK adapters, so the pages in this section are not the full list of supported platforms. Use any Chat SDK platform adapter that exports an adapter factory compatible with `channels.adapters`.
6
-
7
- ## Adapter catalog
8
-
9
- The [Chat SDK adapter catalog](https://chat-sdk.dev/adapters) is the canonical source for available adapters. The list below is only a snapshot and may not always be up to date.
10
-
11
- At the time of writing, Chat SDK lists adapters for:
12
-
13
- - AgentPhone
14
- - Baileys WhatsApp
15
- - Discord
16
- - Google Chat
17
- - GitHub
18
- - iMessage
19
- - Kapso
20
- - Lark / Feishu
21
- - Linear
22
- - Liveblocks
23
- - Matrix
24
- - Messenger
25
- - Mattermost
26
- - Novu
27
- - Resend
28
- - Sendblue
29
- - Telegram
30
- - Twilio
31
- - Velt
32
- - Web
33
- - Webex
34
- - WeChat
35
- - WhatsApp Business Cloud
36
- - X
37
- - Zalo
38
- - Zernio
39
-
40
- Check the adapter's docs for its package name, credential variables, webhook requirements, and platform-specific behavior.
41
-
42
- ## Use the same Mastra wiring
43
-
44
- The Mastra side of each Chat SDK adapter is similar: install the adapter package, add its adapter factory to `channels.adapters`, configure platform credentials, and point the platform webhook to the generated Mastra route.
45
-
46
- Use one of the platform pages in this section as a reference for the Mastra wiring:
47
-
48
- - [Slack](https://mastra.ai/docs/capabilities/channels/slack)
49
- - [Microsoft Teams](https://mastra.ai/docs/capabilities/channels/teams)
50
- - [Discord](https://mastra.ai/docs/capabilities/channels/discord)
51
- - [Telegram](https://mastra.ai/docs/capabilities/channels/telegram)
52
- - [WhatsApp](https://mastra.ai/docs/capabilities/channels/whatsapp)
53
-
54
- ## What to check in adapter docs
55
-
56
- Before wiring a new adapter into Mastra, check the adapter docs for:
57
-
58
- - Credential environment variables.
59
- - Required platform permissions or scopes.
60
- - Webhook verification behavior.
61
- - Whether the platform needs separate routes for setup, events, or interactions.
62
- - Whether regular messages require long-running listeners or polling.
63
- - Attachment, card, and rich message support.
64
-
65
- ## Related
66
-
67
- - [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
68
- - [Channels reference](https://mastra.ai/reference/agents/channels)
@@ -1,255 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Channels overview
4
-
5
- **Added in:** `@mastra/core@1.22.0`
6
-
7
- Channels connect agents to messaging and collaboration platforms like Slack, Microsoft Teams, Discord, Telegram, WhatsApp, GitHub, and Linear. When a user sends a message or comment on a platform, the agent receives it, processes it through the normal agent pipeline, and streams the response back to the conversation. Mastra uses [Chat SDK](https://chat-sdk.dev/) for this channel layer.
8
-
9
- Start with the page for your platform:
10
-
11
- - [Slack](https://mastra.ai/docs/capabilities/channels/slack)
12
- - [Microsoft Teams](https://mastra.ai/docs/capabilities/channels/teams)
13
- - [Discord](https://mastra.ai/docs/capabilities/channels/discord)
14
- - [Telegram](https://mastra.ai/docs/capabilities/channels/telegram)
15
- - [WhatsApp](https://mastra.ai/docs/capabilities/channels/whatsapp)
16
-
17
- [More](https://mastra.ai/docs/capabilities/channels/other-adapters) lists additional platforms. Mastra channels work with compatible [Chat SDK adapters](https://chat-sdk.dev/adapters) beyond the platforms listed here, and the same Mastra configuration pattern applies across adapters.
18
-
19
- ## When to use channels
20
-
21
- Use channels when an agent needs to:
22
-
23
- - Meet users where they already talk or work.
24
- - Respond in chat platforms like Slack, Microsoft Teams, Discord, Telegram, and WhatsApp.
25
- - Support multiplayer agents where several people interact with the same agent in a shared channel or thread.
26
- - Integrate with collaboration workflows like GitHub issues, pull request threads, and Linear comments.
27
-
28
- ## Configure an agent
29
-
30
- Channels use Chat SDK adapters and follow the same Mastra-side pattern: create a channel adapter and add it to the agent.
31
-
32
- ```typescript
33
- import { Agent } from '@mastra/core/agent'
34
- import { createSlackAdapter } from '@chat-adapter/slack'
35
-
36
- export const yourAgent = new Agent({
37
- id: 'your-agent',
38
- name: 'Your Agent',
39
- instructions: 'You are a helpful assistant.',
40
- model: 'openai/gpt-5.5',
41
- channels: {
42
- adapters: {
43
- slack: createSlackAdapter(),
44
- },
45
- },
46
- })
47
- ```
48
-
49
- > **Note:** Channel adapters require provider-specific environment variables for credentials and request verification, such as bot tokens, signing secrets, app IDs, and webhook verification tokens. Check the guide for your platform or the [Chat SDK adapter catalog](https://chat-sdk.dev/adapters) for the exact variable names.
50
-
51
- We recommend configuring [storage](https://mastra.ai/docs/storage/overview) for channels. Storage lets Mastra persist channel state, thread subscriptions, tool approvals, and memory across restarts:
52
-
53
- ```typescript
54
- import { Mastra } from '@mastra/core'
55
- import { LibSQLStore } from '@mastra/libsql'
56
- import { yourAgent } from './agents/your-agent'
57
-
58
- export const mastra = new Mastra({
59
- agents: { yourAgent },
60
- storage: new LibSQLStore({
61
- url: process.env.DATABASE_URL,
62
- }),
63
- })
64
- ```
65
-
66
- ## Webhook routes
67
-
68
- Platforms send channel activity to Mastra through webhooks. A webhook is an HTTP endpoint that the platform calls when something happens, such as a new message, a mention, or a user selecting "Approve" on an interactive tool approval card. This is how your agent receives a new message, starts processing it, and responds in the same channel.
69
-
70
- Mastra registers a webhook route for each configured adapter and handles the request for you:
71
-
72
- ```text
73
- /api/agents/<AGENT_ID>/channels/<PLATFORM>/webhook
74
- ```
75
-
76
- For example, a Slack adapter on an agent with the `your-agent` ID uses:
77
-
78
- ```text
79
- /api/agents/your-agent/channels/slack/webhook
80
- ```
81
-
82
- Point the platform's webhook, event, or interactions URL to this path. Follow the guide for your platform or the [Chat SDK docs](https://chat-sdk.dev/adapters).
83
-
84
- During local development, platform webhooks need a public URL to reach your local server. Use a tunnel like [cloudflared](https://github.com/cloudflare/cloudflared) or [ngrok](https://ngrok.com/) to expose your server, `localhost:4111` by default:
85
-
86
- **npm**:
87
-
88
- ```bash
89
- npx cloudflared tunnel --url http://localhost:4111
90
- ```
91
-
92
- **pnpm**:
93
-
94
- ```bash
95
- pnpm dlx cloudflared tunnel --url http://localhost:4111
96
- ```
97
-
98
- **Yarn**:
99
-
100
- ```bash
101
- yarn dlx cloudflared tunnel --url http://localhost:4111
102
- ```
103
-
104
- **Bun**:
105
-
106
- ```bash
107
- bun x cloudflared tunnel --url http://localhost:4111
108
- ```
109
-
110
- Use the generated public URL as the base URL for webhook paths, for example `https://abc123.trycloudflare.com/api/agents/your-agent/channels/slack/webhook`.
111
-
112
- > **Note:** Tunnel URLs are for local development. After you deploy the Mastra server, update the platform's webhook, event, or interactions URL to your production URL.
113
-
114
- ## Thread context
115
-
116
- 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.
117
-
118
- 1. On the first mention in a thread, the agent fetches recent messages from the platform.
119
- 2. These messages are prepended to the user's message as conversation context.
120
- 3. After responding, the agent subscribes to the thread and has full history through Mastra memory.
121
- 4. Subsequent messages in that thread don't re-fetch from the platform.
122
-
123
- Set `threadContext: { maxMessages: 0 }` to disable this behavior. This only applies to non-direct message threads.
124
-
125
- Mastra also adds a short system message that tells the agent which channel and platform the request came from, such as whether the message came from a direct message or public channel. Set `threadContext: { addSystemMessage: false }` to skip it.
126
-
127
- ## Tool approval
128
-
129
- Tools with `requireApproval: true` render as interactive cards with Approve and Deny buttons:
130
-
131
- ```typescript
132
- import { promises as fs } from 'node:fs'
133
- import { createTool } from '@mastra/core/tools'
134
- import { z } from 'zod'
135
-
136
- export const deleteFile = createTool({
137
- id: 'delete-file',
138
- description: 'Delete a file from the system',
139
- inputSchema: z.object({
140
- path: z.string().describe('Path to the file to delete'),
141
- }),
142
- requireApproval: true,
143
- execute: async ({ path }) => {
144
- await fs.unlink(path)
145
- return { deleted: path }
146
- },
147
- })
148
- ```
149
-
150
- When the agent calls this tool, users see a card with the tool name, arguments, and Approve and Deny actions. The tool only executes after approval.
151
-
152
- Set `toolDisplay: 'text'` on an adapter to render tool calls as plain text instead of interactive cards. In `'hidden'` mode, `autoResumeSuspendedTools` can resume suspended tools when a later user message arrives on the same thread. This requires memory. Hidden mode only suppresses the approval buttons.
153
-
154
- ## Multi-user awareness
155
-
156
- In group conversations, Mastra prefixes each message with the sender's name and platform ID so the agent can distinguish between speakers:
157
-
158
- ```text
159
- [Alice (@U123ABC)]: Can you help me with this?
160
- [Bob (@U456DEF)]: I have a question too.
161
- ```
162
-
163
- ## Multimodal content
164
-
165
- Models like Gemini can process images, video, and audio natively. Combine `inlineMedia` and `inlineLinks` to let users share rich content with your agent across platforms:
166
-
167
- ```typescript
168
- import { Agent } from '@mastra/core/agent'
169
- import { createDiscordAdapter } from '@chat-adapter/discord'
170
-
171
- export const visionAgent = new Agent({
172
- id: 'vision-agent',
173
- name: 'Vision Agent',
174
- instructions: 'You can see images, watch videos, and listen to audio.',
175
- model: 'google/gemini-2.5-flash',
176
- channels: {
177
- adapters: {
178
- discord: createDiscordAdapter(),
179
- },
180
- inlineMedia: ['image/*', 'video/*', 'audio/*'],
181
- inlineLinks: [
182
- { match: 'youtube.com', mimeType: 'video/*' },
183
- { match: 'youtu.be', mimeType: 'video/*' },
184
- 'imgur.com',
185
- ],
186
- },
187
- })
188
- ```
189
-
190
- With this configuration:
191
-
192
- - A user uploads a screenshot and the agent describes what it sees.
193
- - A user uploads an `.mp4` clip and the agent summarizes the video.
194
- - A user pastes a YouTube link and the agent watches and discusses the video.
195
- - A user pastes an imgur link and the agent sees the image directly.
196
-
197
- By default, only images are sent inline (`inlineMedia: ['image/*']`). Unsupported types are described as text summaries so the agent knows about the file without failing on models that reject them. 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.
198
-
199
- ## Serverless deployment
200
-
201
- On serverless platforms like Vercel, each request runs in a separate, short-lived instance. Channels need two things to work reliably in that environment: a way to keep the function alive while the agent responds, and a shared pub/sub so instances can coordinate.
202
-
203
- ### Keep the function alive with `waitUntil`
204
-
205
- A channel webhook returns a `200` response right away, then the agent runs in the background to post its reply. On most serverless platforms the function is frozen as soon as it responds, which stops the run before the agent answers. Pass a `waitUntil` function so the platform keeps the instance alive until the run finishes.
206
-
207
- On Vercel, pass `waitUntil` from `@vercel/functions`:
208
-
209
- ```typescript
210
- import { Agent } from '@mastra/core/agent'
211
- import { createSlackAdapter } from '@chat-adapter/slack'
212
- import { waitUntil } from '@vercel/functions'
213
-
214
- export const yourAgent = new Agent({
215
- id: 'your-agent',
216
- name: 'Your Agent',
217
- instructions: 'You are a helpful assistant.',
218
- model: 'openai/gpt-5.5',
219
- channels: {
220
- adapters: {
221
- slack: createSlackAdapter(),
222
- },
223
- waitUntil,
224
- },
225
- })
226
- ```
227
-
228
- Vercel and AWS Lambda require `waitUntil`, since they freeze the function as soon as the response is sent. Cloudflare Workers and Netlify Functions are detected automatically from the request context, so they don't need it. For runtimes where `waitUntil` lives on the request context but isn't detected automatically, use `resolveWaitUntil`. See the [Channels reference](https://mastra.ai/reference/agents/channels) for details.
229
-
230
- ### Coordinate instances with a shared pub/sub
231
-
232
- Channels route messages through the agent's [signal pipeline](https://mastra.ai/docs/long-running-agents/signals), and each run acquires a lease on its thread so one run owns the conversation at a time. The default in-memory pub/sub can't cross instance boundaries, so on serverless a follow-up message can land on a different instance than the one running the agent. Without a shared pub/sub, that instance can't reach the active run and starts its own, leaving the original run untouched and the thread processed twice.
233
-
234
- Configure a shared pub/sub backed by Redis Streams on the `Mastra` instance so leases and signals coordinate across instances:
235
-
236
- ```typescript
237
- import { Mastra } from '@mastra/core'
238
- import { RedisStreamsPubSub } from '@mastra/redis-streams'
239
- import { yourAgent } from './agents/your-agent'
240
-
241
- export const mastra = new Mastra({
242
- agents: { yourAgent },
243
- pubsub: new RedisStreamsPubSub({
244
- url: process.env.REDIS_URL,
245
- keyPrefix: 'mastra:my-app',
246
- }),
247
- })
248
- ```
249
-
250
- Vercel's managed Redis integration and Upstash Redis both work well. For more on when a distributed pub/sub is needed, see the [PubSub guide](https://mastra.ai/docs/server/pubsub) and the [`RedisStreamsPubSub` reference](https://mastra.ai/reference/pubsub/redis-streams).
251
-
252
- ## Related
253
-
254
- - [Channels reference](https://mastra.ai/reference/agents/channels)
255
- - 📹 [Mastra channels workshop](https://www.youtube.com/watch?v=E9KFsZEnQO8\&t=5s)
@@ -1,225 +0,0 @@
1
- > Discover all available pages from the documentation index: https://mastra.ai/llms.txt
2
-
3
- # Slack
4
-
5
- Add your agent to Slack so people can message it in shared channel threads or direct messages. When someone sends a message, Mastra runs your agent through the normal agent pipeline and streams the response back to Slack. The Slack adapter handles Slack AI indicators and interactive cards for you.
6
-
7
- ## Installation
8
-
9
- Install the Slack adapter from the Chat SDK:
10
-
11
- **npm**:
12
-
13
- ```bash
14
- npm install @chat-adapter/slack
15
- ```
16
-
17
- **pnpm**:
18
-
19
- ```bash
20
- pnpm add @chat-adapter/slack
21
- ```
22
-
23
- **Yarn**:
24
-
25
- ```bash
26
- yarn add @chat-adapter/slack
27
- ```
28
-
29
- **Bun**:
30
-
31
- ```bash
32
- bun add @chat-adapter/slack
33
- ```
34
-
35
- Add `createSlackAdapter()` to the agent's `channels.adapters` object:
36
-
37
- ```typescript
38
- import { Agent } from '@mastra/core/agent'
39
- import { createSlackAdapter } from '@chat-adapter/slack'
40
-
41
- export const yourAgent = new Agent({
42
- id: 'your-agent',
43
- name: 'Your Agent',
44
- instructions: 'Help people plan tasks, answer questions, and coordinate work in Slack.',
45
- model: 'anthropic/claude-opus-4-7',
46
- channels: {
47
- adapters: {
48
- slack: createSlackAdapter(),
49
- },
50
- },
51
- })
52
- ```
53
-
54
- ## Create a Slack app
55
-
56
- To connect your agent, create a Slack app in the workspace where you want it to run. The Slack app controls how your agent appears in Slack, what it can do, and which events it receives.
57
-
58
- This guide uses a [manifest](https://docs.slack.dev/app-manifests/configuring-apps-with-app-manifests/#creating_manifests): a configuration file that creates the Slack app settings for you. This is the fastest path when you are adding your agent to your own workspace. It doesn't cover the platform OAuth flow where other workspaces install your agent.
59
-
60
- Create the Slack app from a manifest:
61
-
62
- 1. Open [api.slack.com/apps](https://api.slack.com/apps).
63
- 2. Select **Create an app**.
64
- 3. Select **From a manifest**.
65
- 4. Choose the workspace where the agent should run.
66
- 5. Paste this manifest, then select **Create**:
67
-
68
- ```yaml
69
- display_information:
70
- name: mastra-agent
71
- features:
72
- app_home:
73
- home_tab_enabled: false
74
- messages_tab_enabled: true
75
- messages_tab_read_only_enabled: false
76
- bot_user:
77
- display_name: mastra-agent
78
- always_online: true
79
- oauth_config:
80
- scopes:
81
- bot:
82
- - im:write
83
- - app_mentions:read
84
- - channels:history
85
- - channels:read
86
- - chat:write
87
- - users:read
88
- - im:read
89
- - im:history
90
- pkce_enabled: false
91
- settings:
92
- event_subscriptions:
93
- request_url: https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
94
- bot_events:
95
- - app_mention
96
- - message.channels
97
- - message.im
98
- interactivity:
99
- is_enabled: true
100
- request_url: https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
101
- org_deploy_enabled: false
102
- socket_mode_enabled: false
103
- token_rotation_enabled: false
104
- is_mcp_enabled: false
105
- ```
106
-
107
- This manifest configures:
108
-
109
- - `display_information.name` and `features.bot_user.display_name`: Set your agent's name in Slack. You can update it at any time; remember to reinstall the app after changing names or permissions.
110
- - `app_home.messages_tab_enabled` and `app_home.messages_tab_read_only_enabled`: Enable direct messages from the Slack app's **Messages** tab.
111
- - `always_online`: Shows the Slack bot user as always available.
112
- - `oauth_config.scopes.bot`: Grants the bot permission to post messages, read channel messages where it is present, read mentions, read and write direct messages, and look up users.
113
- - `event_subscriptions`: Tells Slack which message events to send to the webhook.
114
- - `interactivity`: Enables interactive cards and tells Slack where to send card actions.
115
-
116
- After the app is created, open **Install App**, select **Install to Workspace**, and approve the requested scopes.
117
-
118
- ## Set Slack credentials
119
-
120
- Set the Slack credentials in Mastra so it can verify Slack requests and send messages back to Slack.
121
-
122
- In the Slack app settings, copy these values:
123
-
124
- - **Basic Information** > **App Credentials** > **Signing Secret**
125
- - **OAuth & Permissions** > **Bot User OAuth Token**
126
-
127
- Set them in your Mastra environment:
128
-
129
- ```bash
130
- SLACK_SIGNING_SECRET=your-signing-secret
131
- SLACK_BOT_TOKEN=xoxb-your-bot-token
132
- ```
133
-
134
- Mastra reads these environment variables automatically.
135
-
136
- ## Configure the webhook route
137
-
138
- Slack sends channel activity to Mastra through webhooks. A webhook is an HTTP endpoint Slack calls when something happens, such as a new message, a mention, or a user selecting an interactive card.
139
-
140
- Mastra automatically registers a Slack webhook route for your agent:
141
-
142
- ```text
143
- /api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
144
- ```
145
-
146
- Build the webhook URL from your public Mastra server URL and the generated route:
147
-
148
- ```text
149
- https://<YOUR-PUBLIC-URL>/api/agents/<YOUR-AGENT-ID>/channels/slack/webhook
150
- ```
151
-
152
- Slack can't send events to `localhost`. For local development, keep the Mastra dev server running and expose `http://localhost:4111` with a tunnel before you save the request URL in Slack.
153
-
154
- Use a tunnel such as `cloudflared` or `ngrok` for local development:
155
-
156
- **npm**:
157
-
158
- ```bash
159
- npx cloudflared tunnel --url http://localhost:4111
160
- ```
161
-
162
- **pnpm**:
163
-
164
- ```bash
165
- pnpm dlx cloudflared tunnel --url http://localhost:4111
166
- ```
167
-
168
- **Yarn**:
169
-
170
- ```bash
171
- yarn dlx cloudflared tunnel --url http://localhost:4111
172
- ```
173
-
174
- **Bun**:
175
-
176
- ```bash
177
- bun x cloudflared tunnel --url http://localhost:4111
178
- ```
179
-
180
- Use the generated tunnel host as `<YOUR-PUBLIC-URL>`, for example:
181
-
182
- ```text
183
- https://abc123.trycloudflare.com/api/agents/your-agent/channels/slack/webhook
184
- ```
185
-
186
- Update the request URLs in Slack:
187
-
188
- 1. In the Slack app settings, open **Event Subscriptions**.
189
- 2. Replace **Request URL** with the final webhook URL.
190
- 3. Select **Save Changes**.
191
- 4. Open **Interactivity & Shortcuts**.
192
- 5. Replace **Request URL** with the same webhook URL.
193
- 6. Select **Save Changes**.
194
- 7. If Slack asks you to reinstall the app, open **OAuth & Permissions** and select **Reinstall to Workspace**.
195
-
196
- ## Try it in Slack
197
-
198
- Open a direct message with the Slack bot user and send a message. Direct messages work because the manifest includes the `message.im` event and `im:*` scopes.
199
-
200
- To use the agent in a channel, invite the Slack bot user first:
201
-
202
- ```text
203
- /invite @your-bot-name
204
- ```
205
-
206
- Mention the bot in the channel:
207
-
208
- ```text
209
- @your-bot-name What can you help me with?
210
- ```
211
-
212
- The agent responds in the thread. Response content depends on the model, instructions, memory, and tools configured on the agent.
213
-
214
- ## Production deployment
215
-
216
- When you deploy the Mastra server, update both request URLs in the Slack app settings to the production webhook URL. The tunnel URL used for local development is temporary and changes when the tunnel restarts.
217
-
218
- Channels on serverless platforms may need `waitUntil` and shared pub/sub configuration so background responses and thread leases work across short-lived instances. See [serverless deployment](https://mastra.ai/docs/capabilities/channels/overview) in the channels overview.
219
-
220
- ## Related
221
-
222
- - [Channels overview](https://mastra.ai/docs/capabilities/channels/overview)
223
- - [More](https://mastra.ai/docs/capabilities/channels/other-adapters)
224
- - [Channels reference](https://mastra.ai/reference/agents/channels)
225
- - [Deployment overview](https://mastra.ai/docs/deployment/overview)