@mastra/mcp-docs-server 1.1.29-alpha.8 → 1.1.29-alpha.9
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.
|
@@ -72,7 +72,7 @@ Platform webhooks need a public URL to reach your local server. Use a tunnel to
|
|
|
72
72
|
ngrok http 4111
|
|
73
73
|
|
|
74
74
|
# cloudflared
|
|
75
|
-
cloudflared tunnel --url http://localhost:4111
|
|
75
|
+
npx cloudflared tunnel --url http://localhost:4111
|
|
76
76
|
```
|
|
77
77
|
|
|
78
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`).
|
|
@@ -164,6 +164,7 @@ By default, only images are sent inline (`inlineMedia: ['image/*']`). Unsupporte
|
|
|
164
164
|
|
|
165
165
|
## Related
|
|
166
166
|
|
|
167
|
+
- [Guide: Building a Slack assistant](https://mastra.ai/guides/guide/slack-assistant)
|
|
167
168
|
- [Agent overview](https://mastra.ai/docs/agents/overview)
|
|
168
169
|
- [Tool approval](https://mastra.ai/docs/agents/agent-approval)
|
|
169
170
|
- [Channels reference](https://mastra.ai/reference/agents/channels)
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
# Building a Slack assistant
|
|
2
|
+
|
|
3
|
+
In this guide, you'll build a Mastra agent that responds to messages and mentions on Slack. You'll learn how to configure a channel adapter, set up a Slack app with the right permissions, connect it to your agent via a webhook, and test the interaction.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
- Node.js `v22.13.0` or later installed
|
|
8
|
+
- An API key from a supported [Model Provider](https://mastra.ai/models)
|
|
9
|
+
- An existing Mastra project. Follow the [installation guide](https://mastra.ai/guides/getting-started/quickstart) if needed.
|
|
10
|
+
- A [Slack workspace](https://slack.com/) where you can create apps
|
|
11
|
+
|
|
12
|
+
## Create the agent
|
|
13
|
+
|
|
14
|
+
Install the Slack adapter:
|
|
15
|
+
|
|
16
|
+
**npm**:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @chat-adapter/slack
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**pnpm**:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
pnpm add @chat-adapter/slack
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
**Yarn**:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn add @chat-adapter/slack
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
**Bun**:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
bun add @chat-adapter/slack
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Create a new file `src/mastra/agents/slack-agent.ts` and define your agent:
|
|
41
|
+
|
|
42
|
+
```ts
|
|
43
|
+
import { Agent } from '@mastra/core/agent'
|
|
44
|
+
import { createSlackAdapter } from '@chat-adapter/slack'
|
|
45
|
+
|
|
46
|
+
export const slackAgent = new Agent({
|
|
47
|
+
id: 'slack-agent',
|
|
48
|
+
name: 'Slack Agent',
|
|
49
|
+
instructions:
|
|
50
|
+
'You are a helpful assistant. Answer questions, help with tasks, and have natural conversations.',
|
|
51
|
+
model: 'anthropic/claude-opus-4-6',
|
|
52
|
+
channels: {
|
|
53
|
+
adapters: {
|
|
54
|
+
slack: createSlackAdapter(),
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
})
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The `channels` property tells Mastra to generate a webhook endpoint for each adapter. In this case, the Slack adapter handles event verification, signature validation, and message formatting automatically.
|
|
61
|
+
|
|
62
|
+
Register the agent in your `src/mastra/index.ts` file:
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { Mastra } from '@mastra/core'
|
|
66
|
+
import { slackAgent } from './agents/slack-agent'
|
|
67
|
+
|
|
68
|
+
export const mastra = new Mastra({
|
|
69
|
+
agents: { slackAgent },
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## Create a Slack app
|
|
74
|
+
|
|
75
|
+
You need a Slack app to connect your agent to a workspace.
|
|
76
|
+
|
|
77
|
+
Go to <https://api.slack.com/apps> and select **Create New App** > **From scratch**. Give it a name and select your workspace.
|
|
78
|
+
|
|
79
|
+
Navigate to **OAuth & Permissions** and scroll to **Bot Token Scopes**. Add the following scopes:
|
|
80
|
+
|
|
81
|
+
- `app_mentions:read`
|
|
82
|
+
- `channels:history`
|
|
83
|
+
- `channels:read`
|
|
84
|
+
- `chat:write`
|
|
85
|
+
- `users:read`
|
|
86
|
+
|
|
87
|
+
At the top of **OAuth & Permissions**, select **Install to Workspace**. Copy the **Bot User OAuth Token** (`xoxb-...`).
|
|
88
|
+
|
|
89
|
+
Go to **Basic Information** > **App Credentials** and copy the **Signing Secret** (e.g. `c3a4...`).
|
|
90
|
+
|
|
91
|
+
Ensure **Socket Mode** is turned **off** under **Settings** > **Socket Mode**.
|
|
92
|
+
|
|
93
|
+
Add the credentials to your `.env` file:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
SLACK_SIGNING_SECRET=your-signing-secret
|
|
97
|
+
SLACK_BOT_TOKEN=xoxb-your-bot-token
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
The adapter reads these environment variables by default. See the [Chat SDK Slack adapter docs](https://chat-sdk.dev/adapters/slack) for more details.
|
|
101
|
+
|
|
102
|
+
## Connect the webhook
|
|
103
|
+
|
|
104
|
+
Slack delivers events to your agent via a webhook. Mastra generates this endpoint automatically for each channel adapter.
|
|
105
|
+
|
|
106
|
+
Start the dev server:
|
|
107
|
+
|
|
108
|
+
**npm**:
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm run dev
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**pnpm**:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
pnpm run dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Yarn**:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
yarn dev
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Bun**:
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
bun run dev
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
During local development, Slack needs a public URL to reach your local server. Open a new terminal and start a tunnel:
|
|
133
|
+
|
|
134
|
+
```bash
|
|
135
|
+
npx cloudflared tunnel --url http://localhost:4111
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
This outputs a temporary public URL like `https://triple-arms-solutions-kit.trycloudflare.com`. The URL changes each time you restart the tunnel.
|
|
139
|
+
|
|
140
|
+
In your Slack app settings, go to **Event Subscriptions** and toggle **Enable Events** to **On**.
|
|
141
|
+
|
|
142
|
+
Set the **Request URL** to your tunnel URL with the agent webhook path:
|
|
143
|
+
|
|
144
|
+
```text
|
|
145
|
+
https://<your-tunnel-url>/api/agents/slack-agent/channels/slack/webhook
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
Slack sends a verification request. If your dev server is running, it responds with a green checkmark.
|
|
149
|
+
|
|
150
|
+
Under **Subscribe to bot events**, add:
|
|
151
|
+
|
|
152
|
+
- `app_mention`
|
|
153
|
+
- `message.channels`
|
|
154
|
+
|
|
155
|
+
Select **Save Changes**. Slack requires you to reinstall the app after changing event subscriptions. Go to **OAuth & Permissions** and select **Reinstall to Workspace** to apply the updated permissions.
|
|
156
|
+
|
|
157
|
+
> **Note:** The tunnel URL is for local development only. When you [deploy your application](https://mastra.ai/docs/deployment/overview), update the **Request URL** in your Slack app's **Event Subscriptions** to your production URL (e.g. `https://your-app.example.com/api/agents/slack-agent/channels/slack/webhook`).
|
|
158
|
+
|
|
159
|
+
## Test the agent
|
|
160
|
+
|
|
161
|
+
Before testing with Slack, you can refine your agent's behavior in [Studio](https://mastra.ai/docs/studio/overview). Open <http://localhost:4111/> to chat with your agent directly, adjust its instructions, and inspect traces to see how responses are generated.
|
|
162
|
+
|
|
163
|
+
Once you're happy with the agent's responses, test the Slack integration. Invite the bot to a channel in Slack:
|
|
164
|
+
|
|
165
|
+
```text
|
|
166
|
+
/invite @your-bot-name
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
Mention the bot in the channel:
|
|
170
|
+
|
|
171
|
+
```text
|
|
172
|
+
@your-bot-name What can you help me with?
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The agent responds in the thread. Output may vary depending on the model and instructions.
|
|
176
|
+
|
|
177
|
+
## Next steps
|
|
178
|
+
|
|
179
|
+
You can extend this agent to:
|
|
180
|
+
|
|
181
|
+
- [Deploy your application](https://mastra.ai/docs/deployment/overview) and update the Slack **Request URL** to your production endpoint
|
|
182
|
+
- Add more adapters (Discord, Telegram) to the same agent so it responds on multiple platforms
|
|
183
|
+
- Configure [multimodal content](https://mastra.ai/docs/agents/channels) to let your agent process images, video, and audio shared in chat
|
|
184
|
+
- Add [tools](https://mastra.ai/docs/agents/using-tools) to give the agent access to external APIs and data
|
|
185
|
+
|
|
186
|
+
Learn more:
|
|
187
|
+
|
|
188
|
+
- [Channels overview](https://mastra.ai/docs/agents/channels)
|
|
189
|
+
- [Studio](https://mastra.ai/docs/studio/overview)
|
|
190
|
+
- [Deployment overview](https://mastra.ai/docs/deployment/overview)
|
|
191
|
+
- [Chat SDK adapter docs](https://chat-sdk.dev)
|
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# @mastra/mcp-docs-server
|
|
2
2
|
|
|
3
|
+
## 1.1.29-alpha.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`8a71261`](https://github.com/mastra-ai/mastra/commit/8a71261e3954ae617c6f8e25767b951f99438ab2), [`021a60f`](https://github.com/mastra-ai/mastra/commit/021a60f1f3e0135a70ef23c58be7a9b3aaffe6b4)]:
|
|
8
|
+
- @mastra/core@1.29.0-alpha.4
|
|
9
|
+
|
|
3
10
|
## 1.1.29-alpha.7
|
|
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.29-alpha.
|
|
3
|
+
"version": "1.1.29-alpha.9",
|
|
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.29.0-alpha.
|
|
32
|
+
"@mastra/core": "1.29.0-alpha.4",
|
|
33
33
|
"@mastra/mcp": "^1.5.2"
|
|
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.1.5",
|
|
49
|
+
"@internal/lint": "0.0.86",
|
|
49
50
|
"@internal/types-builder": "0.0.61",
|
|
50
|
-
"@mastra/core": "1.29.0-alpha.
|
|
51
|
-
"@internal/lint": "0.0.86"
|
|
51
|
+
"@mastra/core": "1.29.0-alpha.4"
|
|
52
52
|
},
|
|
53
53
|
"homepage": "https://mastra.ai",
|
|
54
54
|
"repository": {
|