Skip to content

Fix engine MCP bundling#148

Merged
willwashburn merged 1 commit into
mainfrom
fix/issue-144-mcp-sdk-examples
May 31, 2026
Merged

Fix engine MCP bundling#148
willwashburn merged 1 commit into
mainfrom
fix/issue-144-mcp-sdk-examples

Conversation

@willwashburn

Copy link
Copy Markdown
Member

Summary

  • Remove the MCP route, port, and in-process MCP host from @relaycast/engine
  • Drop engine dependencies/references on @relaycast/mcp and @modelcontextprotocol/sdk
  • Remove remote /mcp docs/OpenAPI entries and clean CI lint warnings

Fixes #144
Follow-up hosted MCP service: #147

Test plan

  • npm run lint
  • npx turbo build
  • npx turbo test
  • esbuild engine bundle scan for MCP SDK/example imports

@coderabbitai

coderabbitai Bot commented May 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5964844d-813d-4dd6-85f4-ea3747186bd6

📥 Commits

Reviewing files that changed from the base of the PR and between 2db213d and 349e75e.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (49)
  • README.md
  • openapi.yaml
  • packages/engine/package.json
  • packages/engine/src/__tests__/conformance/node.test.ts
  • packages/engine/src/adapters/node/index.ts
  • packages/engine/src/adapters/node/mcp.ts
  • packages/engine/src/engine.ts
  • packages/engine/src/engine/action.ts
  • packages/engine/src/index.ts
  • packages/engine/src/middleware/auth.ts
  • packages/engine/src/middleware/logger.ts
  • packages/engine/src/ports/auth.ts
  • packages/engine/src/ports/index.ts
  • packages/engine/src/ports/mcp.ts
  • packages/engine/src/routes/action.ts
  • packages/engine/src/routes/certify.ts
  • packages/engine/src/routes/channel.ts
  • packages/engine/src/routes/console.ts
  • packages/engine/src/routes/directory.ts
  • packages/engine/src/routes/dm.ts
  • packages/engine/src/routes/eventSubscription.ts
  • packages/engine/src/routes/file.ts
  • packages/engine/src/routes/groupDm.ts
  • packages/engine/src/routes/inboundWebhook.ts
  • packages/engine/src/routes/inbox.ts
  • packages/engine/src/routes/message.ts
  • packages/engine/src/routes/presence.ts
  • packages/engine/src/routes/reaction.ts
  • packages/engine/src/routes/receipt.ts
  • packages/engine/src/routes/routing.ts
  • packages/engine/src/routes/search.ts
  • packages/engine/tsconfig.json
  • packages/server/src/routes/certify.ts
  • packages/server/src/routes/channel.ts
  • packages/server/src/routes/command.ts
  • packages/server/src/routes/console.ts
  • packages/server/src/routes/directory.ts
  • packages/server/src/routes/dm.ts
  • packages/server/src/routes/eventSubscription.ts
  • packages/server/src/routes/file.ts
  • packages/server/src/routes/groupDm.ts
  • packages/server/src/routes/inboundWebhook.ts
  • packages/server/src/routes/inbox.ts
  • packages/server/src/routes/message.ts
  • packages/server/src/routes/presence.ts
  • packages/server/src/routes/reaction.ts
  • packages/server/src/routes/receipt.ts
  • packages/server/src/routes/routing.ts
  • packages/server/src/routes/search.ts
💤 Files with no reviewable changes (7)
  • packages/engine/src/ports/mcp.ts
  • packages/engine/src/adapters/node/mcp.ts
  • README.md
  • packages/engine/package.json
  • packages/engine/src/index.ts
  • packages/engine/src/middleware/logger.ts
  • openapi.yaml

📝 Walkthrough

Walkthrough

This PR removes MCP (Model Context Protocol) session hosting from the engine while systematically hardening HTTP error response typing across both engine and server packages by replacing permissive any casts with the typed ContentfulStatusCode from Hono. The OpenAPI spec is updated to reflect the removal of MCP endpoints and addition of new A2A, certification, console, directory, and routing capabilities.

