0
Fork 0
mirror of https://github.com/mastra-ai/mastra.git synced 2026-11-17 08:44:46 +00:00
mastra/packages/editor/src
Daniel Lew 4ba2bdef89
feat(server): memory, observability and agent builder MCP toolsets (#29931)
## Description

Adds four toolsets to the built-in MCP server at `/api/mcp`:

- `memory`: threads, messages, memory search, and Observational Memory.
`get_observations` can wait for pending Observational Memory work, for
example right after `call_agent`.
- `observability`: trace and span queries, logs, and trace trajectories.
- `observability_analytics`: `analyze_metrics`, `analyze_scores`, and
`analyze_feedback`, plus metric name and label lookups.
- `stored_agents`: list allowed models, and create, read, and update
stored agents.

With these, an MCP client such as Claude Code can create an agent, talk
to it, read what it remembered, and explain a slow trace.

### Behavior

- **On by default, shown only when supported.** Each toolset appears
only when the app has the matching capability (a memory-enabled agent,
an observability store that supports the queries, an editor for stored
agents). Apps that don't set `server.mcp.toolsets` get these tools on
upgrade, including write tools. Set `toolsets` to keep the previous set,
or `readOnly: true` to drop writes. The changeset says this.
- **Same checks as HTTP.** Every tool dispatches through its HTTP route,
so authentication, RBAC, FGA, thread ownership, and agent visibility
apply unchanged. No MCP caller gets more access than the same caller
over HTTP.
- **Observability isn't scoped per user.** Anyone with
`observability:read` sees all traces, as over HTTP. The docs show how to
leave those toolsets out.
- **Builder model policy.** When the agent builder restricts models,
`create_stored_agent` and `update_stored_agent` check the model the
agent runs (`provider` and `name`, in every conditional variant; other
keys on `model` are rejected), models named in `defaultOptions` such as
`structuredOutput.model`, enabled fallback models (`modelList`), memory
models, input and output processor models, and the defaults they fall
back to. Anything the policy can't check is rejected. The HTTP
stored-agent routes don't apply this check. Agents created or updated
over MCP are published immediately (`update_stored_agent` defaults
`autoPublish` to `true`).
- **Results fit MCP client limits.** `get_trace` returns light span
records with every span id, and `get_span` returns one span in full.
Long lists are cut to fit, with a note on how to get the rest, and a
single oversized item has its long values shortened (ids are never cut).
- **Errors.** Bad `analyze_*` and `list_metric_names` arguments return
400. A failed observability store lookup is retried on the next request
instead of hiding the observability tools until restart.

Stacked on #29930.

## Test plan

- `@mastra/server`: unit tests for the toolsets, capability detection,
result sizing, and schemas.
- Shared adapter suite (`builtin-mcp-toolsets-test-suite`) on Hono,
Express, Fastify, Koa, Elysia, and NestJS: memory ownership compared
with HTTP on the same request, read-only mode, analytics dispatch, and
argument errors. Hono also runs observability tests against in-memory,
LibSQL, and DuckDB stores.
- `@mastra/editor` integration tests for the builder model policy across
`model` (static and conditional), `defaultOptions`, fallback models,
memory, and processors. They need no provider API keys.
- Run end to end with two users over MCP and HTTP, and with Claude Code.

---------

Co-authored-by: mastracode <284800079+mastra-platform[bot]@users.noreply.github.com>
History 2026-11-12 10:25:19 -08:00
..
ee fix(editor): stop the builder agent config from hitting TS2590 (#29899) 2026-11-10 14:06:16 +01:00
namespaces fix(server): enforce stored-agent visibility on every route that resolves an agent (#29927) 2026-11-12 12:30:07 -05:00
providers feat(editor): support Composio shared connected accounts (#26002) 2026-10-05 17:27:54 -04:00
storage feat(editor): FilesystemStore adapter with code agent override support (#13727) 2026-03-04 12:09:28 -05:00
apply-stored-overrides.test.ts feat(editor): make model fallback lists editable and persistent (#27287) 2026-11-02 18:53:39 +01:00
arcade.ts feat(editor): mcp, tools, integrationTools (#12974) 2026-02-12 13:07:02 -05:00
builtin-mcp-stored-agents.integration.test.ts feat(server): memory, observability and agent builder MCP toolsets (#29931) 2026-11-12 10:25:19 -08:00
composio.ts feat(editor): route Composio tools by invoker identity (#21783) 2026-08-18 12:07:14 -07:00
editor-integration-tools.test.ts chore: migrate linting to oxlint (#20173) 2026-07-25 01:04:02 +02:00
editor-libsql.integration.test.ts chore: migrate linting to oxlint (#20173) 2026-07-25 01:04:02 +02:00
editor-mcp-server.test.ts chore: migrate linting to oxlint (#20173) 2026-07-25 01:04:02 +02:00
editor-mcp.test.ts docs(editor): clarify that omitting agent-level MCP tools selects none (#26738) 2026-10-12 11:17:35 +02:00
editor-memory-ref.test.ts feat(editor): let stored agents reference registered Memory instances (#25850) 2026-10-02 14:10:05 -07:00
editor-processors.test.ts feat(editor): processor providers and stored processor graphs (#13219) 2026-02-19 13:30:58 -05:00
editor-scorers.test.ts fix(editor): unregister version-specific stored scorers on clearCache() (#25544) 2026-09-29 23:54:02 -07:00
editor-skills.test.ts feat(core): run agentic loop on the evented workflow engine (#16796) 2026-06-09 00:13:36 +01:00
editor-workspace-reconciliation.test.ts chore: migrate linting to oxlint (#20173) 2026-07-25 01:04:02 +02:00
editor-workspaces.test.ts fix(editor): stable inline workspace identity independent of config key order (#24009) 2026-09-15 09:52:49 -07:00
editor.test.ts feat(editor): workflow builder backend and client SDK plumbing (#23493) 2026-09-14 09:58:00 +02:00
index.ts feat(editor): workflow builder backend and client SDK plumbing (#23493) 2026-09-14 09:58:00 +02:00
instruction-builder.test.ts feat(editor): per-usage display conditions on prompt block references (#25991) 2026-10-05 16:25:55 -04:00
instruction-builder.ts feat(editor): per-usage display conditions on prompt block references (#25991) 2026-10-05 16:25:55 -04:00
processor-graph-hydrator.test.ts refactor(lint): flatten lone if statements in else branches (#28431) 2026-10-26 18:44:48 +01:00
processor-graph-hydrator.ts refactor(lint): enable no-else-return at root (#28601) 2026-10-28 12:30:27 +01:00
providers.ts chore: migrate linting to oxlint (#20173) 2026-07-25 01:04:02 +02:00
rule-evaluator.test.ts feat(editor): dynamic instructions for stored agents (#12776) 2026-02-06 15:35:09 -05:00
rule-evaluator.ts feat(editor): dynamic instructions for stored agents (#12776) 2026-02-06 15:35:09 -05:00
snapshots-match.ts feat(editor): ship Agent Builder EE runtime via @mastra/editor/ee (STACK-4) (#16948) 2026-05-22 12:10:55 -07:00
stored-agent-visibility.integration.test.ts fix(server): enforce stored-agent visibility on every route that resolves an agent (#29927) 2026-11-12 12:30:07 -05:00
template-engine.test.ts fix(editor): resolve only own properties in prompt block templates (#23568) 2026-09-10 19:58:39 -07:00
template-engine.ts fix(editor): resolve only own properties in prompt block templates (#23568) 2026-09-10 19:58:39 -07:00
workspace-tools-config.test.ts fix(editor): preserve per-tool workspace settings across round trips (#23838) 2026-09-14 13:54:18 +01:00
workspace-tools-config.ts fix(editor): preserve per-tool workspace settings across round trips (#23838) 2026-09-14 13:54:18 +01:00