@mastra/claude 0.3.1-alpha.0 → 0.3.1
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/README.md +13 -74
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,105 +1,44 @@
|
|
|
1
1
|
# @mastra/claude
|
|
2
2
|
|
|
3
|
-
`@mastra/claude` connects Mastra to the Claude Agent SDK. Use it when you want
|
|
3
|
+
`@mastra/claude` connects Mastra to the Claude Agent SDK. Use it when you want Claude Code's agent loop, tools, permissions, and runtime configuration while exposing the agent through Mastra-compatible `generate()` and `stream()` methods.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
npm install @mastra/claude
|
|
8
|
+
npm install @mastra/claude
|
|
9
|
+
npm install @anthropic-ai/claude-agent-sdk
|
|
9
10
|
```
|
|
10
11
|
|
|
11
|
-
##
|
|
12
|
+
## Usage
|
|
12
13
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
`ClaudeSDKAgent` keeps the Claude SDK run loop in charge. Mastra receives compatible outputs, usage, cost estimates, and tracing data for the run.
|
|
16
|
-
|
|
17
|
-
## Create a Claude SDK agent
|
|
18
|
-
|
|
19
|
-
Pass Claude SDK configuration through `sdkOptions`.
|
|
14
|
+
Set `ANTHROPIC_API_KEY` before creating the agent.
|
|
20
15
|
|
|
21
16
|
```typescript
|
|
22
17
|
import { ClaudeSDKAgent } from '@mastra/claude';
|
|
18
|
+
import { Mastra } from '@mastra/core/mastra';
|
|
23
19
|
|
|
24
20
|
export const claudeAgent = new ClaudeSDKAgent({
|
|
25
21
|
id: 'claude-sdk-agent',
|
|
26
22
|
name: 'Claude SDK Agent',
|
|
27
23
|
description: 'Use Claude Agent SDK through Mastra.',
|
|
28
24
|
sdkOptions: {
|
|
29
|
-
model: process.env.CLAUDE_CODE_MODEL,
|
|
30
25
|
cwd: process.cwd(),
|
|
31
26
|
},
|
|
32
27
|
});
|
|
33
|
-
```
|
|
34
|
-
|
|
35
|
-
You can register the wrapper anywhere Mastra accepts an `Agent`.
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
import { Mastra } from '@mastra/core/mastra';
|
|
39
28
|
|
|
40
29
|
export const mastra = new Mastra({
|
|
41
|
-
agents: {
|
|
42
|
-
claudeAgent,
|
|
43
|
-
},
|
|
30
|
+
agents: { claudeAgent },
|
|
44
31
|
});
|
|
45
32
|
```
|
|
46
33
|
|
|
47
|
-
##
|
|
34
|
+
## Documentation
|
|
48
35
|
|
|
49
|
-
|
|
50
|
-
const result = await claudeAgent.generate('Summarize the latest changes in this repository.', {
|
|
51
|
-
runId: 'claude-run',
|
|
52
|
-
});
|
|
36
|
+
- [Claude Agent SDK integration](https://mastra.ai/docs/connections/sdk-agents#claude-agent-sdk)
|
|
53
37
|
|
|
54
|
-
|
|
55
|
-
```
|
|
38
|
+
## Changelog
|
|
56
39
|
|
|
57
|
-
|
|
58
|
-
const stream = await claudeAgent.stream('Review this package for test gaps.');
|
|
40
|
+
See the [package changelog](https://github.com/mastra-ai/mastra/blob/main/agent-sdks/claude/CHANGELOG.md) for version history and release notes.
|
|
59
41
|
|
|
60
|
-
|
|
61
|
-
if (chunk.type === 'text-delta') {
|
|
62
|
-
process.stdout.write(chunk.payload.text);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
```
|
|
42
|
+
## Support
|
|
66
43
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
`ClaudeSDKAgent` forwards `sdkOptions` to the Claude SDK `query()` call on every run.
|
|
70
|
-
|
|
71
|
-
For custom tools, create a Claude SDK MCP server and pass it with `mcpServers`.
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
import { createSdkMcpServer, tool } from '@anthropic-ai/claude-agent-sdk';
|
|
75
|
-
import { ClaudeSDKAgent } from '@mastra/claude';
|
|
76
|
-
import { z } from 'zod';
|
|
77
|
-
|
|
78
|
-
const weatherServer = createSdkMcpServer({
|
|
79
|
-
name: 'weather',
|
|
80
|
-
version: '1.0.0',
|
|
81
|
-
tools: [
|
|
82
|
-
tool(
|
|
83
|
-
'get_temperature',
|
|
84
|
-
'Get the current temperature.',
|
|
85
|
-
{
|
|
86
|
-
location: z.string(),
|
|
87
|
-
},
|
|
88
|
-
async ({ location }) => ({
|
|
89
|
-
content: [{ type: 'text', text: `Temperature for ${location}: 72F` }],
|
|
90
|
-
}),
|
|
91
|
-
),
|
|
92
|
-
],
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
export const claudeAgent = new ClaudeSDKAgent({
|
|
96
|
-
id: 'claude-sdk-agent',
|
|
97
|
-
description: 'Use Claude with weather tools.',
|
|
98
|
-
sdkOptions: {
|
|
99
|
-
mcpServers: {
|
|
100
|
-
weather: weatherServer,
|
|
101
|
-
},
|
|
102
|
-
allowedTools: ['mcp__weather__get_temperature'],
|
|
103
|
-
},
|
|
104
|
-
});
|
|
105
|
-
```
|
|
44
|
+
We have an [open community Discord](https://discord.gg/mastra-ai). Come and say hello and let us know if you have any questions or need any help getting things running.
|
package/dist/docs/SKILL.md
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/claude",
|
|
3
|
-
"version": "0.3.1
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Claude SDK package for Mastra",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"tsx": "^4.23.1",
|
|
35
35
|
"typescript": "^7.0.2",
|
|
36
36
|
"vitest": "4.1.10",
|
|
37
|
-
"@internal/
|
|
38
|
-
"@
|
|
39
|
-
"@
|
|
37
|
+
"@internal/lint": "0.0.130",
|
|
38
|
+
"@mastra/core": "1.64.0",
|
|
39
|
+
"@internal/types-builder": "0.0.105"
|
|
40
40
|
},
|
|
41
41
|
"homepage": "https://mastra.ai",
|
|
42
42
|
"repository": {
|