-
Notifications
You must be signed in to change notification settings - Fork 78
feat: add support for Actorized MCP servers streamable transport. Refactor Actors as a tool adding logic. Update Apify client and SDK and MCP SDK. Refactor standby Actor MCP web server to support multiple concurrent clients. #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…d DELETE endpoint, rewrite server logic to use multiple internal MCP servers - this had to be done as the legacy SSE transport test were hanging for some reason, bump MCP sdk and apify and apify-client versions, split tests touching MCP server internals into separate file, remove tool loading from the root get endpoint (!!!), prepare support for streamable Actorized MCP servers
…lient add support for streamable - use it first then fallback to legacy sse
…O to remove Actor loading from Actor input directly since it probably does not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces streamable HTTP transport support for Actorized MCP servers, refactors actor tooling with caching and unified handling of normal vs. MCP-backed Actors, and overhauls the standby web server to handle multiple concurrent clients.
- Extend
connectMCPClientto prefer streamable HTTP with SSE fallback - Centralize actor definition caching and split normal vs. MCP server tool generation
- Rewrite Express app (
createExpressApp) to spin up per-session servers/transports and add session cleanup
Reviewed Changes
Copilot reviewed 22 out of 23 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/utils.ttl-lru.test.ts | New unit tests for TTL‐based LRU cache |
| tests/unit/mcp.actors.test.ts | Added tests for getActorMCPServerPath helper |
| tests/integration/suite.ts | Refactored integration suite to parameterize transport types |
| tests/integration/actor.server-streamable.test.ts | Updated streamable HTTP integration test for transport: 'streamable-http' |
| tests/integration/actor.server-sse.test.ts | Updated SSE integration test for transport: 'sse' |
| src/utils/ttl-lru.ts | Implemented TTLLRUCache wrapper with expiry logic |
| src/types.ts | Extended ActorDefinitionPruned and added ActorInfo type |
| src/tools/run_collection.ts | Modified run‐collection status enum entries |
| src/tools/build.ts | Preserved webServerMcpPath in pruned actor definitions |
| src/tools/actor.ts | Refactored actor‐tool creation to use unified ActorInfo and caching |
| src/state.ts | Introduced global actorDefinitionPrunedCache using TTL cache |
| src/mcp/client.ts | Renamed client builder to connectMCPClient with fallback logic |
| src/mcp/actors.ts | Simplified MCP server path resolution and URL construction |
| src/mcp/server.ts | Added notification forwarding and multi-client support |
| src/actor/server.ts | Overhauled Express app for concurrent SSE/HTTP sessions and added DELETE route |
| package.json | Bumped versions for MCP SDK, Apify, and Apify client |
| .actor/ACTOR.md | Documented ?actors URL parameter example |
Comments suppressed due to low confidence (3)
src/types.ts:52
- Fix the grammar in this comment. Change 'To determined' to 'to determine'.
* The `id` property is set to Actor ID.
src/mcp/client.ts:30
- [nitpick] The helper is named
createMCPSSEClientbut the exported function isconnectMCPClient. Consider renaming this toconnectMCPSSEClientfor consistency with the public API.
async function createMCPSSEClient(
src/tools/run_collection.ts:22
- The status enum uses 'TIMING-OUT' instead of the API's 'TIMING_OUT' value. It should be reverted to 'TIMING_OUT' to match the Apify API specification.
status: z.enum(['READY', 'RUNNING', 'SUCCEEDED', 'FAILED', 'TIMING-OUT', 'TIMED-OUT', 'ABORTING', 'ABORTED'])
MichalKalita
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍
Note: currently the Actorized MCP server integration test is failing, it will pass after we release a new version of apify/actors-mcp-server on Apify platform.
Initially wanted to just implement support for streamable Actorized MCP servers but turned out into quite a large PR - sorry guys.
One possibly breaking change is that I deteleted tool loading logic on the root GET endpoint so if someone was using that it could break that integration.
Had to refactor standby Actor MCP web server to support multiple clients otherwise the Actorized MCP server tests were failing - previous version supported only single concurrent client, if there was multiple of them only last connected received the resuts.
Refactored Actors as a tool adding logic and imrpoved caching so every Actor now (even the MCP servers) are cached (their definiitons) for 30 minutes. This version is also better for testing so we can write unit tests for that (if needed).
Moved integrations tests touching internal MCP server to internals.test.ts so it separate from the end to end/MCP client integration tests.
closes #89
closes #118
closes #100