Skip to content

Allow MCP middleware and visibility to use HTTP request services - #9856

Merged
tim-smart merged 3 commits into
v4/next-minorfrom
agent/effect-bot/36c2e36320f4
Oct 23, 2026
Merged

tim-smart merged 3 commits into
v4/next-minorfrom
agent/effect-bot/36c2e36320f4

Conversation

@effect-bot

Copy link
Copy Markdown
Contributor

Summary

Under layerHttp, McpServer middleware and visibility layers can now use per-request services that an HttpRouter.middleware provides, the same way tool registrations already do. Before, .layer failed with MissingRequestDependencies<S> when the service wasn't supplied by combine or the transport, so you needed a bridge middleware or a second round of authentication.

  • MiddlewareLayer is now always a Layer that keeps its per-request requirements as McpRequest<"Requires", S> inputs, like registrations do. There is no runtime change. layerHttp already converts leftover requirements into HttpRouter.Request requirements. layer and layerStdio still reject them, now as an unmet layer input.
  • Removed MissingRequestDependencies and TransportServices, which had become dead code. Both are unreleased (Add request-level dependencies to McpServer #9154) and @stability unstable.
  • Middleware can now also be provided in a separate Layer.provide, not only through .combine. When the types accept an order, the runtime order is also correct. A misordered composition is still rejected by the types and fails at runtime with -32603, and a test pins that.
  • Updated the JSDoc on Middleware, middleware, visibility and MCP.md: where per-request services can come from, what an unmet requirement on the server layer means, and that layerGlobal provided outside applies to the whole server.

Tests

  • typetest/ai/McpServer.tst.ts: middleware and visibility layers keep their requirements, which stay unmet under layerStdio, become HttpRouter.Request requirements under layerHttp, and are satisfied by an outer Auth.layerGlobal.
  • test/ai/McpServer/Visibility.test.ts: a visibility running through layerHttp and HttpRouter.toWebHandler reads CurrentUser from HttpRouter.middleware. A rejected tool is left out of tools/list and returns -32602; a visible tool reads CurrentUser.
  • test/ai/McpServer/RequestDependencies.test.ts: the misordered composition fails with -32603.

Closes #9854
Closes EFF-2871

@changeset-bot

changeset-bot Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 83f181d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 33 packages
Name Type
effect Patch
@effect/opentelemetry Patch
@effect/vitest Patch
@effect/ai-anthropic Patch
@effect/ai-cloudflare Patch
@effect/ai-openai-compat Patch
@effect/ai-openai Patch
@effect/ai-openrouter Patch
@effect/ai-typesafe Patch
@effect/atom-react Patch
@effect/atom-solid Patch
@effect/atom-vue Patch
@effect/platform-browser Patch
@effect/platform-bun Patch
@effect/platform-deno Patch
@effect/platform-node-shared Patch
@effect/platform-node Patch
@effect/sql-clickhouse Patch
@effect/sql-d1 Patch
@effect/sql-libsql Patch
@effect/sql-mssql Patch
@effect/sql-mysql2 Patch
@effect/sql-pg Patch
@effect/sql-pglite Patch
@effect/sql-sqlite-bun Patch
@effect/sql-sqlite-do Patch
@effect/sql-sqlite-node Patch
@effect/sql-sqlite-react-native Patch
@effect/sql-sqlite-wasm Patch
@effect/docgen Patch
@effect/doctest Patch
@effect/graphql-generator Patch
@effect/openapi-generator Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@effect-bot
effect-bot force-pushed the agent/effect-bot/36c2e36320f4 branch from f9d4cdd to 3b49a34 Compare October 23, 2026 11:23
@tim-smart
tim-smart enabled auto-merge (squash) October 23, 2026 11:30
@tim-smart
tim-smart merged commit 6e00b62 into v4/next-minor Oct 23, 2026
10 checks passed
@tim-smart
tim-smart deleted the agent/effect-bot/36c2e36320f4 branch October 23, 2026 11:38
@github-actions

Copy link
Copy Markdown
Contributor

Bundle Size Analysis

Generated from PR build output; treat the content below as untrusted.

File Name Current Size Previous Size Difference
arbitrary-combinators.ts 39.27 KB 39.27 KB 0.00 KB (0.00%)
basic.ts 7.17 KB 7.17 KB 0.00 KB (0.00%)
batching.ts 11.04 KB 11.04 KB 0.00 KB (0.00%)
brand.ts 6.83 KB 6.83 KB 0.00 KB (0.00%)
cache.ts 11.47 KB 11.47 KB 0.00 KB (0.00%)
config.ts 22.70 KB 22.70 KB 0.00 KB (0.00%)
differ.ts 21.83 KB 21.83 KB 0.00 KB (0.00%)
http-client.ts 26.64 KB 26.64 KB 0.00 KB (0.00%)
http-router.ts 36.31 KB 36.31 KB 0.00 KB (0.00%)
logger.ts 11.86 KB 11.86 KB 0.00 KB (0.00%)
metric.ts 9.40 KB 9.40 KB 0.00 KB (0.00%)
optic.ts 7.04 KB 7.04 KB 0.00 KB (0.00%)
pubsub.ts 15.95 KB 15.95 KB 0.00 KB (0.00%)
queue.ts 12.75 KB 12.75 KB 0.00 KB (0.00%)
schedule.ts 11.72 KB 11.72 KB 0.00 KB (0.00%)
schema-bigdecimal.ts 13.98 KB 13.98 KB 0.00 KB (0.00%)
schema-binary.ts 40.99 KB 40.99 KB 0.00 KB (0.00%)
schema-class.ts 21.49 KB 21.49 KB 0.00 KB (0.00%)
schema-fromJsonSchemaDocument.ts 32.54 KB 32.54 KB 0.00 KB (0.00%)
schema-representation-roundtrip.ts 27.73 KB 27.73 KB 0.00 KB (0.00%)
schema-string-transformation.ts 15.24 KB 15.24 KB 0.00 KB (0.00%)
schema-string.ts 12.22 KB 12.22 KB 0.00 KB (0.00%)
schema-template-literal.ts 16.16 KB 16.16 KB 0.00 KB (0.00%)
schema-toArbitrary.ts 38.80 KB 38.80 KB 0.00 KB (0.00%)
schema-toCodeDocument.ts 25.89 KB 25.89 KB 0.00 KB (0.00%)
schema-toCodecJson.ts 20.77 KB 20.77 KB 0.00 KB (0.00%)
schema-toEquivalence.ts 20.91 KB 20.91 KB 0.00 KB (0.00%)
schema-toFormatter.ts 21.02 KB 21.02 KB 0.00 KB (0.00%)
schema-toJsonSchemaDocument.ts 25.65 KB 25.65 KB 0.00 KB (0.00%)
schema-toRepresentation.ts 21.01 KB 21.01 KB 0.00 KB (0.00%)
schema.ts 20.69 KB 20.69 KB 0.00 KB (0.00%)
stm.ts 14.06 KB 14.06 KB 0.00 KB (0.00%)
stream.ts 10.31 KB 10.31 KB 0.00 KB (0.00%)

@effect-bot effect-bot mentioned this pull request Oct 23, 2026
effect-bot added a commit to jayhemnani9910/effect that referenced this pull request Oct 24, 2026
brandon-julio-t added a commit to brandon-julio-t/effect that referenced this pull request Oct 24, 2026
Release automation retargeted the optional stateless HTTP RFC to v4/next-minor,
where its constructor and notification changes conflicted with newer MCP APIs.
Merge that actual release base without rebasing or replacing earlier contributor
commits, retaining the minor changeset and reviewed stateless behavior.

Preserve the base's generic registration and request-service marker types,
HTTP middleware and visibility, revision-aware notification delivery, and secure
session ID generation. Give synthetic legacy bindings the required revision
field, forward notification revisions for stateful clients, and continue to
suppress subscriptions for stateless legacy requests. The batched logging
restriction and previous disconnect/cancellation regression cases remain intact.

Use the new registrations option in the stateless test fixture. An added HTTP
workflow checks that a guest cannot discover a protected tool, an admin can call
it using the current request identity, and the next guest POST remains denied.
This verifies that opting out of MCP sessions retains request-level authorization
and visibility without preserving the previous caller's identity.

Validation: 1,102 MCP server/client tests pass, with 42 revision-specific skips;
all 16 stateless tests pass, including native-client requests across fresh
runtimes. McpServer type tests pass 70 tests and 164 assertions across both
configured TypeScript targets. pnpm check, pnpm lint-fix, pnpm lint,
pnpm jsdocs --check, and the diff check against v4/next-minor pass. Fresh shared
autoreview reports no actionable P0-P2 findings on the complete PR candidate.

RFC: Effect-TS#8856
Request services: Effect-TS#9856
effect-bot added a commit to FredAmartey/effect that referenced this pull request Oct 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants