@mastra/mcp 0.10.7 → 0.10.8-alpha.0
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/.turbo/turbo-build.log +5 -5
- package/CHANGELOG.md +7 -0
- package/dist/index.cjs +4 -4
- package/dist/index.js +4 -4
- package/integration-tests/node_modules/.bin/vitest +2 -2
- package/integration-tests/package.json +2 -2
- package/integration-tests/src/mastra/agents/weather.ts +21 -7
- package/integration-tests/src/mastra/index.ts +3 -0
- package/integration-tests/src/server.test.ts +10 -4
- package/package.json +7 -7
- package/integration-tests/node_modules/.bin/mastra +0 -21
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
|
|
2
|
-
> @mastra/mcp@0.10.
|
|
2
|
+
> @mastra/mcp@0.10.8-alpha.0 build /home/runner/work/mastra/mastra/packages/mcp
|
|
3
3
|
> tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting
|
|
4
4
|
|
|
5
5
|
[34mCLI[39m Building entry: src/index.ts
|
|
6
6
|
[34mCLI[39m Using tsconfig: tsconfig.json
|
|
7
7
|
[34mCLI[39m tsup v8.5.0
|
|
8
8
|
[34mTSC[39m Build start
|
|
9
|
-
[32mTSC[39m ⚡️ Build success in
|
|
9
|
+
[32mTSC[39m ⚡️ Build success in 22811ms
|
|
10
10
|
[34mDTS[39m Build start
|
|
11
11
|
[34mCLI[39m Target: es2022
|
|
12
12
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
13
13
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.ts[39m
|
|
14
14
|
Analysis will use the bundled TypeScript version 5.8.3
|
|
15
15
|
[36mWriting package typings: /home/runner/work/mastra/mastra/packages/mcp/dist/_tsup-dts-rollup.d.cts[39m
|
|
16
|
-
[32mDTS[39m ⚡️ Build success in
|
|
16
|
+
[32mDTS[39m ⚡️ Build success in 31810ms
|
|
17
17
|
[34mCLI[39m Cleaning output folder
|
|
18
18
|
[34mESM[39m Build start
|
|
19
19
|
[34mCJS[39m Build start
|
|
20
20
|
[32mESM[39m [1mdist/index.js [22m[32m88.94 KB[39m
|
|
21
|
-
[32mESM[39m ⚡️ Build success in
|
|
21
|
+
[32mESM[39m ⚡️ Build success in 2367ms
|
|
22
22
|
[32mCJS[39m [1mdist/index.cjs [22m[32m89.72 KB[39m
|
|
23
|
-
[32mCJS[39m ⚡️ Build success in
|
|
23
|
+
[32mCJS[39m ⚡️ Build success in 2366ms
|
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1022,7 +1022,7 @@ var MCPConfiguration = class extends MCPClient {
|
|
|
1022
1022
|
}
|
|
1023
1023
|
};
|
|
1024
1024
|
|
|
1025
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1025
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/utils/stream.js
|
|
1026
1026
|
var StreamingApi = class {
|
|
1027
1027
|
writer;
|
|
1028
1028
|
encoder;
|
|
@@ -1089,7 +1089,7 @@ var StreamingApi = class {
|
|
|
1089
1089
|
}
|
|
1090
1090
|
};
|
|
1091
1091
|
|
|
1092
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1092
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/helper/streaming/utils.js
|
|
1093
1093
|
var isOldBunVersion = () => {
|
|
1094
1094
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
1095
1095
|
if (version === void 0) {
|
|
@@ -1100,7 +1100,7 @@ var isOldBunVersion = () => {
|
|
|
1100
1100
|
return result;
|
|
1101
1101
|
};
|
|
1102
1102
|
|
|
1103
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1103
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/utils/html.js
|
|
1104
1104
|
var HtmlEscapedCallbackPhase = {
|
|
1105
1105
|
Stringify: 1};
|
|
1106
1106
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -1131,7 +1131,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
1131
1131
|
}
|
|
1132
1132
|
};
|
|
1133
1133
|
|
|
1134
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1134
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/helper/streaming/sse.js
|
|
1135
1135
|
var SSEStreamingApi = class extends StreamingApi {
|
|
1136
1136
|
constructor(writable, readable) {
|
|
1137
1137
|
super(writable, readable);
|
package/dist/index.js
CHANGED
|
@@ -1015,7 +1015,7 @@ var MCPConfiguration = class extends MCPClient {
|
|
|
1015
1015
|
}
|
|
1016
1016
|
};
|
|
1017
1017
|
|
|
1018
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1018
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/utils/stream.js
|
|
1019
1019
|
var StreamingApi = class {
|
|
1020
1020
|
writer;
|
|
1021
1021
|
encoder;
|
|
@@ -1082,7 +1082,7 @@ var StreamingApi = class {
|
|
|
1082
1082
|
}
|
|
1083
1083
|
};
|
|
1084
1084
|
|
|
1085
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1085
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/helper/streaming/utils.js
|
|
1086
1086
|
var isOldBunVersion = () => {
|
|
1087
1087
|
const version = typeof Bun !== "undefined" ? Bun.version : void 0;
|
|
1088
1088
|
if (version === void 0) {
|
|
@@ -1093,7 +1093,7 @@ var isOldBunVersion = () => {
|
|
|
1093
1093
|
return result;
|
|
1094
1094
|
};
|
|
1095
1095
|
|
|
1096
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1096
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/utils/html.js
|
|
1097
1097
|
var HtmlEscapedCallbackPhase = {
|
|
1098
1098
|
Stringify: 1};
|
|
1099
1099
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
@@ -1124,7 +1124,7 @@ var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) =>
|
|
|
1124
1124
|
}
|
|
1125
1125
|
};
|
|
1126
1126
|
|
|
1127
|
-
// ../../node_modules/.pnpm/hono@4.8.
|
|
1127
|
+
// ../../node_modules/.pnpm/hono@4.8.9/node_modules/hono/dist/helper/streaming/sse.js
|
|
1128
1128
|
var SSEStreamingApi = class extends StreamingApi {
|
|
1129
1129
|
constructor(writable, readable) {
|
|
1130
1130
|
super(writable, readable);
|
|
@@ -10,9 +10,9 @@ case `uname` in
|
|
|
10
10
|
esac
|
|
11
11
|
|
|
12
12
|
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
13
|
+
export NODE_PATH="/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.9_@vitest+ui@3.2.3_jiti@2.4.2_jsdom@_0090e69ea15e68f4eaa34b37eb448faf/node_modules/vitest/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.9_@vitest+ui@3.2.3_jiti@2.4.2_jsdom@_0090e69ea15e68f4eaa34b37eb448faf/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules"
|
|
14
14
|
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.
|
|
15
|
+
export NODE_PATH="/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.9_@vitest+ui@3.2.3_jiti@2.4.2_jsdom@_0090e69ea15e68f4eaa34b37eb448faf/node_modules/vitest/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/vitest@3.2.4_@types+debug@4.1.12_@types+node@20.19.9_@vitest+ui@3.2.3_jiti@2.4.2_jsdom@_0090e69ea15e68f4eaa34b37eb448faf/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
16
|
fi
|
|
17
17
|
if [ -x "$basedir/node" ]; then
|
|
18
18
|
exec "$basedir/node" "$basedir/../vitest/vitest.mjs" "$@"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
"@types/node": "^20.17.57",
|
|
21
21
|
"get-port": "^7.1.0",
|
|
22
22
|
"mastra": "workspace:*",
|
|
23
|
-
"typescript": "^5.8.
|
|
23
|
+
"typescript": "^5.8.3",
|
|
24
24
|
"vitest": "^3.2.4"
|
|
25
25
|
},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@mastra/core": ">=0.10.7-0 <0.
|
|
27
|
+
"@mastra/core": ">=0.10.7-0 <0.13.0-0"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -3,18 +3,32 @@ import { createTool } from '@mastra/core';
|
|
|
3
3
|
import { Agent } from '@mastra/core/agent';
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { weatherTool } from '../tools/weather';
|
|
6
|
+
import { MCPClient } from '@mastra/mcp';
|
|
7
|
+
|
|
8
|
+
const client = new MCPClient({
|
|
9
|
+
id: 'weather-server',
|
|
10
|
+
servers: {
|
|
11
|
+
weather: {
|
|
12
|
+
url: new URL(`http://localhost:4114/api/mcp/myMcpServer/mcp`),
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
});
|
|
6
16
|
|
|
7
17
|
export const weatherAgent = new Agent({
|
|
8
18
|
name: 'test',
|
|
9
19
|
instructions:
|
|
10
20
|
'You are a weather agent. When asked about weather in any city, use the get_weather tool with the city name as the postal code. When asked for clipboard contents you also get that.',
|
|
11
21
|
model: openai('gpt-4o'),
|
|
12
|
-
tools: {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
22
|
+
tools: async () => {
|
|
23
|
+
const tools = await client.getTools();
|
|
24
|
+
return {
|
|
25
|
+
get_weather: weatherTool,
|
|
26
|
+
clipboard: createTool({
|
|
27
|
+
id: 'clipboard',
|
|
28
|
+
description: 'Returns the contents of the users clipboard',
|
|
29
|
+
inputSchema: z.object({}),
|
|
30
|
+
}),
|
|
31
|
+
...tools,
|
|
32
|
+
};
|
|
19
33
|
},
|
|
20
34
|
});
|
|
@@ -2,21 +2,18 @@ import { spawn } from 'node:child_process';
|
|
|
2
2
|
import { MCPClient } from '@mastra/mcp';
|
|
3
3
|
import { describe, it, expect, beforeAll, afterAll, vi } from 'vitest';
|
|
4
4
|
import { ServerInfo } from '@mastra/core/mcp';
|
|
5
|
-
import getPort from 'get-port';
|
|
6
5
|
import path from 'node:path';
|
|
7
6
|
|
|
8
7
|
vi.setConfig({ testTimeout: 20000, hookTimeout: 20000 });
|
|
9
8
|
|
|
10
9
|
describe('MCPServer through Mastra HTTP Integration (Subprocess)', () => {
|
|
11
10
|
let mastraServer: ReturnType<typeof spawn>;
|
|
12
|
-
|
|
11
|
+
const port: number = 4114;
|
|
13
12
|
const mcpServerId = 'myMcpServer';
|
|
14
13
|
const testToolId = 'calculator';
|
|
15
14
|
let client: MCPClient;
|
|
16
15
|
|
|
17
16
|
beforeAll(async () => {
|
|
18
|
-
port = await getPort();
|
|
19
|
-
|
|
20
17
|
mastraServer = spawn(
|
|
21
18
|
'pnpm',
|
|
22
19
|
[
|
|
@@ -228,5 +225,14 @@ describe('MCPServer through Mastra HTTP Integration (Subprocess)', () => {
|
|
|
228
225
|
expect(body.next).toBeNull();
|
|
229
226
|
}
|
|
230
227
|
});
|
|
228
|
+
|
|
229
|
+
it('Should be able to get lazy loaded tools', async () => {
|
|
230
|
+
const agent = await fetch(`http://localhost:${port}/api/agents/test`);
|
|
231
|
+
const agentJson = await agent.json();
|
|
232
|
+
const tools = agentJson.tools;
|
|
233
|
+
|
|
234
|
+
expect(tools).toHaveProperty('weather_fetchWeather');
|
|
235
|
+
expect(Object.keys(tools).length).toBe(4);
|
|
236
|
+
});
|
|
231
237
|
});
|
|
232
238
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mastra/mcp",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.8-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,28 +31,28 @@
|
|
|
31
31
|
"zod-from-json-schema": "^0.0.5"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@mastra/core": ">=0.10.2-0 <0.
|
|
34
|
+
"@mastra/core": ">=0.10.2-0 <0.13.0-0",
|
|
35
35
|
"zod": "^3.0.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@ai-sdk/anthropic": "^1.2.12",
|
|
39
39
|
"@ai-sdk/openai": "^1.3.22",
|
|
40
|
-
"@hono/node-server": "^1.
|
|
41
|
-
"@mendable/firecrawl-js": "^1.
|
|
40
|
+
"@hono/node-server": "^1.17.1",
|
|
41
|
+
"@mendable/firecrawl-js": "^1.29.2",
|
|
42
42
|
"@microsoft/api-extractor": "^7.52.8",
|
|
43
43
|
"@types/node": "^20.19.0",
|
|
44
44
|
"ai": "4.3.16",
|
|
45
45
|
"eslint": "^9.30.1",
|
|
46
46
|
"hono-mcp-server-sse-transport": "0.0.7",
|
|
47
|
-
"hono": "^4.8.
|
|
47
|
+
"hono": "^4.8.9",
|
|
48
48
|
"tsup": "^8.5.0",
|
|
49
49
|
"tsx": "^4.19.4",
|
|
50
50
|
"typescript": "^5.8.3",
|
|
51
51
|
"vitest": "^3.2.4",
|
|
52
52
|
"zod": "^3.25.67",
|
|
53
53
|
"zod-to-json-schema": "^3.24.5",
|
|
54
|
-
"@mastra/core": "0.
|
|
55
|
-
"@internal/lint": "0.0.
|
|
54
|
+
"@mastra/core": "0.12.0-alpha.5",
|
|
55
|
+
"@internal/lint": "0.0.23"
|
|
56
56
|
},
|
|
57
57
|
"scripts": {
|
|
58
58
|
"build": "tsup src/index.ts --format esm,cjs --experimental-dts --clean --treeshake=smallest --splitting",
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/bin/sh
|
|
2
|
-
basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
|
|
3
|
-
|
|
4
|
-
case `uname` in
|
|
5
|
-
*CYGWIN*|*MINGW*|*MSYS*)
|
|
6
|
-
if command -v cygpath > /dev/null 2>&1; then
|
|
7
|
-
basedir=`cygpath -w "$basedir"`
|
|
8
|
-
fi
|
|
9
|
-
;;
|
|
10
|
-
esac
|
|
11
|
-
|
|
12
|
-
if [ -z "$NODE_PATH" ]; then
|
|
13
|
-
export NODE_PATH="/home/runner/work/mastra/mastra/packages/cli/dist/node_modules:/home/runner/work/mastra/mastra/packages/cli/node_modules:/home/runner/work/mastra/mastra/packages/node_modules:/home/runner/work/mastra/mastra/node_modules:/home/runner/work/mastra/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules"
|
|
14
|
-
else
|
|
15
|
-
export NODE_PATH="/home/runner/work/mastra/mastra/packages/cli/dist/node_modules:/home/runner/work/mastra/mastra/packages/cli/node_modules:/home/runner/work/mastra/mastra/packages/node_modules:/home/runner/work/mastra/mastra/node_modules:/home/runner/work/mastra/node_modules:/home/runner/work/node_modules:/home/runner/node_modules:/home/node_modules:/node_modules:/home/runner/work/mastra/mastra/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
16
|
-
fi
|
|
17
|
-
if [ -x "$basedir/node" ]; then
|
|
18
|
-
exec "$basedir/node" "$basedir/../mastra/dist/index.js" "$@"
|
|
19
|
-
else
|
|
20
|
-
exec node "$basedir/../mastra/dist/index.js" "$@"
|
|
21
|
-
fi
|