@mastra/mcp 2.3.0-alpha.1 → 2.4.0-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.
@@ -100,7 +100,8 @@ export declare class InternalMastraMCPClient extends MastraBase {
100
100
  /**
101
101
  * Request metadata every outgoing request carries: the per-request log-level
102
102
  * opt-in (when enabled) and the W3C trace fields resolved for this request,
103
- * merged under caller-supplied keys.
103
+ * merged under caller-supplied keys. A configured `traceContext` provider owns
104
+ * the trace fields; without one they name `span`, the span making the request.
104
105
  */
105
106
  private requestMeta;
106
107
  private buildStdioEnv;
@@ -1 +1 @@
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;AAI/C,OAAO,KAAK,EAAmB,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAShE,OAAO,KAAK,EAEV,eAAe,EACf,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAG3B,kBAAkB,EAMnB,MAAM,8BAA8B,CAAC;AAOtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAG3D,OAAO,KAAK,EAGV,eAAe,EAEf,8BAA8B,EAE9B,uBAAuB,EAEvB,6BAA6B,EAC9B,MAAM,SAAS,CAAC;AAIjB,YAAY,EACV,YAAY,EACZ,UAAU,EACV,UAAU,EACV,eAAe,EACf,eAAe,EACf,yBAAyB,EACzB,qBAAqB,EACrB,wBAAwB,EACxB,eAAe,EACf,sBAAsB,EACtB,8BAA8B,EAC9B,mBAAmB,EACnB,qBAAqB,EACrB,0BAA0B,EAC1B,6BAA6B,GAC9B,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;IACH,OAAO,CAAC,mBAAmB;IAY3B;;OAEG;IACG,eAAe,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,6BAA6B,CAAC,CAAC,CAU9E;IAED,OAAO,CAAC,wBAAwB;IAoBhC;;;OAGG;IACH,kBAAkB,CAAC,EAAE,UAAU,EAAE,EAAE;QAAE,UAAU,EAAE,6BAA6B,CAAA;KAAE,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CA4B1G;IAEK,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,CAgB/D;IAED;;;OAGG;IACH,OAAO,CAAC,sBAAsB;IAkO9B,OAAO,CAAC,mBAAmB;CAQ5B"}
@@ -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: "2.3.0-alpha.1"
6
+ version: "2.4.0-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "2.3.0-alpha.1",
2
+ "version": "2.4.0-alpha.0",
3
3
  "package": "@mastra/mcp",
4
4
  "exports": {},
5
5
  "modules": {}
@@ -79,7 +79,6 @@ resourceMapping: {
79
79
  - `user`: the authenticated user
80
80
  - `resourceId`: the owning Mastra resource ID when available (for example, a thread's `resourceId`)
81
81
  - `requestContext`: the current request context for advanced tenant resolution
82
- - `metadata`: provider-specific metadata for the attempted action
83
82
 
84
83
  Return `undefined` from `deriveId()` to fall back to the original Mastra resource ID.
85
84
 
@@ -78,10 +78,18 @@ Stored HTTP definitions don't accept arbitrary headers. When the reserved `mastr
78
78
 
79
79
  MCP tools can be allowlisted at two levels:
80
80
 
81
- 1. **Server level**: The stored server's `tools` map limits tools for every agent that uses the client.
82
- 2. **Agent level**: The agent's MCP client reference limits the remaining tools for that agent.
81
+ 1. **Server level**: The stored server's `tools` map limits tools for every agent that uses the client. Omitting `tools` at this level exposes all of the server's tools.
82
+ 2. **Agent level**: The agent's MCP client reference limits the remaining tools for that agent. Omitting `tools` at this level selects no tools.
83
83
 
84
- Agent-level tool names can use namespaced or bare names. An explicit empty `tools` map selects all tools. With the current resolver, omitting `tools` from an agent-level MCP reference selects none.
84
+ Agent-level tool names can use namespaced or bare names. To select every remaining tool at the agent level, pass an explicit empty `tools` map:
85
+
86
+ ```typescript
87
+ const mcpClients = {
88
+ 'docs-client': { tools: {} }, // all tools
89
+ 'search-client': { tools: { docs_search: {} } }, // only docs_search
90
+ 'billing-client': {}, // no tools
91
+ }
92
+ ```
85
93
 
86
94
  ### Namespacing
87
95
 
@@ -16,12 +16,12 @@ Streamable HTTP still streams responses as Server-Sent Events. What's removed is
16
16
 
17
17
  ### `@mastra/core` peer range
18
18
 
19
- `@mastra/mcp` 2.0 requires `@mastra/core` 1.68 or newer, which adds the shared server contract (`mcpVersion`, `MCPToolExecutionResultV2`, `context.mcp.protocolVersion`). Update both packages together.
19
+ `@mastra/mcp` 2.0 requires `@mastra/core` 1.76 or a later 1.x release, which includes the shared server contract (`mcpVersion`, `MCPToolExecutionResultV2`, `context.mcp.protocolVersion`). Update both packages together.
20
20
 
21
21
  ```diff
22
22
  - "@mastra/core": "^1.60.0",
23
23
  - "@mastra/mcp": "^1.17.0"
24
- + "@mastra/core": "^1.68.0",
24
+ + "@mastra/core": "^1.76.0",
25
25
  + "@mastra/mcp": "^2.0.0"
26
26
  ```
27
27
 
@@ -76,7 +76,7 @@ The client speaks the MCP `2026-07-28` revision. On connect it asks the server w
76
76
 
77
77
  **enableProgressTracking** (`boolean`): Whether to send a progressToken with tool calls so the server can report progress. See the progress property. (Default: `false`)
78
78
 
79
- **traceContext** (`() => MCPTraceContext | undefined`): Returns the W3C traceparent, optional tracestate and baggage to send as request \_meta on every call to this server. Called when each request is sent so it can read a request-local carrier. Explicit \_meta keys on a tool call take precedence. Servers built with MCPServer expose the received values to tools as requestContext.get("traceContext"); they are observability data and are never used for authorization.
79
+ **traceContext** (`() => MCPTraceContext | undefined`): Returns the W3C traceparent, optional tracestate and baggage to send as request \_meta on every call to this server. Called when each request is sent so it can read a request-local carrier. Without this option, a tool call made by a traced agent or workflow sends the traceparent of its tool call span. When the reply names the server span that handled the call, as MCPServer does, the tool call span links to it. Set this option to send your own trace context, or return undefined to send none. Explicit \_meta keys on a tool call take precedence. Servers built with MCPServer link their request span to the span the traceparent names and expose the received values to tools as requestContext.get("traceContext"); they are observability data and are never used for authorization.
80
80
 
81
81
  **forwardInstructions** (`boolean`): Whether to append instructions advertised by this MCP server to an agent's system prompt when the agent uses this server's tools. Disabled by default; enable it only for servers you trust, since the instructions are injected into the agent's system prompt. (Default: `false`)
82
82
 
@@ -856,6 +856,23 @@ The span is named after the method and target (for example `tools/call lookupOrd
856
856
 
857
857
  A standalone `MCPServer` with no `mastra` instance produces no spans.
858
858
 
859
+ ### Linking to the caller's trace
860
+
861
+ A request that carries a W3C `traceparent` keeps its own trace, root span, and trace summary. Its request span links to the caller's span, so you can follow a tool call from the caller's trace to the request it started.
862
+
863
+ With a tracing bridge, the request span starts under the span that's active when the request arrives. If HTTP instrumentation on the server continues the caller's trace from the `traceparent` header, the request joins the caller's trace instead of starting its own. Its link then points to a span in the same trace.
864
+
865
+ The server reads `traceparent` and `tracestate` from two places, in this order:
866
+
867
+ 1. The request `_meta`. `MCPClient` sends `traceparent` there for every traced tool call an agent or workflow makes, over HTTP and stdio.
868
+ 2. The HTTP headers. OpenTelemetry HTTP instrumentation in a non-Mastra caller sends them there.
869
+
870
+ The request span also records a valid `traceparent` as the `callerTraceparent` attribute, and the `tracestate` sent with it as `callerTracestate`, capped at 512 characters. Exporters without span link support still carry these attributes. A request without a valid `traceparent` gets no link and no caller attributes. The trace fields are left out of the span input.
871
+
872
+ The link also works in the other direction. When a `tools/call` request carried a `traceparent`, the reply's `_meta.mastra.traceparent` names the request span, and `MCPClient` adds a link from its tool call span to it. Callers that sent no trace context get nothing back.
873
+
874
+ Mastra storage saves the links with the spans. The OpenTelemetry exporter, [`OtelBridge`](https://mastra.ai/integrations/observability/opentelemetry), `DatadogBridge`, `DatadogExporter`, and `SentryExporter` send them as span links. `DatadogExporter` and `SentryExporter` give spans their own IDs, so a link between two Mastra spans doesn't resolve in those backends.
875
+
859
876
  ## Notification delivery
860
877
 
861
878
  Request-scoped notifications (`context.mcp.log()`, `context.mcp.progress()`) stream inside the request that triggered them, so they reach exactly the caller. Notifications that outlive a request (`resources.notifyListChanged()`, `prompts.notifyListChanged()`, `toolActions.notifyListChanged()`, `resources.notifyUpdated()`) are delivered on the `subscriptions/listen` stream each interested client keeps open. `resources.notifyUpdated()` only reaches clients whose stream includes that resource URI. List-changed notifications reach every client listening for that list. Over stdio the connection itself carries the stream.
package/dist/index.cjs CHANGED
@@ -38,6 +38,7 @@ let _mastra_core_tools = require("@mastra/core/tools");
38
38
  let _modelcontextprotocol_client = require("@modelcontextprotocol/client");
39
39
  let _modelcontextprotocol_client_stdio = require("@modelcontextprotocol/client/stdio");
40
40
  let exit_hook = require("exit-hook");
41
+ let _mastra_core_observability = require("@mastra/core/observability");
41
42
  let crypto$1 = require("crypto");
42
43
  let fast_deep_equal = require("fast-deep-equal");
43
44
  fast_deep_equal = __toESM$2(fast_deep_equal, 1);
@@ -45,7 +46,6 @@ let http = require("http");
45
46
  let _mastra_core_mcp = require("@mastra/core/mcp");
46
47
  let _mastra_core_schema = require("@mastra/core/schema");
47
48
  let fs = require("fs");
48
- let _mastra_core_observability = require("@mastra/core/observability");
49
49
  let _mastra_core_request_context = require("@mastra/core/request-context");
50
50
  let _mastra_core_utils = require("@mastra/core/utils");
51
51
  let _modelcontextprotocol_core = require("@modelcontextprotocol/core");
@@ -22322,21 +22322,21 @@ function rewrite(schema, depth, budget, isRoot = false) {
22322
22322
  }
22323
22323
  //#endregion
22324
22324
  //#region src/shared/mastra-tool-meta.ts
22325
- const MASTRA_META_KEY = "mastra";
22325
+ const MASTRA_META_KEY$1 = "mastra";
22326
22326
  const STRICT_META_KEY = "strict";
22327
22327
  function withMastraToolStrictMeta(meta, strict) {
22328
22328
  if (strict == null) return meta;
22329
- const mastraMeta = meta?.[MASTRA_META_KEY] && typeof meta[MASTRA_META_KEY] === "object" ? meta[MASTRA_META_KEY] : void 0;
22329
+ const mastraMeta = meta?.[MASTRA_META_KEY$1] && typeof meta[MASTRA_META_KEY$1] === "object" ? meta[MASTRA_META_KEY$1] : void 0;
22330
22330
  return {
22331
22331
  ...meta ?? {},
22332
- [MASTRA_META_KEY]: {
22332
+ [MASTRA_META_KEY$1]: {
22333
22333
  ...mastraMeta ?? {},
22334
22334
  [STRICT_META_KEY]: strict
22335
22335
  }
22336
22336
  };
22337
22337
  }
22338
22338
  function getMastraToolStrictMeta(meta) {
22339
- const mastraMeta = meta?.[MASTRA_META_KEY];
22339
+ const mastraMeta = meta?.[MASTRA_META_KEY$1];
22340
22340
  if (!mastraMeta || typeof mastraMeta !== "object") return;
22341
22341
  const strict = mastraMeta[STRICT_META_KEY];
22342
22342
  return typeof strict === "boolean" ? strict : void 0;
@@ -22430,6 +22430,122 @@ function traceContextToMeta(traceContext) {
22430
22430
  ...traceContext.baggage !== void 0 ? { [BAGGAGE_META_KEY]: traceContext.baggage } : {}
22431
22431
  };
22432
22432
  }
22433
+ /**
22434
+ * Request params without the W3C trace fields in `_meta`. They are removed
22435
+ * whenever present, valid or not: a valid caller span is recorded as a link,
22436
+ * and `tracestate` and `baggage` are untrusted data the span doesn't need.
22437
+ */
22438
+ function withoutTraceContext(params) {
22439
+ const meta = params?._meta;
22440
+ if (!meta || typeof meta !== "object" || Array.isArray(meta) || ![
22441
+ TRACEPARENT_META_KEY,
22442
+ TRACESTATE_META_KEY,
22443
+ BAGGAGE_META_KEY
22444
+ ].some((key) => key in meta)) return params;
22445
+ const { [TRACEPARENT_META_KEY]: _traceparent, [TRACESTATE_META_KEY]: _tracestate, [BAGGAGE_META_KEY]: _baggage, ...restMeta } = meta;
22446
+ const { _meta, ...rest } = params;
22447
+ return Object.keys(restMeta).length > 0 ? {
22448
+ ...rest,
22449
+ _meta: restMeta
22450
+ } : rest;
22451
+ }
22452
+ /**
22453
+ * Reads the caller's trace context from a `traceparent` and its `tracestate`.
22454
+ * A `traceparent` that doesn't parse yields nothing, and its `tracestate` is
22455
+ * ignored with it, as the W3C spec requires.
22456
+ */
22457
+ function callerTraceContext(traceparent, tracestate) {
22458
+ const parts = (0, _mastra_core_observability.parseTraceparent)(traceparent);
22459
+ if (!parts) return void 0;
22460
+ const cappedTracestate = typeof tracestate === "string" ? capTracestate(tracestate) : void 0;
22461
+ return {
22462
+ link: {
22463
+ traceId: parts.traceId,
22464
+ spanId: parts.spanId
22465
+ },
22466
+ traceparent: traceparent.trim(),
22467
+ ...cappedTracestate ? { tracestate: cappedTracestate } : {}
22468
+ };
22469
+ }
22470
+ const TRACESTATE_MAX_LENGTH = 512;
22471
+ const TRACESTATE_MAX_MEMBERS = 32;
22472
+ const TRACESTATE_LONG_MEMBER = 128;
22473
+ /**
22474
+ * Caps a `tracestate` at 512 characters the way the W3C spec asks: keep at most
22475
+ * 32 entries, drop entries longer than 128 characters first, then drop entries
22476
+ * from the end. Entries are never cut in the middle.
22477
+ * @see https://www.w3.org/TR/trace-context/#tracestate-limits
22478
+ */
22479
+ function capTracestate(value) {
22480
+ let members = value.split(",").map((member) => member.trim()).filter(Boolean).slice(0, TRACESTATE_MAX_MEMBERS);
22481
+ const length = () => members.join(",").length;
22482
+ if (length() > TRACESTATE_MAX_LENGTH) members = members.filter((member) => member.length <= TRACESTATE_LONG_MEMBER);
22483
+ while (members.length > 0 && length() > TRACESTATE_MAX_LENGTH) members.pop();
22484
+ return members.length > 0 ? members.join(",") : void 0;
22485
+ }
22486
+ /**
22487
+ * The trace context that makes `span` the parent of an outgoing request. A span
22488
+ * that is not recorded, or whose ids are not W3C-sized, propagates nothing. A
22489
+ * span hidden from exporters is replaced by its closest exported ancestor.
22490
+ */
22491
+ function traceContextFromSpan(span) {
22492
+ if (!span?.isValid) return void 0;
22493
+ const traceparent = (0, _mastra_core_observability.formatTraceparent)(span.traceId, (0, _mastra_core_observability.resolveExportedSpanId)(span) ?? "", true);
22494
+ return (0, _mastra_core_observability.parseTraceparent)(traceparent) ? { traceparent } : void 0;
22495
+ }
22496
+ /**
22497
+ * Reply `_meta` key under which a Mastra server returns the `traceparent` of the
22498
+ * span that served the request, so the caller can link back to it.
22499
+ */
22500
+ const MASTRA_META_KEY = "mastra";
22501
+ const SERVER_TRACEPARENT_KEY = "traceparent";
22502
+ /**
22503
+ * Adds the `traceparent` of `span`, the span serving the request, to the reply
22504
+ * `_meta`. Only callers that sent their own trace context get it back.
22505
+ */
22506
+ function withServerTraceContext(result, span, callerSentTrace) {
22507
+ const traceparent = callerSentTrace ? traceContextFromSpan(span)?.traceparent : void 0;
22508
+ if (!traceparent || !result || typeof result !== "object" || Array.isArray(result)) return result;
22509
+ const meta = result._meta ?? {};
22510
+ const mastraMeta = meta[MASTRA_META_KEY];
22511
+ return {
22512
+ ...result,
22513
+ _meta: {
22514
+ ...meta,
22515
+ [MASTRA_META_KEY]: {
22516
+ ...mastraMeta && typeof mastraMeta === "object" ? mastraMeta : {},
22517
+ [SERVER_TRACEPARENT_KEY]: traceparent
22518
+ }
22519
+ }
22520
+ };
22521
+ }
22522
+ /**
22523
+ * Splits the server's span out of a reply: returns the span the server named in
22524
+ * its reply `_meta`, if any, and the reply without that key.
22525
+ */
22526
+ function takeServerTraceContext(result) {
22527
+ const meta = result?._meta;
22528
+ const mastraMeta = meta?.[MASTRA_META_KEY];
22529
+ if (!mastraMeta || typeof mastraMeta !== "object" || !(SERVER_TRACEPARENT_KEY in mastraMeta)) return { result };
22530
+ const { [SERVER_TRACEPARENT_KEY]: traceparent, ...restMastra } = mastraMeta;
22531
+ const { [MASTRA_META_KEY]: _mastra, ...restMeta } = meta;
22532
+ const nextMeta = Object.keys(restMastra).length > 0 ? {
22533
+ ...restMeta,
22534
+ [MASTRA_META_KEY]: restMastra
22535
+ } : restMeta;
22536
+ const { _meta, ...rest } = result;
22537
+ const parts = (0, _mastra_core_observability.parseTraceparent)(traceparent);
22538
+ return {
22539
+ result: Object.keys(nextMeta).length > 0 ? {
22540
+ ...rest,
22541
+ _meta: nextMeta
22542
+ } : rest,
22543
+ ...parts ? { serverSpan: {
22544
+ traceId: parts.traceId,
22545
+ spanId: parts.spanId
22546
+ } } : {}
22547
+ };
22548
+ }
22433
22549
  //#endregion
22434
22550
  //#region src/client/actions/progress.ts
22435
22551
  /**
@@ -23337,10 +23453,11 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
23337
23453
  /**
23338
23454
  * Request metadata every outgoing request carries: the per-request log-level
23339
23455
  * opt-in (when enabled) and the W3C trace fields resolved for this request,
23340
- * merged under caller-supplied keys.
23456
+ * merged under caller-supplied keys. A configured `traceContext` provider owns
23457
+ * the trace fields; without one they name `span`, the span making the request.
23341
23458
  */
23342
- requestMeta(meta) {
23343
- const traceContext = this.serverConfig.traceContext?.();
23459
+ requestMeta(meta, span) {
23460
+ const traceContext = this.serverConfig.traceContext ? this.serverConfig.traceContext() : traceContextFromSpan(span);
23344
23461
  const merged = {
23345
23462
  ...this.serverLogLevel ? { [_modelcontextprotocol_client.LOG_LEVEL_META_KEY]: this.serverLogLevel } : {},
23346
23463
  ...traceContext ? traceContextToMeta(traceContext) : {},
@@ -24080,15 +24197,17 @@ var InternalMastraMCPClient = class extends _mastra_core_base.MastraBase {
24080
24197
  const _meta = this.requestMeta({
24081
24198
  ...context?._meta,
24082
24199
  ...progressMeta
24083
- });
24084
- const res = await this.client.callTool({
24200
+ }, context?.tracingContext?.currentSpan);
24201
+ const { result: res, serverSpan } = takeServerTraceContext(await this.client.callTool({
24085
24202
  name: tool.name,
24086
24203
  arguments: input,
24087
24204
  ..._meta ? { _meta } : {}
24088
24205
  }, {
24089
24206
  timeout: this.timeout,
24090
24207
  signal: context?.abortSignal
24091
- });
24208
+ }));
24209
+ const toolCallSpan = context?.tracingContext?.currentSpan;
24210
+ if (toolCallSpan && serverSpan) toolCallSpan.links = [...toolCallSpan.links ?? [], serverSpan];
24092
24211
  if (res.isError && this.onToolError === "throw") {
24093
24212
  const errorText = extractToolErrorText(res.content);
24094
24213
  this.log("debug", `Tool reported an error: ${tool.name}`, { error: errorText });
@@ -26162,6 +26281,16 @@ function toToolExecutionContext(ctx, loggerName) {
26162
26281
  };
26163
26282
  }
26164
26283
  /**
26284
+ * The caller's trace context a request names: `traceparent` and `tracestate` in
26285
+ * `_meta`, else the HTTP headers, which is where OpenTelemetry-instrumented hosts
26286
+ * put them.
26287
+ */
26288
+ function callerTrace(ctx) {
26289
+ const meta = ctx.mcpReq._meta;
26290
+ const headers = ctx.http?.req?.headers;
26291
+ return callerTraceContext(meta?.traceparent, meta?.tracestate) ?? callerTraceContext(headers?.get("traceparent"), headers?.get("tracestate"));
26292
+ }
26293
+ /**
26165
26294
  * Builds the trusted application context for one request. Auth is re-derived from
26166
26295
  * the transport every time; nothing is carried between continuation rounds. The W3C
26167
26296
  * trace fields sent by the client are exposed under `traceContext` as opaque
@@ -26581,29 +26710,33 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26581
26710
  setTracedHandler(server, method, handler) {
26582
26711
  server.setRequestHandler(method, async (request, ctx) => {
26583
26712
  const params = request.params;
26713
+ const caller = callerTrace(ctx);
26584
26714
  let requestContext;
26585
26715
  try {
26586
26716
  requestContext = await toRequestContext(ctx, this.mapAuthInfoToUser);
26587
26717
  } catch (error) {
26588
26718
  this.startRequestSpan(method, params, {
26589
26719
  server,
26590
- ctx
26720
+ ctx,
26721
+ caller
26591
26722
  })?.error({ error });
26592
26723
  throw error;
26593
26724
  }
26594
26725
  const requestSpan = this.startRequestSpan(method, params, {
26595
26726
  server,
26596
26727
  ctx,
26728
+ caller,
26597
26729
  requestContext
26598
26730
  });
26599
26731
  let reportedError;
26600
- return this.traceRequest(requestSpan, () => handler(request, ctx, {
26732
+ const result = await this.traceRequest(requestSpan, () => handler(request, ctx, {
26601
26733
  requestSpan,
26602
26734
  requestContext,
26603
26735
  reportError: (error) => {
26604
26736
  reportedError = error;
26605
26737
  }
26606
26738
  }), () => reportedError);
26739
+ return method === "tools/call" ? withServerTraceContext(result, requestSpan, caller !== void 0) : result;
26607
26740
  });
26608
26741
  }
26609
26742
  /**
@@ -26616,13 +26749,14 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26616
26749
  const client = envelope?.[_modelcontextprotocol_server.CLIENT_INFO_META_KEY] ?? connection?.server?.getClientVersion();
26617
26750
  const target = params?.name ?? params?.uri;
26618
26751
  const targetName = typeof target === "string" ? target : void 0;
26752
+ const caller = connection?.caller;
26619
26753
  return (0, _mastra_core_observability.getOrCreateSpan)({
26620
26754
  type: _mastra_core_observability.SpanType.MCP_SERVER_REQUEST,
26621
26755
  name: targetName ? `${method} ${targetName}` : method,
26622
26756
  entityType: _mastra_core_observability.EntityType.MCP_SERVER,
26623
26757
  entityId: this.id,
26624
26758
  entityName: this.name,
26625
- input: params,
26759
+ input: withoutTraceContext(params),
26626
26760
  attributes: {
26627
26761
  mcpMethod: method,
26628
26762
  targetName,
@@ -26630,9 +26764,12 @@ var MCPServer = class extends _mastra_core_mcp.MCPServerBase {
26630
26764
  serverVersion: this.version,
26631
26765
  mcpProtocolVersion: typeof protocolVersion === "string" ? protocolVersion : void 0,
26632
26766
  clientName: client?.name,
26633
- clientVersion: client?.version
26767
+ clientVersion: client?.version,
26768
+ callerTraceparent: caller?.traceparent,
26769
+ callerTracestate: caller?.tracestate
26634
26770
  },
26635
26771
  tracingContext: {},
26772
+ links: caller && [caller.link],
26636
26773
  requestContext: connection?.requestContext,
26637
26774
  mastra: this.mastra
26638
26775
  });