Skip to content

Conversation

@MQ37
Copy link
Contributor

@MQ37 MQ37 commented Jul 1, 2025

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

MQ37 added 2 commits July 1, 2025 15:19
…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
@github-actions github-actions bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels Jul 1, 2025
MQ37 added 3 commits July 1, 2025 16:33
@MQ37 MQ37 requested a review from MichalKalita July 1, 2025 16:43
@MQ37 MQ37 marked this pull request as ready for review July 1, 2025 16:43
@MQ37 MQ37 changed the title feat: add support for Actorized MCP servers streanable 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. 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. Jul 1, 2025
@MQ37 MQ37 requested a review from Copilot July 1, 2025 17:21
Copy link
Contributor

Copilot AI left a 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 connectMCPClient to 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 createMCPSSEClient but the exported function is connectMCPClient. Consider renaming this to connectMCPSSEClient for 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'])

Copy link
Contributor

@MichalKalita MichalKalita left a comment

Choose a reason for hiding this comment

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

LGTM 👍

@MQ37 MQ37 merged commit c2527af into master Jul 3, 2025
2 checks passed
@MQ37 MQ37 deleted the feat/actorized-mcp-streamable branch July 3, 2025 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics.

Projects

None yet

2 participants