Changes

MCP Infrastructure Removal

Layer / File(s) Summary
MCP port interface and contracts
packages/engine/src/ports/mcp.ts, packages/engine/src/ports/index.ts, packages/engine/src/index.ts
Removes the McpSessionHost interface definition and re-export; updates the EnginePorts interface to drop the mcp field, eliminating the public contract for stateful MCP session management.
InProcessMcpSessionHost adapter and node runtime wiring
packages/engine/src/adapters/node/mcp.ts, packages/engine/src/adapters/node/index.ts
Deletes the InProcessMcpSessionHost implementation that managed per-session MCP state via Map-based storage and WebStandardStreamableHTTPServerTransport; removes this adapter from the node runtime's dependency construction.
Engine MCP HTTP routes and runtime injection
packages/engine/src/engine.ts
Stops injecting the MCP port into EngineRuntime; removes the HTTP route handlers for MCP server card discovery (/.well-known/mcp/server-card.json), config discovery (/.well-known/mcp-config), and the streamable HTTP endpoint (/mcp).
MCP documentation and config cleanups
README.md, packages/engine/src/__tests__/conformance/node.test.ts, packages/engine/src/middleware/logger.ts, packages/engine/src/ports/auth.ts, packages/engine/src/middleware/auth.ts
Updates MCP server config example from remote streamable HTTP to local stdio via npx @relaycast/mcp``; removes the MCP session routing conformance test; removes /mcp route group classification from logger; updates `hashToken` and `AuthProvider` documentation to remove MCP key handling references.
TypeScript references and dependencies cleanup
packages/engine/package.json, packages/engine/tsconfig.json
Removes @modelcontextprotocol/sdk and @relaycast/mcp from engine dependencies; removes the ../mcp TypeScript project reference.

HTTP Status Code Type Safety Hardening

Layer / File(s) Summary
Engine action routes type safety
packages/engine/src/routes/action.ts
Imports ContentfulStatusCode and applies typed status casts to POST, GET, DELETE, invoke, and completion error handlers across action routes.
Engine certification, console, and routing route type safety
packages/engine/src/routes/certify.ts, packages/engine/src/routes/console.ts, packages/engine/src/routes/directory.ts, packages/engine/src/routes/routing.ts, packages/engine/src/routes/search.ts
Adds ContentfulStatusCode typing to error response status casts; directory and routing routes refactor handleError to accept Context<AppEnv> instead of any.
Engine messaging and interaction routes type safety
packages/engine/src/routes/dm.ts, packages/engine/src/routes/groupDm.ts, packages/engine/src/routes/message.ts, packages/engine/src/routes/inbox.ts, packages/engine/src/routes/receipt.ts, packages/engine/src/routes/eventSubscription.ts
Applies ContentfulStatusCode typing to DM, group DM, message, inbox, receipt, and event subscription route error and success responses across 20+ handlers.
Engine file, presence, reaction, and other routes type safety
packages/engine/src/routes/file.ts, packages/engine/src/routes/presence.ts, packages/engine/src/routes/reaction.ts, packages/engine/src/routes/inboundWebhook.ts
Adds ContentfulStatusCode type import and applies typed status casts across file upload/get/delete, presence tracking, reaction add/remove/get, and webhook route handlers.
Engine channel routes type safety
packages/engine/src/routes/channel.ts
Imports ContentfulStatusCode and updates 13 error handlers for create, list, get, update, archive, join, leave, members, invite, mute, and unmute operations.
Server certification, console, and routing route type safety
packages/server/src/routes/certify.ts, packages/server/src/routes/console.ts, packages/server/src/routes/directory.ts, packages/server/src/routes/routing.ts, packages/server/src/routes/search.ts
Adds ContentfulStatusCode typing to error response status casts; directory and routing routes refactor handleError to accept typed context and cast status properly.
Server messaging and interaction routes type safety
packages/server/src/routes/dm.ts, packages/server/src/routes/groupDm.ts, packages/server/src/routes/message.ts, packages/server/src/routes/inbox.ts, packages/server/src/routes/receipt.ts, packages/server/src/routes/eventSubscription.ts
Applies ContentfulStatusCode typing to DM, group DM, message, inbox, receipt, and event subscription route error and success responses across 20+ handlers.
Server file, presence, reaction, and other routes type safety
packages/server/src/routes/file.ts, packages/server/src/routes/presence.ts, packages/server/src/routes/reaction.ts, packages/server/src/routes/inboundWebhook.ts
Adds ContentfulStatusCode type import and applies typed status casts across file upload/completion/get/delete, presence tracking, reaction operations, and webhook route handlers.
Server command routes type safety
packages/server/src/routes/command.ts
Adds ContentfulStatusCode import and applies typed status casts to POST, GET, DELETE, and invoke error handlers for command routes.
Server channel routes type safety
packages/server/src/routes/channel.ts
Imports ContentfulStatusCode and updates error handlers for create, list, get, patch, topic update/delete/archive, join, leave, members, invite, mute, and unmute operations.

