@mastra/mcp-docs-server 1.3.13-alpha.0 → 1.3.13-alpha.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/docs/agents/resumable-streams.md +140 -0
- package/.docs/docs/agents/tools.md +2 -2
- package/.docs/docs/auth/overview.md +1 -0
- package/.docs/docs/channels.md +34 -1
- package/.docs/docs/connections/mcp.md +27 -61
- package/.docs/docs/harness/background-tasks.md +2 -1
- package/.docs/docs/harness/durable-agents.md +6 -6
- package/.docs/docs/harness/schedules.md +2 -0
- package/.docs/docs/mastra-platform/connect.md +231 -0
- package/.docs/docs/mastra-platform/overview.md +1 -1
- package/.docs/docs/observability/tracing/overview.md +0 -2
- package/.docs/docs/signals/sending-signals.md +3 -1
- package/.docs/integrations/auth/clerk.md +46 -7
- package/.docs/integrations/auth/neon.md +217 -0
- package/.docs/integrations/auth/supabase.md +46 -7
- package/.docs/integrations/auth/workos.md +54 -15
- package/.docs/integrations/channels/discord.md +84 -6
- package/.docs/integrations/channels/github.md +63 -24
- package/.docs/integrations/channels/slack.md +89 -8
- package/.docs/integrations/channels/teams.md +79 -5
- package/.docs/integrations/channels/telegram.md +47 -6
- package/.docs/integrations/crm/attio.md +42 -0
- package/.docs/integrations/crm/clay.md +42 -0
- package/.docs/integrations/crm/hubspot.md +41 -0
- package/.docs/integrations/databases/neon.md +37 -1
- package/.docs/integrations/databases/postgresql.md +46 -0
- package/.docs/integrations/deploy/render.md +59 -18
- package/.docs/integrations/documents/google-docs.md +41 -0
- package/.docs/integrations/documents/google-sheet.md +41 -0
- package/.docs/integrations/documents/microsoft-excel.md +43 -0
- package/.docs/integrations/documents/microsoft-powerpoint.md +41 -0
- package/.docs/integrations/documents/microsoft-word.md +41 -0
- package/.docs/integrations/documents/notion.md +41 -0
- package/.docs/integrations/documents/one-drive.md +41 -0
- package/.docs/integrations/documents/sharepoint-online.md +41 -0
- package/.docs/integrations/email-calendar/google-calendar.md +41 -0
- package/.docs/integrations/email-calendar/google-mail.md +41 -0
- package/.docs/integrations/email-calendar/outlook.md +41 -0
- package/.docs/integrations/file-storage/amazon-s3.md +1 -1
- package/.docs/integrations/file-storage/google-drive.md +54 -15
- package/.docs/integrations/observability/posthog.md +50 -11
- package/.docs/integrations/other/canva.md +42 -0
- package/.docs/integrations/other/fireflies.md +41 -0
- package/.docs/integrations/other/incident-io.md +41 -0
- package/.docs/integrations/other/resend.md +43 -0
- package/.docs/integrations/other/robinhood.md +44 -0
- package/.docs/integrations/other/sanity.md +42 -0
- package/.docs/integrations/other/snowflake.md +41 -0
- package/.docs/integrations/project-management/jira.md +41 -0
- package/.docs/integrations/project-management/linear.md +41 -0
- package/.docs/integrations/voice/openai.md +40 -0
- package/.docs/integrations.md +40 -1
- package/.docs/models/gateways/custom-gateways.md +2 -0
- package/.docs/models/gateways/netlify.md +6 -3
- package/.docs/models/gateways/openrouter.md +7 -8
- package/.docs/models/gateways/vercel.md +419 -420
- package/.docs/models/index.md +46 -2
- package/.docs/models/providers/aiand.md +1 -1
- package/.docs/models/providers/chutes.md +2 -1
- package/.docs/models/providers/edenai.md +9 -13
- package/.docs/models/providers/empiriolabs.md +3 -3
- package/.docs/models/providers/hyper.md +7 -13
- package/.docs/models/providers/inceptron.md +1 -1
- package/.docs/models/providers/kilo.md +16 -16
- package/.docs/models/providers/llmgateway-providers.md +16 -8
- package/.docs/models/providers/llmgateway.md +4 -4
- package/.docs/models/providers/nano-gpt.md +12 -14
- package/.docs/models/providers/opencode-go.md +3 -1
- package/.docs/models/providers/opencode.md +2 -2
- package/.docs/models/providers/prime.md +1 -1
- package/.docs/models/providers/tencent-token-plan.md +2 -1
- package/.docs/models/providers/tencent-tokenhub.md +2 -1
- package/.docs/models/providers/wandb.md +3 -3
- package/.docs/reference/agents/agent.md +2 -0
- package/.docs/reference/agents/channels.md +38 -1
- package/.docs/reference/agents/durable-agent.md +37 -26
- package/.docs/reference/auth/neon.md +24 -15
- package/.docs/reference/cli/mastra.md +10 -1
- package/.docs/reference/client-js/agents.md +4 -4
- package/.docs/reference/client-js/observability.md +23 -1
- package/.docs/reference/connect/channels.md +55 -1
- package/.docs/reference/connect/providers.md +5 -3
- package/.docs/reference/connect/tools.md +29 -2
- package/.docs/reference/core/getGatewayById.md +14 -1
- package/.docs/reference/observability/tracing/advanced-queries.md +47 -58
- package/.docs/reference/pubsub/redis-streams.md +2 -0
- package/.docs/reference/streaming/agents/MastraModelOutput.md +6 -4
- package/.docs/reference/tools/mcp-server.md +6 -2
- package/.docs/reference/workflows/workflow.md +1 -1
- package/package.json +4 -4
- package/.docs/docs/mastra-platform/connect/channels.md +0 -165
- package/.docs/docs/mastra-platform/connect/overview.md +0 -102
- package/.docs/docs/mastra-platform/connect/providers.md +0 -66
- package/.docs/docs/mastra-platform/connect/tools.md +0 -151
|
@@ -4,9 +4,48 @@
|
|
|
4
4
|
|
|
5
5
|
# Supabase
|
|
6
6
|
|
|
7
|
+
Use Supabase with Mastra in two ways:
|
|
8
|
+
|
|
9
|
+
- **Agent tools** let an agent query tables, call database functions, and manage storage and auth users in Supabase through [Mastra Connect](https://mastra.ai/docs/mastra-platform/connect).
|
|
10
|
+
- **[Server authentication](#server-authentication)** verifies requests to your Mastra server with Supabase, using the `@mastra/auth-supabase` package.
|
|
11
|
+
|
|
12
|
+
## Connect
|
|
13
|
+
|
|
14
|
+
Before you start, complete the [Connect setup](https://mastra.ai/docs/mastra-platform/connect) to install `@mastra/connect` and configure your platform project.
|
|
15
|
+
|
|
16
|
+
### Agent tools
|
|
17
|
+
|
|
18
|
+
Give agents tools to query and change table rows, call database functions, and manage storage buckets, files, and auth users in Supabase.
|
|
19
|
+
|
|
20
|
+
Connect an account with the `supabase` provider ID. Run this command from the directory that contains your `.env` file:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
mastra connect add supabase
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then pass [`tools()`](https://mastra.ai/reference/connect/tools) to the agent and select the provider:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Agent } from '@mastra/core/agent'
|
|
30
|
+
import { tools } from '@mastra/connect'
|
|
31
|
+
|
|
32
|
+
export const supabaseAgent = new Agent({
|
|
33
|
+
id: 'supabase-agent',
|
|
34
|
+
name: 'Supabase agent',
|
|
35
|
+
instructions:
|
|
36
|
+
'You help people query and change table rows, call database functions, and manage storage buckets, files, and auth users in Supabase.',
|
|
37
|
+
model: '__GATEWAY_OPENAI_MODEL_LUNA__',
|
|
38
|
+
tools: tools({ providers: ['supabase'] }),
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The agent gets 27 Supabase tools, with keys such as `supabase_copy_storage_object`. See [Supabase tools](https://mastra.ai/reference/connect/providers) for the full list, and the [`tools()` parameters](https://mastra.ai/reference/connect/tools) to restrict tools or require approval before a call runs.
|
|
43
|
+
|
|
44
|
+
## Server authentication
|
|
45
|
+
|
|
7
46
|
The `@mastra/auth-supabase` package provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the `auth` option.
|
|
8
47
|
|
|
9
|
-
|
|
48
|
+
### Prerequisites
|
|
10
49
|
|
|
11
50
|
This example uses Supabase Auth. Make sure to add your Supabase credentials to your `.env` file and ensure your Supabase project is properly configured.
|
|
12
51
|
|
|
@@ -17,7 +56,7 @@ SUPABASE_ANON_KEY=your-anon-key
|
|
|
17
56
|
|
|
18
57
|
> **Note:** Review your Supabase Row Level Security (RLS) settings to ensure proper data access controls.
|
|
19
58
|
|
|
20
|
-
|
|
59
|
+
### Installation
|
|
21
60
|
|
|
22
61
|
Before you can use the `MastraAuthSupabase` class you have to install the `@mastra/auth-supabase` package.
|
|
23
62
|
|
|
@@ -45,7 +84,7 @@ yarn add @mastra/auth-supabase@latest
|
|
|
45
84
|
bun add @mastra/auth-supabase@latest
|
|
46
85
|
```
|
|
47
86
|
|
|
48
|
-
|
|
87
|
+
### Usage example
|
|
49
88
|
|
|
50
89
|
```typescript
|
|
51
90
|
import { Mastra } from '@mastra/core'
|
|
@@ -65,11 +104,11 @@ export const mastra = new Mastra({
|
|
|
65
104
|
>
|
|
66
105
|
> Visit [MastraAuthSupabase](https://mastra.ai/reference/auth/supabase) for all available configuration options.
|
|
67
106
|
|
|
68
|
-
|
|
107
|
+
### Client-side setup
|
|
69
108
|
|
|
70
109
|
When using Supabase auth, you'll need to retrieve the access token from Supabase on the client side and pass it to your Mastra requests.
|
|
71
110
|
|
|
72
|
-
|
|
111
|
+
#### Retrieving the access token
|
|
73
112
|
|
|
74
113
|
Use the Supabase client to authenticate users and retrieve their access token:
|
|
75
114
|
|
|
@@ -88,7 +127,7 @@ const accessToken = authTokenResponse.data?.session?.access_token
|
|
|
88
127
|
|
|
89
128
|
> **Note:** Refer to the [Supabase documentation](https://supabase.com/docs/guides/auth) for other authentication methods like OAuth, magic links, and more.
|
|
90
129
|
|
|
91
|
-
|
|
130
|
+
### Configuring `MastraClient`
|
|
92
131
|
|
|
93
132
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid Supabase access token in the `Authorization` header:
|
|
94
133
|
|
|
@@ -107,7 +146,7 @@ export const mastraClient = new MastraClient({
|
|
|
107
146
|
>
|
|
108
147
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
109
148
|
|
|
110
|
-
|
|
149
|
+
#### Making authenticated requests
|
|
111
150
|
|
|
112
151
|
Once `MastraClient` is configured with the Supabase access token, you can send authenticated requests:
|
|
113
152
|
|
|
@@ -4,9 +4,48 @@
|
|
|
4
4
|
|
|
5
5
|
# WorkOS
|
|
6
6
|
|
|
7
|
+
Use WorkOS with Mastra in two ways:
|
|
8
|
+
|
|
9
|
+
- **Agent tools** let an agent manage WorkOS organizations, users, and SSO connections through [Mastra Connect](https://mastra.ai/docs/mastra-platform/connect).
|
|
10
|
+
- **[Server authentication](#server-authentication)** verifies requests to your Mastra server with WorkOS, using the `@mastra/auth-workos` package.
|
|
11
|
+
|
|
12
|
+
## Connect
|
|
13
|
+
|
|
14
|
+
Before you start, complete the [Connect setup](https://mastra.ai/docs/mastra-platform/connect) to install `@mastra/connect` and configure your platform project.
|
|
15
|
+
|
|
16
|
+
### Agent tools
|
|
17
|
+
|
|
18
|
+
Give agents tools to manage organizations, users, memberships, invitations, SSO connections, and directories in WorkOS.
|
|
19
|
+
|
|
20
|
+
Connect an account with the `workos` provider ID. Run this command from the directory that contains your `.env` file:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
mastra connect add workos
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then pass [`tools()`](https://mastra.ai/reference/connect/tools) to the agent and select the provider:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Agent } from '@mastra/core/agent'
|
|
30
|
+
import { tools } from '@mastra/connect'
|
|
31
|
+
|
|
32
|
+
export const workosAgent = new Agent({
|
|
33
|
+
id: 'workos-agent',
|
|
34
|
+
name: 'WorkOS agent',
|
|
35
|
+
instructions:
|
|
36
|
+
'You help people manage organizations, users, memberships, invitations, SSO connections, and directories in WorkOS.',
|
|
37
|
+
model: '__GATEWAY_OPENAI_MODEL_LUNA__',
|
|
38
|
+
tools: tools({ providers: ['workos'] }),
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The agent gets 40 WorkOS tools, with keys such as `workos_create_connection`. See [WorkOS tools](https://mastra.ai/reference/connect/providers) for the full list, and the [`tools()` parameters](https://mastra.ai/reference/connect/tools) to restrict tools or require approval before a call runs.
|
|
43
|
+
|
|
44
|
+
## Server authentication
|
|
45
|
+
|
|
7
46
|
The `@mastra/auth-workos` package provides authentication for Mastra using WorkOS. It verifies incoming requests using WorkOS access tokens and integrates with the Mastra server using the `auth` option.
|
|
8
47
|
|
|
9
|
-
|
|
48
|
+
### Prerequisites
|
|
10
49
|
|
|
11
50
|
This example uses WorkOS authentication. Make sure to:
|
|
12
51
|
|
|
@@ -24,7 +63,7 @@ WORKOS_CLIENT_ID=client_...
|
|
|
24
63
|
>
|
|
25
64
|
> For detailed setup instructions, refer to the [WorkOS documentation](https://workos.com/docs) for your specific platform.
|
|
26
65
|
|
|
27
|
-
|
|
66
|
+
### Installation
|
|
28
67
|
|
|
29
68
|
Before you can use the `MastraAuthWorkos` class you have to install the `@mastra/auth-workos` package.
|
|
30
69
|
|
|
@@ -52,9 +91,9 @@ yarn add @mastra/auth-workos@latest
|
|
|
52
91
|
bun add @mastra/auth-workos@latest
|
|
53
92
|
```
|
|
54
93
|
|
|
55
|
-
|
|
94
|
+
### Usage examples
|
|
56
95
|
|
|
57
|
-
|
|
96
|
+
#### Basic usage with environment variables
|
|
58
97
|
|
|
59
98
|
```typescript
|
|
60
99
|
import { Mastra } from '@mastra/core'
|
|
@@ -67,7 +106,7 @@ export const mastra = new Mastra({
|
|
|
67
106
|
})
|
|
68
107
|
```
|
|
69
108
|
|
|
70
|
-
|
|
109
|
+
#### Custom configuration
|
|
71
110
|
|
|
72
111
|
```typescript
|
|
73
112
|
import { Mastra } from '@mastra/core'
|
|
@@ -83,13 +122,13 @@ export const mastra = new Mastra({
|
|
|
83
122
|
})
|
|
84
123
|
```
|
|
85
124
|
|
|
86
|
-
|
|
125
|
+
### Configuration
|
|
87
126
|
|
|
88
|
-
|
|
127
|
+
#### Default authorization
|
|
89
128
|
|
|
90
129
|
By default, `MastraAuthWorkos` grants access to any authenticated WorkOS user. The authorization check succeeds when the resolved user object contains both a Mastra user ID and a WorkOS user ID.
|
|
91
130
|
|
|
92
|
-
|
|
131
|
+
#### FGA membership loading
|
|
93
132
|
|
|
94
133
|
> **Note:** FGA requires a Mastra Enterprise Edition (EE) license in production. It works without a license in development. See [what requires an EE license](https://mastra.ai/docs/license). [Contact sales](https://mastra.ai/contact) for more information.
|
|
95
134
|
|
|
@@ -112,7 +151,7 @@ const workosFga = new MastraFGAWorkos({
|
|
|
112
151
|
|
|
113
152
|
When `fetchMemberships` is `false`, Mastra skips the extra WorkOS `listOrganizationMemberships()` call on each authenticated request.
|
|
114
153
|
|
|
115
|
-
|
|
154
|
+
#### Service tokens and custom JWT templates
|
|
116
155
|
|
|
117
156
|
For machine-to-machine or service-account access, you can configure `MastraAuthWorkos` to trust verified bearer-token claims from a WorkOS custom JWT template.
|
|
118
157
|
|
|
@@ -133,7 +172,7 @@ const workosAuth = new MastraAuthWorkos({
|
|
|
133
172
|
|
|
134
173
|
This is useful when your JWT template already includes the exact FGA context Mastra needs, such as `organizationMembershipId`, tenant IDs, or service-principal identifiers. When `trustJwtClaims` is enabled, Mastra can fall back to those verified claims if a bearer token isn't meant to round-trip through `workos.userManagement.getUser()`.
|
|
135
174
|
|
|
136
|
-
|
|
175
|
+
#### Custom authorization
|
|
137
176
|
|
|
138
177
|
If you need stricter authorization, subclass `MastraAuthWorkos` and override `authorizeUser()`:
|
|
139
178
|
|
|
@@ -155,11 +194,11 @@ const workosAuth = new AdminOnlyWorkosAuth({
|
|
|
155
194
|
|
|
156
195
|
Visit [MastraAuthWorkos](https://mastra.ai/reference/auth/workos) for all available configuration options.
|
|
157
196
|
|
|
158
|
-
|
|
197
|
+
### Client-side setup
|
|
159
198
|
|
|
160
199
|
When using WorkOS auth, you'll need to implement the WorkOS authentication flow to exchange an authorization code for an access token, then use that token with your Mastra requests.
|
|
161
200
|
|
|
162
|
-
|
|
201
|
+
#### Installing WorkOS SDK
|
|
163
202
|
|
|
164
203
|
First, install the WorkOS SDK in your application:
|
|
165
204
|
|
|
@@ -187,7 +226,7 @@ yarn add @workos-inc/node
|
|
|
187
226
|
bun add @workos-inc/node
|
|
188
227
|
```
|
|
189
228
|
|
|
190
|
-
|
|
229
|
+
#### Exchanging code for access token
|
|
191
230
|
|
|
192
231
|
After users complete the WorkOS authentication flow and return with an authorization code, exchange it for an access token:
|
|
193
232
|
|
|
@@ -208,7 +247,7 @@ export const authenticateWithWorkos = async (code: string, clientId: string) =>
|
|
|
208
247
|
|
|
209
248
|
> **Note:** Refer to the [WorkOS User Management documentation](https://workos.com/docs/authkit/vanilla/nodejs) for more authentication methods and configuration options.
|
|
210
249
|
|
|
211
|
-
|
|
250
|
+
### Configuring `MastraClient`
|
|
212
251
|
|
|
213
252
|
When `auth` is enabled, all requests made with `MastraClient` must include a valid WorkOS access token in the `Authorization` header:
|
|
214
253
|
|
|
@@ -229,7 +268,7 @@ export const createMastraClient = (accessToken: string) => {
|
|
|
229
268
|
>
|
|
230
269
|
> Visit [Mastra Client SDK](https://mastra.ai/docs/server/mastra-client) for more configuration options.
|
|
231
270
|
|
|
232
|
-
|
|
271
|
+
#### Making authenticated requests
|
|
233
272
|
|
|
234
273
|
Once `MastraClient` is configured with the WorkOS access token, you can send authenticated requests:
|
|
235
274
|
|
|
@@ -4,9 +4,87 @@
|
|
|
4
4
|
|
|
5
5
|
# Discord
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use Discord with Mastra in two ways:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- **Agent tools** let an agent act in Discord servers, for example to send messages or manage channels.
|
|
10
|
+
- **Agent chat** lets people talk to your agent in Discord through bot messages and interactions such as slash commands and buttons.
|
|
11
|
+
|
|
12
|
+
[Mastra Connect](https://mastra.ai/docs/mastra-platform/connect) sets up both from one Discord bot and keeps its token on the Mastra platform. For agent chat, you can also manage the bot credentials yourself.
|
|
13
|
+
|
|
14
|
+
## Connect
|
|
15
|
+
|
|
16
|
+
Before you start, complete the [Connect setup](https://mastra.ai/docs/mastra-platform/connect) to install `@mastra/connect` and configure your platform project.
|
|
17
|
+
|
|
18
|
+
One `discord` connection provides both agent tools and agent chat. It uses a **bot token**, not a user OAuth token.
|
|
19
|
+
|
|
20
|
+
### Create a Discord bot
|
|
21
|
+
|
|
22
|
+
1. In the [Discord Developer Portal](https://discord.com/developers/applications), create an application.
|
|
23
|
+
2. Open **Bot**, add a bot, then select **Reset Token** and copy the bot token.
|
|
24
|
+
3. For agent chat, enable **Message Content Intent** under **Privileged Gateway Intents**.
|
|
25
|
+
|
|
26
|
+
When `mastra connect add discord` asks for a credential, enter the bot token.
|
|
27
|
+
|
|
28
|
+
### Agent tools
|
|
29
|
+
|
|
30
|
+
Give agents tools to send and manage messages, and manage channels, threads, roles, members, and webhooks in Discord.
|
|
31
|
+
|
|
32
|
+
Connect an account with the `discord` provider ID. Run this command from the directory that contains your `.env` file:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
mastra connect add discord
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then pass [`tools()`](https://mastra.ai/reference/connect/tools) to the agent and select the provider:
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Agent } from '@mastra/core/agent'
|
|
42
|
+
import { tools } from '@mastra/connect'
|
|
43
|
+
|
|
44
|
+
export const discordAgent = new Agent({
|
|
45
|
+
id: 'discord-agent',
|
|
46
|
+
name: 'Discord agent',
|
|
47
|
+
instructions:
|
|
48
|
+
'You help people send and manage messages, and manage channels, threads, roles, members, and webhooks in Discord.',
|
|
49
|
+
model: '__GATEWAY_OPENAI_MODEL_LUNA__',
|
|
50
|
+
tools: tools({ providers: ['discord'] }),
|
|
51
|
+
})
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
The agent gets 34 Discord tools, with keys such as `discord_add_guild_member_role`. See [Discord tools](https://mastra.ai/reference/connect/providers) for the full list, and the [`tools()` parameters](https://mastra.ai/reference/connect/tools) to restrict tools or require approval before a call runs.
|
|
55
|
+
|
|
56
|
+
### Agent chat
|
|
57
|
+
|
|
58
|
+
Your server needs a public URL that Discord can reach for webhook delivery and OAuth callbacks. Mastra platform supplies this URL. When you host elsewhere, set `MASTRA_SERVER_URL` to your public server URL. For local development, use a public HTTPS tunnel.
|
|
59
|
+
|
|
60
|
+
1. If you haven't added the connection yet, run `mastra connect add discord` and enter the bot token.
|
|
61
|
+
|
|
62
|
+
2. Pass [`channels()`](https://mastra.ai/reference/connect/channels) to the `Mastra` constructor. It registers the Discord channel provider and its routes:
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Mastra } from '@mastra/core'
|
|
66
|
+
import { channels } from '@mastra/connect'
|
|
67
|
+
import { assistant } from './agents/assistant'
|
|
68
|
+
|
|
69
|
+
export const mastra = new Mastra({
|
|
70
|
+
agents: { assistant },
|
|
71
|
+
channels: await channels({ providers: ['discord'] }),
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
To register other channels too, add their provider IDs to `providers`.
|
|
76
|
+
|
|
77
|
+
3. Start your Mastra application.
|
|
78
|
+
|
|
79
|
+
4. In Studio, connect the Discord channel to an agent. If the bot isn't already in a server, open the generated authorization URL, choose the server, and approve the requested permissions.
|
|
80
|
+
|
|
81
|
+
Discord uses the Gateway for messages and the HTTP interactions route for slash commands and buttons. See [Discord permissions](https://mastra.ai/reference/connect/channels) for the scopes and permissions requested by the bot invite.
|
|
82
|
+
|
|
83
|
+
## Self-managed setup
|
|
84
|
+
|
|
85
|
+
Use the Chat SDK Discord adapter with your own Discord application and credentials.
|
|
86
|
+
|
|
87
|
+
### Install the adapter
|
|
10
88
|
|
|
11
89
|
Install the Discord adapter from the Chat SDK:
|
|
12
90
|
|
|
@@ -34,7 +112,7 @@ yarn add @chat-adapter/discord
|
|
|
34
112
|
bun add @chat-adapter/discord
|
|
35
113
|
```
|
|
36
114
|
|
|
37
|
-
|
|
115
|
+
### Agent configuration
|
|
38
116
|
|
|
39
117
|
Add `createDiscordAdapter()` to the agent's `channels.adapters` object:
|
|
40
118
|
|
|
@@ -66,7 +144,7 @@ export const mastra = new Mastra({
|
|
|
66
144
|
})
|
|
67
145
|
```
|
|
68
146
|
|
|
69
|
-
|
|
147
|
+
### Adapter setup
|
|
70
148
|
|
|
71
149
|
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.
|
|
72
150
|
|
|
@@ -78,7 +156,7 @@ DISCORD_PUBLIC_KEY=your-discord-application-public-key
|
|
|
78
156
|
DISCORD_APPLICATION_ID=your-discord-application-id
|
|
79
157
|
```
|
|
80
158
|
|
|
81
|
-
|
|
159
|
+
### Webhook URL
|
|
82
160
|
|
|
83
161
|
Mastra generates the Discord webhook route from the agent ID and adapter key:
|
|
84
162
|
|
|
@@ -92,7 +170,7 @@ Use your public Mastra server URL as the base URL:
|
|
|
92
170
|
https://your-app.example.com/api/agents/discord-agent/channels/discord/webhook
|
|
93
171
|
```
|
|
94
172
|
|
|
95
|
-
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
|
|
173
|
+
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.
|
|
96
174
|
|
|
97
175
|
## Related
|
|
98
176
|
|
|
@@ -4,9 +4,48 @@
|
|
|
4
4
|
|
|
5
5
|
# GitHub
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
Use GitHub with Mastra in two ways:
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
- **Agent tools** let an agent work with repositories, issues, pull requests, releases, and workflow runs through [Mastra Connect](https://mastra.ai/docs/mastra-platform/connect).
|
|
10
|
+
- **[Pull request signals](#pull-request-signals)** let an agent follow pull requests (PRs) and react when they change.
|
|
11
|
+
|
|
12
|
+
## Connect
|
|
13
|
+
|
|
14
|
+
Before you start, complete the [Connect setup](https://mastra.ai/docs/mastra-platform/connect) to install `@mastra/connect` and configure your platform project. Connect keeps GitHub credentials on the Mastra platform, so your application never stores them.
|
|
15
|
+
|
|
16
|
+
### Agent tools
|
|
17
|
+
|
|
18
|
+
Give agents tools to search code and repositories, manage issues, pull requests, branches, files, and releases, and inspect and rerun workflow runs in GitHub.
|
|
19
|
+
|
|
20
|
+
Connect an account with the `github` provider ID. Run this command from the directory that contains your `.env` file:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
mastra connect add github
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
Then pass [`tools()`](https://mastra.ai/reference/connect/tools) to the agent and select the provider:
|
|
27
|
+
|
|
28
|
+
```typescript
|
|
29
|
+
import { Agent } from '@mastra/core/agent'
|
|
30
|
+
import { tools } from '@mastra/connect'
|
|
31
|
+
|
|
32
|
+
export const githubAgent = new Agent({
|
|
33
|
+
id: 'github-agent',
|
|
34
|
+
name: 'GitHub agent',
|
|
35
|
+
instructions:
|
|
36
|
+
'You help people search code and repositories, manage issues, pull requests, branches, files, and releases, and inspect and rerun workflow runs in GitHub.',
|
|
37
|
+
model: '__GATEWAY_OPENAI_MODEL_LUNA__',
|
|
38
|
+
tools: tools({ providers: ['github'] }),
|
|
39
|
+
})
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
The agent gets 49 GitHub tools, with keys such as `github_add_issue_comment`. See [GitHub tools](https://mastra.ai/reference/connect/providers) for the full list, and the [`tools()` parameters](https://mastra.ai/reference/connect/tools) to restrict tools or require approval before a call runs.
|
|
43
|
+
|
|
44
|
+
## Pull request signals
|
|
45
|
+
|
|
46
|
+
The `@mastra/github-signals` provider polls subscribed PRs and sends [notification signals](https://mastra.ai/docs/signals/notifications) to the agent thread when relevant activity occurs. It runs on your own infrastructure and uses the GitHub CLI for access instead of a Connect connection.
|
|
47
|
+
|
|
48
|
+
### Installation
|
|
10
49
|
|
|
11
50
|
Install GitHub Signals and the memory packages used in this example:
|
|
12
51
|
|
|
@@ -34,7 +73,7 @@ yarn add @mastra/github-signals @mastra/libsql @mastra/memory
|
|
|
34
73
|
bun add @mastra/github-signals @mastra/libsql @mastra/memory
|
|
35
74
|
```
|
|
36
75
|
|
|
37
|
-
|
|
76
|
+
### Prerequisites
|
|
38
77
|
|
|
39
78
|
GitHub Signals requires:
|
|
40
79
|
|
|
@@ -45,11 +84,11 @@ GitHub Signals requires:
|
|
|
45
84
|
|
|
46
85
|
By default, comments from users with `admin`, `maintain`, or `write` access can trigger notifications. CodeRabbit and Devin bot comments are explicitly allowed.
|
|
47
86
|
|
|
48
|
-
Bot authorization checks `ignoredBots` first, using an exact case-insensitive login match. Other bots can trigger notifications when they
|
|
87
|
+
Bot authorization checks `ignoredBots` first, using an exact case-insensitive login match. Other bots can trigger notifications when they're listed in `authorizedBots`, when the GitHub App is owned by a user whose repository permission is listed in `authorizedPermissions`, or when the app is owned by the organization that owns the repository. The default authorized permissions are `admin`, `maintain`, and `write`.
|
|
49
88
|
|
|
50
|
-
Failed, inaccessible, malformed, and unsupported app-owner lookups deny the bot comment. Successful app-owner lookups are cached for 24 hours
|
|
89
|
+
Failed, inaccessible, malformed, and unsupported app-owner lookups deny the bot comment. Successful app-owner lookups are cached for 24 hours. Failed lookups aren't cached.
|
|
51
90
|
|
|
52
|
-
|
|
91
|
+
### Agent and subscription
|
|
53
92
|
|
|
54
93
|
Create one `GithubSignals` instance and register it on the agent. Register the agent and a storage adapter on the Mastra instance:
|
|
55
94
|
|
|
@@ -99,35 +138,35 @@ The provider syncs the PR immediately, stores the subscription, and starts polli
|
|
|
99
138
|
|
|
100
139
|
A thread has one current GitHub Signals subscription. Subscribing it to another PR replaces the existing subscription.
|
|
101
140
|
|
|
102
|
-
|
|
141
|
+
### Subscription modes
|
|
103
142
|
|
|
104
143
|
GitHub Signals supports two subscription modes:
|
|
105
144
|
|
|
106
145
|
- `review`: Follows new head revisions, authorized latest PR comments, and observable review-thread-state changes, including when all review threads become resolved.
|
|
107
|
-
- `working`: Follows all
|
|
146
|
+
- `working`: Follows all PR activity that can trigger a notification detected by the provider. Comment-bearing notifications remain subject to existing authorization gates. This is the default when `mode` is omitted and for stored subscriptions without a valid mode.
|
|
108
147
|
|
|
109
148
|
The following table shows the observable behavior of each mode:
|
|
110
149
|
|
|
111
|
-
| Pull request activity
|
|
112
|
-
|
|
|
113
|
-
| First observation
|
|
114
|
-
| New commit or force-push
|
|
115
|
-
| New authorized latest PR comment
|
|
116
|
-
| Observable review-thread-state change
|
|
117
|
-
| Continuous integration checks start, fail, or recover
|
|
118
|
-
| Merge conflicts appear or resolve
|
|
119
|
-
| Other
|
|
120
|
-
| PR closes without merging
|
|
121
|
-
| PR reopens
|
|
122
|
-
| PR merges
|
|
123
|
-
|
|
124
|
-
Review mode uses the latest generic PR comment exposed by `gitcrawl
|
|
150
|
+
| Pull request activity | `working` | `review` |
|
|
151
|
+
| ----------------------------------------------------------- | ----------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
|
|
152
|
+
| First observation | Sends a baseline notification | Saves all cursors without notifying unless the PR is closed or merged; then notifies and removes the subscription |
|
|
153
|
+
| New commit or force-push | Notifies when the latest comment author is authorized | Notifies without requiring a comment author |
|
|
154
|
+
| New authorized latest PR comment | Notifies | Notifies |
|
|
155
|
+
| Observable review-thread-state change | Notifies while unresolved threads remain | Notifies, including when all review threads become resolved |
|
|
156
|
+
| Continuous integration checks start, fail, or recover | Notifies | Saves the new state without notifying |
|
|
157
|
+
| Merge conflicts appear or resolve | Notifies | Saves the new state without notifying |
|
|
158
|
+
| Other aggregate PR activity that can trigger a notification | Notifies when applicable authorization checks pass | Saves the new state without notifying |
|
|
159
|
+
| PR closes without merging | Notifies and keeps the subscription | Notifies and removes the subscription |
|
|
160
|
+
| PR reopens | Notifies | Doesn't notify because the earlier close removed the subscription |
|
|
161
|
+
| PR merges | Notifies and removes the subscription | Notifies and removes the subscription |
|
|
162
|
+
|
|
163
|
+
Review mode uses the latest generic PR comment exposed by `gitcrawl`, and the snapshot doesn't distinguish general PR conversation from inline review comments. Comment notifications require an authorized author because they include comment content. Review-state notifications contain only provider-generated state summaries and aren't author-gated.
|
|
125
164
|
|
|
126
165
|
The review-state cursor includes the unresolved thread count and the latest unresolved thread timestamp. It reports when the count reaches zero, but it can't report replies on threads that are already resolved.
|
|
127
166
|
|
|
128
167
|
During subscription, a PR already known to be closed or merged isn't stored and doesn't send an activity notification. Otherwise, review mode silently saves its first available non-terminal snapshot, including when the subscribe-time snapshot fails and a later poll supplies the first observation. If the first available poll snapshot or a later snapshot is closed or merged, the provider sends a terminal notification and removes the subscription. It doesn't follow a later reopen unless you subscribe again.
|
|
129
168
|
|
|
130
|
-
|
|
169
|
+
### Subscription tools
|
|
131
170
|
|
|
132
171
|
The provider adds `github_subscribe_pr` and `github_unsubscribe_pr` tools to the agent. Pass `mode` when subscribing:
|
|
133
172
|
|
|
@@ -142,7 +181,7 @@ The provider adds `github_subscribe_pr` and `github_unsubscribe_pr` tools to the
|
|
|
142
181
|
|
|
143
182
|
Omitting `mode` selects `working`. Don't subscribe for a one-off PR inspection.
|
|
144
183
|
|
|
145
|
-
|
|
184
|
+
### MastraCode commands
|
|
146
185
|
|
|
147
186
|
In MastraCode, use the spaced `--mode` flag with a PR number, `owner/repo#number`, or full GitHub PR URL:
|
|
148
187
|
|