@mastra/mcp 1.6.0 → 1.6.1-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/CHANGELOG.md +9 -0
- package/dist/client/client.d.ts.map +1 -1
- package/dist/docs/SKILL.md +1 -2
- package/dist/docs/assets/SOURCE_MAP.json +1 -1
- package/dist/docs/references/reference-tools-mcp-server.md +1 -3
- package/dist/index.cjs +58 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +57 -2
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
- package/dist/docs/references/docs-mcp-publishing-mcp-server.md +0 -115
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @mastra/mcp
|
|
2
2
|
|
|
3
|
+
## 1.6.1-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Fixed trace parenting for long-lived MCP Stream connections. ([#15716](https://github.com/mastra-ai/mastra/pull/15716))
|
|
8
|
+
|
|
9
|
+
- Updated dependencies [[`6dcd65f`](https://github.com/mastra-ai/mastra/commit/6dcd65f2a34069e6dc43ba35f1d11119b9b40bef), [`1c2dda8`](https://github.com/mastra-ai/mastra/commit/1c2dda805fbfccc0abf55d4cb20cc34402dc3f0c)]:
|
|
10
|
+
- @mastra/core@1.31.1-alpha.0
|
|
11
|
+
|
|
3
12
|
## 1.6.0
|
|
4
13
|
|
|
5
14
|
### Minor Changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client/client.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAG/C,OAAO,KAAK,EAAE,IAAI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O,CAAC,2BAA2B,CAAC;IAOnE;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,iBAAiB,CAAC;IAO/C;;;;OAIG;IACG,SAAS,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;KAAE,GAAG,OAAO,CAAC,eAAe,CAAC;IASvG;;;OAGG;IACH,uCAAuC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOlE,qCAAqC,CAAC,OAAO,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,IAAI,GAAG,IAAI;IAO3E,yCAAyC,CAAC,OAAO,EAAE,MAAM,IAAI,GAAG,IAAI;IAOpE,4BAA4B,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IAQ/D,8BAA8B,CAAC,OAAO,EAAE,eAAe,GAAG,IAAI;YAOhD,kBAAkB;IAM1B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;CAgJjE"}
|
package/dist/docs/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: mastra-mcp
|
|
|
3
3
|
description: Documentation for @mastra/mcp. Use when working with @mastra/mcp APIs, configuration, or implementation.
|
|
4
4
|
metadata:
|
|
5
5
|
package: "@mastra/mcp"
|
|
6
|
-
version: "1.6.0"
|
|
6
|
+
version: "1.6.1-alpha.0"
|
|
7
7
|
---
|
|
8
8
|
|
|
9
9
|
## When to use
|
|
@@ -17,7 +17,6 @@ Read the individual reference documents for detailed explanations and code examp
|
|
|
17
17
|
### Docs
|
|
18
18
|
|
|
19
19
|
- [MCP overview](references/docs-mcp-overview.md) - Learn about the Model Context Protocol (MCP), how to use third-party tools via MCPClient, connect to registries, and share your own tools using MCPServer.
|
|
20
|
-
- [Publishing an MCP server](references/docs-mcp-publishing-mcp-server.md) - Guide to setting up and building a Mastra MCP server using the stdio transport, and publishing it to NPM.
|
|
21
20
|
|
|
22
21
|
### Reference
|
|
23
22
|
|
|
@@ -768,11 +768,9 @@ await serverWithPrompts.prompts.notifyListChanged()
|
|
|
768
768
|
- Handle errors with informative messages.
|
|
769
769
|
- Document argument expectations and available versions.
|
|
770
770
|
|
|
771
|
-
***
|
|
772
|
-
|
|
773
771
|
## Examples
|
|
774
772
|
|
|
775
|
-
For practical examples of setting up and deploying an MCPServer, see the [Publishing an MCP Server guide](https://mastra.ai/
|
|
773
|
+
For practical examples of setting up and deploying an MCPServer, see the [Publishing an MCP Server guide](https://mastra.ai/guides/guide/publishing-mcp-server).
|
|
776
774
|
|
|
777
775
|
The example at the beginning of this page also demonstrates how to instantiate `MCPServer` with both tools and agents.
|
|
778
776
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var async_hooks = require('async_hooks');
|
|
4
|
+
var module$1 = require('module');
|
|
4
5
|
var base = require('@mastra/core/base');
|
|
5
6
|
var tools = require('@mastra/core/tools');
|
|
6
7
|
var index_js = require('@modelcontextprotocol/sdk/client/index.js');
|
|
@@ -23,6 +24,7 @@ var stdio_js$1 = require('@modelcontextprotocol/sdk/server/stdio.js');
|
|
|
23
24
|
var streamableHttp_js$1 = require('@modelcontextprotocol/sdk/server/streamableHttp.js');
|
|
24
25
|
var auth_js = require('@modelcontextprotocol/sdk/client/auth.js');
|
|
25
26
|
|
|
27
|
+
var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
|
|
26
28
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
27
29
|
|
|
28
30
|
var equal__default = /*#__PURE__*/_interopDefault(equal);
|
|
@@ -421,7 +423,57 @@ function isReconnectableMCPError(error) {
|
|
|
421
423
|
|
|
422
424
|
// src/client/client.ts
|
|
423
425
|
var DEFAULT_SERVER_CONNECT_TIMEOUT_MSEC = 3e3;
|
|
426
|
+
var require2 = module$1.createRequire((typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('index.cjs', document.baseURI).href)));
|
|
424
427
|
var SSE_FALLBACK_STATUS_CODES = [400, 404, 405];
|
|
428
|
+
var DATADOG_TRACER_TEST_SYMBOL = /* @__PURE__ */ Symbol.for("mastra.mcp.dd-trace-test-tracer");
|
|
429
|
+
function shouldDetachPersistentTransportRequest(init) {
|
|
430
|
+
return (init?.method ?? "GET").toUpperCase() === "GET";
|
|
431
|
+
}
|
|
432
|
+
function getDatadogScope() {
|
|
433
|
+
const testTracer = globalThis[DATADOG_TRACER_TEST_SYMBOL];
|
|
434
|
+
const tracer = testTracer ?? loadDatadogTracer();
|
|
435
|
+
if (typeof tracer?.scope === "function") {
|
|
436
|
+
return tracer.scope();
|
|
437
|
+
}
|
|
438
|
+
if (typeof tracer?.default?.scope === "function") {
|
|
439
|
+
return tracer.default.scope();
|
|
440
|
+
}
|
|
441
|
+
return null;
|
|
442
|
+
}
|
|
443
|
+
function loadDatadogTracer() {
|
|
444
|
+
if (!isDatadogTracerLikelyLoaded()) {
|
|
445
|
+
return null;
|
|
446
|
+
}
|
|
447
|
+
try {
|
|
448
|
+
return require2("dd-trace");
|
|
449
|
+
} catch {
|
|
450
|
+
return null;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function isDatadogTracerLikelyLoaded() {
|
|
454
|
+
if (globalThis[DATADOG_TRACER_TEST_SYMBOL]) {
|
|
455
|
+
return true;
|
|
456
|
+
}
|
|
457
|
+
if (process.execArgv.some((arg) => arg.includes("dd-trace"))) {
|
|
458
|
+
return true;
|
|
459
|
+
}
|
|
460
|
+
if (process.env.NODE_OPTIONS?.includes("dd-trace")) {
|
|
461
|
+
return true;
|
|
462
|
+
}
|
|
463
|
+
try {
|
|
464
|
+
const resolvedPath = require2.resolve("dd-trace");
|
|
465
|
+
return Boolean(require2.cache[resolvedPath]);
|
|
466
|
+
} catch {
|
|
467
|
+
return false;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function runOutsideDatadogTraceScope(callback) {
|
|
471
|
+
const scope = getDatadogScope();
|
|
472
|
+
if (!scope) {
|
|
473
|
+
return callback();
|
|
474
|
+
}
|
|
475
|
+
return scope.activate(null, callback);
|
|
476
|
+
}
|
|
425
477
|
function convertLogLevelToLoggerMethod(level) {
|
|
426
478
|
switch (level) {
|
|
427
479
|
case "debug":
|
|
@@ -616,7 +668,11 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
616
668
|
}
|
|
617
669
|
async connectHttp(url) {
|
|
618
670
|
const { requestInit, eventSourceInit, authProvider, connectTimeout, fetch: userFetch } = this.serverConfig;
|
|
619
|
-
const fetch2 =
|
|
671
|
+
const fetch2 = (requestUrl, init) => {
|
|
672
|
+
const requestContext = this.operationContextStore.getStore() ?? null;
|
|
673
|
+
const executeFetch = () => userFetch ? userFetch(requestUrl, init, requestContext) : globalThis.fetch(requestUrl, init);
|
|
674
|
+
return shouldDetachPersistentTransportRequest(init) ? runOutsideDatadogTraceScope(executeFetch) : executeFetch();
|
|
675
|
+
};
|
|
620
676
|
this.log("debug", `Attempting to connect to URL: ${url}`);
|
|
621
677
|
let shouldTrySSE = url.pathname.endsWith(`/sse`);
|
|
622
678
|
if (!shouldTrySSE) {
|
|
@@ -645,7 +701,7 @@ var InternalMastraMCPClient = class extends base.MastraBase {
|
|
|
645
701
|
if (shouldTrySSE) {
|
|
646
702
|
this.log("debug", "Falling back to deprecated HTTP+SSE transport...");
|
|
647
703
|
try {
|
|
648
|
-
const sseEventSourceInit =
|
|
704
|
+
const sseEventSourceInit = { ...eventSourceInit, fetch: fetch2 };
|
|
649
705
|
const sseTransport = new sse_js.SSEClientTransport(url, {
|
|
650
706
|
requestInit,
|
|
651
707
|
eventSourceInit: sseEventSourceInit,
|