API Specification Update

Layer / File(s) Summary
OpenAPI spec: MCP removal and new feature endpoints
openapi.yaml
Replaces removed MCP paths (/.well-known/mcp/server-card.json, /.well-known/mcp-config, /mcp) with new A2A endpoints (/.well-known/agent-card.json, /a2a/*), certification (/certify/*), console observability (/console/*), directory with ratings (/directory/*), and routing/skills management (/route, /skills/*, /routing/config). Updates OpenAPI tags section to replace MCP tag with A2A, Certify, Console, Directory, and Routing tags.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • AgentWorkforce/relaycast#138: Both PRs directly modify the engine's MCP integration by removing InProcessMcpSessionHost and associated MCP HTTP routes and contracts from the engine's dependency surface.

Poem

🐰 Farewell, MCP's streamable flow,
The sessions and servers must go!
With ContentfulStatusCode so bright,
We've typed all our errors just right.
StatusCode—no more any in sight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix engine MCP bundling' directly and clearly describes the main change: removing MCP-related code from the engine to address bundling issues.
Description check ✅ Passed The description explains the main changes (removing MCP routes/ports/dependencies), references the issue being fixed (#144), and includes a comprehensive test plan.
Linked Issues check ✅ Passed The PR fully addresses issue #144 by removing all MCP SDK dependencies and in-process MCP hosting from the engine, eliminating the bundling of example files that were causing 4.5MB of bloat.
Out of Scope Changes check ✅ Passed All changes are within scope: MCP removal from engine, dependency cleanup, OpenAPI spec updates to replace MCP with A2A/other services, and consistent HTTP status typing improvements across route handlers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issue-144-mcp-sdk-examples

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request completely removes the Model Context Protocol (MCP) integration from the codebase, including its endpoints, dependencies, tests, ports, and documentation. Additionally, it improves type safety across various route handlers in both packages/engine and packages/server by replacing loose as any type assertions for HTTP status codes with explicit ContentfulStatusCode casts and properly typing Hono context parameters. There are no review comments, so I have no feedback to provide.

@github-actions

Copy link
Copy Markdown

Preview deployed!

Environment URL
API https://pr148-api.relaycast.dev
Health https://pr148-api.relaycast.dev/health
Observer https://pr148-observer.relaycast.dev/observer

This preview shares the staging database and will be cleaned up when the PR is merged or closed.

Run E2E tests

npm run e2e -- https://pr148-api.relaycast.dev --ci

Open observer dashboard

https://pr148-observer.relaycast.dev/observer

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 50 files

You’re at about 90% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Re-trigger cubic

@willwashburn willwashburn merged commit 068e51f into main May 31, 2026
6 checks passed
@willwashburn willwashburn deleted the fix/issue-144-mcp-sdk-examples branch May 31, 2026 14:53
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.

engine/mcp: @modelcontextprotocol/sdk example files bundle into Workers builds (dead code, ~4.5MB, drags in fs/readline/http)

1 participant