@mastra/cursor 0.0.0-declined-tool-result-fix-20260602220958
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/CHANGELOG.md +70 -0
- package/LICENSE.md +30 -0
- package/README.md +93 -0
- package/dist/docs/SKILL.md +22 -0
- package/dist/docs/assets/SOURCE_MAP.json +6 -0
- package/dist/docs/references/docs-agents-sdk-agents.md +261 -0
- package/dist/index.cjs +1041 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +52 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1039 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.d.ts +138 -0
- package/dist/utils.d.ts.map +1 -0
- package/package.json +64 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# @mastra/cursor
|
|
2
|
+
|
|
3
|
+
## 0.0.0-declined-tool-result-fix-20260602220958
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`800c318`](https://github.com/mastra-ai/mastra/commit/800c318828a865b18bb952b819c1cd598035d44d)]:
|
|
8
|
+
- @mastra/core@0.0.0-declined-tool-result-fix-20260602220958
|
|
9
|
+
|
|
10
|
+
## 0.1.0
|
|
11
|
+
|
|
12
|
+
### Minor Changes
|
|
13
|
+
|
|
14
|
+
- Added `@mastra/cursor`, a package for running Cursor SDK agents through Mastra. ([#16906](https://github.com/mastra-ai/mastra/pull/16906))
|
|
15
|
+
|
|
16
|
+
Create a Cursor SDK agent, register it with Mastra, and call `generate()` or `stream()` with Mastra-compatible outputs. Runs keep Cursor SDK usage and observability data available to Mastra.
|
|
17
|
+
|
|
18
|
+
```ts
|
|
19
|
+
import { CursorSDKAgent } from '@mastra/cursor';
|
|
20
|
+
|
|
21
|
+
export const cursorAgent = new CursorSDKAgent({
|
|
22
|
+
id: 'cursor-sdk-agent',
|
|
23
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
24
|
+
sdkOptions: {
|
|
25
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
26
|
+
model: { id: process.env.CURSOR_MODEL_ID! },
|
|
27
|
+
local: {
|
|
28
|
+
cwd: process.cwd(),
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### Patch Changes
|
|
35
|
+
|
|
36
|
+
- Updated dependencies [[`fa63872`](https://github.com/mastra-ai/mastra/commit/fa6387280954e6b667bec5714b55ba082bc627ff), [`d779de3`](https://github.com/mastra-ai/mastra/commit/d779de3cd9d2e7ed8110547190e2f15e786a0e41), [`1750c97`](https://github.com/mastra-ai/mastra/commit/1750c975d6179fbf6db2813b15229d4f8f23fc55), [`9283971`](https://github.com/mastra-ai/mastra/commit/928397157009b4aef4d5fdf3a0a273cb371beb55), [`f07b646`](https://github.com/mastra-ai/mastra/commit/f07b64604ab7d25391179790b7fd4823df9e2dff), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`40f9297`](https://github.com/mastra-ai/mastra/commit/40f9297003b921c62373d3e8d3a4bda76c9f6de3), [`19a8658`](https://github.com/mastra-ai/mastra/commit/19a86589c788ef48bb6c1b0612cc82a201857379), [`850af77`](https://github.com/mastra-ai/mastra/commit/850af7779cb87c350804488734544a5b1843de25), [`0f0d1ba`](https://github.com/mastra-ai/mastra/commit/0f0d1ba67bfcb2204e571401662f1eceefc03357), [`a18775a`](https://github.com/mastra-ai/mastra/commit/a18775a693172546ee2378d39b67d4e32895b251), [`1baf2d1`](https://github.com/mastra-ai/mastra/commit/1baf2d152c6881338ff8f114633d5316fe13dd15), [`8c31bcd`](https://github.com/mastra-ai/mastra/commit/8c31bcdb00e597880d5939b1b7d7566fbe5dacae), [`0e32507`](https://github.com/mastra-ai/mastra/commit/0e32507962cdfa5569b7bda5bc6fb3dd34e40b03), [`95b14cd`](https://github.com/mastra-ai/mastra/commit/95b14cdd820e86d97ac05fe568424c513a252e31), [`07c3de7`](https://github.com/mastra-ai/mastra/commit/07c3de7f7bc418beccaea3b5e6b7f7cdda79d492), [`0bf2d93`](https://github.com/mastra-ai/mastra/commit/0bf2d932d20e2936f2d9abb8c0a86e24fbc97ec6), [`7b0d34c`](https://github.com/mastra-ai/mastra/commit/7b0d34cfe4a2fce22ac86ae17404685ff67a2ddb), [`a659a77`](https://github.com/mastra-ai/mastra/commit/a659a779bdebe3a52a518c56d2260592d0240fe0), [`aa36be2`](https://github.com/mastra-ai/mastra/commit/aa36be23aa513b7dc53cb8ca16b7fab8f20e43ad), [`3332be9`](https://github.com/mastra-ai/mastra/commit/3332be9701ecd77aba840959d9a1d1ce7aef02d3), [`212c635`](https://github.com/mastra-ai/mastra/commit/212c635203e61d036ab41db8ff86c3893dc795b3), [`d8838ae`](https://github.com/mastra-ai/mastra/commit/d8838ae80b69780361693d27098f7f6684af12fe), [`9aa5a73`](https://github.com/mastra-ai/mastra/commit/9aa5a73e7e110f6e9365eec69364a33d5f03bb56), [`f73c789`](https://github.com/mastra-ai/mastra/commit/f73c789e8ef21561580395d2c410119cab5848c8), [`8bd16da`](https://github.com/mastra-ai/mastra/commit/8bd16da73a4cb874d739373643dbd6a6e7f88684), [`c8630f8`](https://github.com/mastra-ai/mastra/commit/c8630f80d4f40cb5d22e60ab162b618b1907167a), [`94dfef6`](https://github.com/mastra-ai/mastra/commit/94dfef6e2bf19a88467ea3940afcbce88a433f0f), [`47f71dc`](https://github.com/mastra-ai/mastra/commit/47f71dc6fbcbd12d71e21a979e676e20a02bd77d), [`50ceae2`](https://github.com/mastra-ai/mastra/commit/50ceae270878e2f8fb2b2c6c2faab09df0007c8a), [`a122f79`](https://github.com/mastra-ai/mastra/commit/a122f79427ae225ec79c7b2ed46278da48d04b17), [`8cdde58`](https://github.com/mastra-ai/mastra/commit/8cdde5875bbba6702d9df226f2b20232b8d75d6c), [`3a081c1`](https://github.com/mastra-ai/mastra/commit/3a081c1255c5ae8c99f6dad91cc612934ef6f2bd), [`49f8abc`](https://github.com/mastra-ai/mastra/commit/49f8abce8258e4f2f87bd326acfbdb641264a47c), [`847ff1e`](https://github.com/mastra-ai/mastra/commit/847ff1e0d94368d94b2e173e4e0908e115568ef3), [`0c1ed1d`](https://github.com/mastra-ai/mastra/commit/0c1ed1d00c7d87b5ac99ca95896211a2fa9189fa), [`259d409`](https://github.com/mastra-ai/mastra/commit/259d409a514174299dbde1ff5e1121209b3ba850), [`9e16c68`](https://github.com/mastra-ai/mastra/commit/9e16c6818b6485ccb43df28aba6f3a2219d28662), [`cefca33`](https://github.com/mastra-ai/mastra/commit/cefca33ae666e69810c935fedf95a929c173d1d7), [`d00e8c5`](https://github.com/mastra-ai/mastra/commit/d00e8c50daebe5bce5bf2f48bde39c86fc3d2fe4), [`36fa7e2`](https://github.com/mastra-ai/mastra/commit/36fa7e24d14e58a1eb46147097b32f583e5b8775), [`87e9774`](https://github.com/mastra-ai/mastra/commit/87e97741c1e493cd6d62f478eb810b49bda4d57c), [`65a72e7`](https://github.com/mastra-ai/mastra/commit/65a72e70c25eedea8ff985a6624b96be2850236b), [`fe9eacd`](https://github.com/mastra-ai/mastra/commit/fe9eacd9545a0a9d64aad31c9fa90294a425289e), [`4c02027`](https://github.com/mastra-ai/mastra/commit/4c020277235eaa6b1dc957c90ad0639eef213992), [`0f77241`](https://github.com/mastra-ai/mastra/commit/0f7724108806703799a8ba80ad0f09414afd5066), [`849efb9`](https://github.com/mastra-ai/mastra/commit/849efb9fca6dc976589c1f90a303fea618769109), [`92ff509`](https://github.com/mastra-ai/mastra/commit/92ff5098ef8a990438ca038077021a5f7541ec1d), [`3fce5e7`](https://github.com/mastra-ai/mastra/commit/3fce5e70d011d289043e75003ef3336ed4aa43c3), [`a763592`](https://github.com/mastra-ai/mastra/commit/a763592c3db46963ef1011cfe16fe372816e775e), [`db79c86`](https://github.com/mastra-ai/mastra/commit/db79c86c60723d57e02f9636ca2611bd4515f194), [`6855012`](https://github.com/mastra-ai/mastra/commit/685501247cc4717506f3e89beed03509d63a5370), [`80c7737`](https://github.com/mastra-ai/mastra/commit/80c7737e32d7917b5f356957d67c169d01744fd3), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`7fef31c`](https://github.com/mastra-ai/mastra/commit/7fef31c0d2a6d362a43a647a8a4f6ab893758a23), [`3f1cf47`](https://github.com/mastra-ai/mastra/commit/3f1cf476f74c1e4cc2df908837e05853a5347e31)]:
|
|
37
|
+
- @mastra/core@1.38.0
|
|
38
|
+
|
|
39
|
+
## 0.1.0-alpha.1
|
|
40
|
+
|
|
41
|
+
### Minor Changes
|
|
42
|
+
|
|
43
|
+
- Added `@mastra/cursor`, a package for running Cursor SDK agents through Mastra. ([#16906](https://github.com/mastra-ai/mastra/pull/16906))
|
|
44
|
+
|
|
45
|
+
Create a Cursor SDK agent, register it with Mastra, and call `generate()` or `stream()` with Mastra-compatible outputs. Runs keep Cursor SDK usage and observability data available to Mastra.
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { CursorSDKAgent } from '@mastra/cursor';
|
|
49
|
+
|
|
50
|
+
export const cursorAgent = new CursorSDKAgent({
|
|
51
|
+
id: 'cursor-sdk-agent',
|
|
52
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
53
|
+
sdkOptions: {
|
|
54
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
55
|
+
model: { id: process.env.CURSOR_MODEL_ID! },
|
|
56
|
+
local: {
|
|
57
|
+
cwd: process.cwd(),
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
});
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Patch Changes
|
|
64
|
+
|
|
65
|
+
- Updated dependencies:
|
|
66
|
+
- @mastra/core@1.38.0-alpha.7
|
|
67
|
+
|
|
68
|
+
## 0.1.0-alpha.0
|
|
69
|
+
|
|
70
|
+
Initial release.
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
Portions of this software are licensed as follows:
|
|
2
|
+
|
|
3
|
+
- All content that resides under any directory named "ee/" within this
|
|
4
|
+
repository, including but not limited to:
|
|
5
|
+
- `packages/core/src/auth/ee/`
|
|
6
|
+
- `packages/server/src/server/auth/ee/`
|
|
7
|
+
is licensed under the license defined in `ee/LICENSE`.
|
|
8
|
+
|
|
9
|
+
- All third-party components incorporated into the Mastra Software are
|
|
10
|
+
licensed under the original license provided by the owner of the
|
|
11
|
+
applicable component.
|
|
12
|
+
|
|
13
|
+
- Content outside of the above-mentioned directories or restrictions is
|
|
14
|
+
available under the "Apache License 2.0" as defined below.
|
|
15
|
+
|
|
16
|
+
# Apache License 2.0
|
|
17
|
+
|
|
18
|
+
Copyright (c) 2025 Kepler Software, Inc.
|
|
19
|
+
|
|
20
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
21
|
+
you may not use this file except in compliance with the License.
|
|
22
|
+
You may obtain a copy of the License at
|
|
23
|
+
|
|
24
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
25
|
+
|
|
26
|
+
Unless required by applicable law or agreed to in writing, software
|
|
27
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
28
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
29
|
+
See the License for the specific language governing permissions and
|
|
30
|
+
limitations under the License.
|
package/README.md
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# @mastra/cursor
|
|
2
|
+
|
|
3
|
+
`@mastra/cursor` connects Mastra to the Cursor SDK. Use it when you want to register a Cursor SDK agent with Mastra and call it through Mastra-compatible `generate()` and `stream()` methods.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @mastra/cursor @cursor/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Overview
|
|
12
|
+
|
|
13
|
+
The package exports `CursorSDKAgent`, a Mastra `Agent` wrapper around a Cursor SDK agent.
|
|
14
|
+
|
|
15
|
+
`CursorSDKAgent` keeps the Cursor SDK run loop in charge. Mastra receives compatible outputs, usage data, and tracing data for the run.
|
|
16
|
+
|
|
17
|
+
## Create a Cursor SDK agent
|
|
18
|
+
|
|
19
|
+
Pass Cursor SDK configuration through `sdkOptions`. `CursorSDKAgent` creates the Cursor SDK agent on first use.
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import { CursorSDKAgent } from '@mastra/cursor';
|
|
23
|
+
|
|
24
|
+
export const cursorAgent = new CursorSDKAgent({
|
|
25
|
+
id: 'cursor-sdk-agent',
|
|
26
|
+
name: 'Cursor SDK Agent',
|
|
27
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
28
|
+
sdkOptions: {
|
|
29
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
30
|
+
model: { id: process.env.CURSOR_MODEL_ID! },
|
|
31
|
+
local: {
|
|
32
|
+
cwd: process.cwd(),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
You can also pass an existing Cursor SDK agent when your app already creates or owns it.
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
import { Agent as CursorAgent } from '@cursor/sdk';
|
|
42
|
+
import { CursorSDKAgent } from '@mastra/cursor';
|
|
43
|
+
|
|
44
|
+
export const cursorAgent = new CursorSDKAgent({
|
|
45
|
+
id: 'cursor-sdk-agent',
|
|
46
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
47
|
+
agent: CursorAgent.create({
|
|
48
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
49
|
+
model: { id: process.env.CURSOR_MODEL_ID! },
|
|
50
|
+
local: {
|
|
51
|
+
cwd: process.cwd(),
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
});
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
You can register the wrapper anywhere Mastra accepts an `Agent`.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
61
|
+
|
|
62
|
+
export const mastra = new Mastra({
|
|
63
|
+
agents: {
|
|
64
|
+
cursorAgent,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
## Run the agent
|
|
70
|
+
|
|
71
|
+
```typescript
|
|
72
|
+
const result = await cursorAgent.generate('Find and explain the failing test.', {
|
|
73
|
+
runId: 'cursor-run',
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
console.log(result.text);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
const stream = await cursorAgent.stream('Inspect this repository and suggest the smallest fix.');
|
|
81
|
+
|
|
82
|
+
for await (const chunk of stream.fullStream) {
|
|
83
|
+
if (chunk.type === 'text-delta') {
|
|
84
|
+
process.stdout.write(chunk.payload.text);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Configure Cursor
|
|
90
|
+
|
|
91
|
+
`CursorSDKAgent` forwards `sdkOptions` to `CursorAgent.create()` when `agent` is not provided or when `agent` is a factory. These include `apiKey`, `model`, `local`, `cloud`, `mcpServers`, `agents`, `agentId`, `idempotencyKey`, and `platform`.
|
|
92
|
+
|
|
93
|
+
`apiKey` defaults to `process.env.CURSOR_API_KEY` when it is not provided.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: mastra-cursor
|
|
3
|
+
description: Documentation for @mastra/cursor. Use when working with @mastra/cursor APIs, configuration, or implementation.
|
|
4
|
+
metadata:
|
|
5
|
+
package: "@mastra/cursor"
|
|
6
|
+
version: "0.0.0-declined-tool-result-fix-20260602220958"
|
|
7
|
+
---
|
|
8
|
+
|
|
9
|
+
## When to use
|
|
10
|
+
|
|
11
|
+
Use this skill whenever you are working with @mastra/cursor to obtain the domain-specific knowledge.
|
|
12
|
+
|
|
13
|
+
## How to use
|
|
14
|
+
|
|
15
|
+
Read the individual reference documents for detailed explanations and code examples.
|
|
16
|
+
|
|
17
|
+
### Docs
|
|
18
|
+
|
|
19
|
+
- [SDK agents](references/docs-agents-sdk-agents.md) - Use Claude Agent SDK and Cursor Agent SDK agents from Mastra.
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Read [assets/SOURCE_MAP.json](assets/SOURCE_MAP.json) for source code references.
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# SDK agents
|
|
2
|
+
|
|
3
|
+
SDK agents let you use other agent SDK frameworks inside Mastra. Use them to register SDK-backed agents in a Mastra project while the provider SDK keeps its own runtime, tools, permissions, and agent loop.
|
|
4
|
+
|
|
5
|
+
## When to use SDK agents
|
|
6
|
+
|
|
7
|
+
- A vendor SDK already owns the agent loop, tools, permissions, or local runtime.
|
|
8
|
+
- You want to register that SDK-backed agent in a Mastra project.
|
|
9
|
+
- You need Mastra-compatible `generate()` and `stream()` outputs.
|
|
10
|
+
- You want usage, cost, and tool activity from the SDK run to appear in Mastra observability.
|
|
11
|
+
|
|
12
|
+
## Supported SDK agents
|
|
13
|
+
|
|
14
|
+
- [Claude Agent SDK](#claude-agent-sdk): Use `@mastra/claude` to register a Claude SDK agent and call it with Mastra `generate()` and `stream()`.
|
|
15
|
+
- [Cursor Agent SDK](#cursor-agent-sdk): Use `@mastra/cursor` to register a Cursor SDK agent and call it with Mastra `generate()` and `stream()`.
|
|
16
|
+
|
|
17
|
+
## Claude Agent SDK
|
|
18
|
+
|
|
19
|
+
Use `@mastra/claude` for Claude Code runtime configuration, permissions, tools, and agent-loop behavior.
|
|
20
|
+
|
|
21
|
+
### Install Claude packages
|
|
22
|
+
|
|
23
|
+
Install the Mastra package and the Claude Agent SDK peer dependency:
|
|
24
|
+
|
|
25
|
+
**npm**:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
npm install @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
**pnpm**:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pnpm add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**Yarn**:
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
yarn add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
**Bun**:
|
|
44
|
+
|
|
45
|
+
```bash
|
|
46
|
+
bun add @mastra/claude @anthropic-ai/claude-agent-sdk
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Set the Claude SDK credential:
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
export ANTHROPIC_API_KEY="..."
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### Create a Claude SDK agent
|
|
56
|
+
|
|
57
|
+
Configure Claude Agent SDK through `sdkOptions`.
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { ClaudeSDKAgent } from '@mastra/claude'
|
|
61
|
+
|
|
62
|
+
export const claudeSDKAgent = new ClaudeSDKAgent({
|
|
63
|
+
id: 'claude-sdk-agent',
|
|
64
|
+
name: 'Claude SDK Agent',
|
|
65
|
+
description: 'Use Claude Agent SDK through Mastra.',
|
|
66
|
+
sdkOptions: {
|
|
67
|
+
model: 'claude-sonnet-4-6',
|
|
68
|
+
cwd: process.cwd(),
|
|
69
|
+
},
|
|
70
|
+
})
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
### Add Claude SDK tools
|
|
74
|
+
|
|
75
|
+
Claude Agent SDK tools are provided through Claude SDK Model Context Protocol (MCP) servers. Create the server with the Claude SDK, then pass it through `sdkOptions.mcpServers`.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
import { createSdkMcpServer } from '@anthropic-ai/claude-agent-sdk'
|
|
79
|
+
import { ClaudeSDKAgent } from '@mastra/claude'
|
|
80
|
+
import { getTemperature } from '../tools/get-temperature'
|
|
81
|
+
|
|
82
|
+
const weatherServer = createSdkMcpServer({
|
|
83
|
+
name: 'weather',
|
|
84
|
+
version: '1.0.0',
|
|
85
|
+
tools: [getTemperature],
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export const claudeSDKAgent = new ClaudeSDKAgent({
|
|
89
|
+
id: 'claude-sdk-agent',
|
|
90
|
+
name: 'Claude SDK Agent',
|
|
91
|
+
description: 'Use Claude Agent SDK through Mastra.',
|
|
92
|
+
sdkOptions: {
|
|
93
|
+
model: 'claude-sonnet-4-6',
|
|
94
|
+
cwd: process.cwd(),
|
|
95
|
+
mcpServers: {
|
|
96
|
+
weather: weatherServer,
|
|
97
|
+
},
|
|
98
|
+
allowedTools: ['mcp__weather__get_temperature'],
|
|
99
|
+
},
|
|
100
|
+
})
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
The `allowedTools` value uses Claude Agent SDK MCP tool naming: `mcp__<server name>__<tool name>`.
|
|
104
|
+
|
|
105
|
+
## Cursor Agent SDK
|
|
106
|
+
|
|
107
|
+
Use `@mastra/cursor` to register a Cursor SDK agent in Mastra while keeping Cursor-specific setup in Cursor SDK options.
|
|
108
|
+
|
|
109
|
+
### Install Cursor packages
|
|
110
|
+
|
|
111
|
+
Install the Mastra package and the Cursor SDK peer dependency:
|
|
112
|
+
|
|
113
|
+
**npm**:
|
|
114
|
+
|
|
115
|
+
```bash
|
|
116
|
+
npm install @mastra/cursor @cursor/sdk
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**pnpm**:
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
pnpm add @mastra/cursor @cursor/sdk
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
**Yarn**:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
yarn add @mastra/cursor @cursor/sdk
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Bun**:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
bun add @mastra/cursor @cursor/sdk
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
Set the Cursor SDK credential:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
export CURSOR_API_KEY="..."
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Create a Cursor SDK agent
|
|
144
|
+
|
|
145
|
+
Configure Cursor Agent SDK through `sdkOptions`.
|
|
146
|
+
|
|
147
|
+
```typescript
|
|
148
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
149
|
+
|
|
150
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
151
|
+
id: 'cursor-sdk-agent',
|
|
152
|
+
name: 'Cursor SDK Agent',
|
|
153
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
154
|
+
sdkOptions: {
|
|
155
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
156
|
+
model: {
|
|
157
|
+
id: 'gpt-5.5',
|
|
158
|
+
},
|
|
159
|
+
local: {
|
|
160
|
+
cwd: process.cwd(),
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Cursor local agents require an explicit model. Set it in `sdkOptions.model`.
|
|
167
|
+
|
|
168
|
+
### Use an existing Cursor SDK agent
|
|
169
|
+
|
|
170
|
+
If your app already creates a Cursor SDK agent, pass that agent to `CursorSDKAgent` instead:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
import { Agent as CursorAgent } from '@cursor/sdk'
|
|
174
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
175
|
+
|
|
176
|
+
const cursorAgent = CursorAgent.create({
|
|
177
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
178
|
+
model: {
|
|
179
|
+
id: 'gpt-5.5',
|
|
180
|
+
},
|
|
181
|
+
local: {
|
|
182
|
+
cwd: process.cwd(),
|
|
183
|
+
},
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
187
|
+
id: 'cursor-sdk-agent',
|
|
188
|
+
name: 'Cursor SDK Agent',
|
|
189
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
190
|
+
agent: cursorAgent,
|
|
191
|
+
})
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
### Add Cursor SDK tools
|
|
195
|
+
|
|
196
|
+
Cursor Agent SDK tools are configured with Cursor SDK options. Pass Model Context Protocol (MCP) servers through `sdkOptions.mcpServers`:
|
|
197
|
+
|
|
198
|
+
```typescript
|
|
199
|
+
import { CursorSDKAgent } from '@mastra/cursor'
|
|
200
|
+
import { mcpServers } from '../mcp/cursor'
|
|
201
|
+
|
|
202
|
+
export const cursorSDKAgent = new CursorSDKAgent({
|
|
203
|
+
id: 'cursor-sdk-agent',
|
|
204
|
+
name: 'Cursor SDK Agent',
|
|
205
|
+
description: 'Use Cursor Agent SDK through Mastra.',
|
|
206
|
+
sdkOptions: {
|
|
207
|
+
apiKey: process.env.CURSOR_API_KEY,
|
|
208
|
+
model: {
|
|
209
|
+
id: 'gpt-5.5',
|
|
210
|
+
},
|
|
211
|
+
local: {
|
|
212
|
+
cwd: process.cwd(),
|
|
213
|
+
},
|
|
214
|
+
mcpServers,
|
|
215
|
+
},
|
|
216
|
+
})
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
## Register SDK agents
|
|
220
|
+
|
|
221
|
+
Register SDK agents in the Mastra instance like other agents:
|
|
222
|
+
|
|
223
|
+
```typescript
|
|
224
|
+
import { Mastra } from '@mastra/core'
|
|
225
|
+
import { claudeSDKAgent } from './agents/claude-sdk-agent'
|
|
226
|
+
import { cursorSDKAgent } from './agents/cursor-sdk-agent'
|
|
227
|
+
|
|
228
|
+
export const mastra = new Mastra({
|
|
229
|
+
agents: {
|
|
230
|
+
claudeSDKAgent,
|
|
231
|
+
cursorSDKAgent,
|
|
232
|
+
},
|
|
233
|
+
})
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
After registration, call them with `mastra.getAgentById()`:
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import { mastra } from './index'
|
|
240
|
+
|
|
241
|
+
const agent = mastra.getAgentById('cursor-sdk-agent')
|
|
242
|
+
const stream = await agent.stream('Inspect this project and describe the test setup.')
|
|
243
|
+
|
|
244
|
+
for await (const chunk of stream.textStream) {
|
|
245
|
+
process.stdout.write(chunk)
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
## Observability
|
|
250
|
+
|
|
251
|
+
SDK agents create Mastra agent and model spans for `generate()` and `stream()` calls. Mastra records SDK-provided usage, tool activity, and provider metadata when the vendor SDK exposes those events.
|
|
252
|
+
|
|
253
|
+
Claude SDK runs can include SDK-estimated cost from the Claude result message. Cursor SDK runs include token usage from Cursor interaction updates.
|
|
254
|
+
|
|
255
|
+
For storage and dashboard setup, see [Observability](https://mastra.ai/docs/observability/overview).
|
|
256
|
+
|
|
257
|
+
## Related
|
|
258
|
+
|
|
259
|
+
- [Agents overview](https://mastra.ai/docs/agents/overview)
|
|
260
|
+
- [Tools](https://mastra.ai/docs/agents/using-tools)
|
|
261
|
+
- [Observability](https://mastra.ai/docs/observability/overview)
|