Skip to content

Conversation

@MQ37
Copy link
Contributor

@MQ37 MQ37 commented Apr 1, 2025

Closes #55
Closes #56

The idea is that we expose the MCP server and the Express app that can then be extended with other endpoints - so it can be used in the platform MCP server.

The new proposed solution is to expose MCP server and tools/prompt/resources functionalty as additional library and keep the stdio (and the Actor for now - legacy).

@MQ37
Copy link
Contributor Author

MQ37 commented Apr 3, 2025

I splitted the tools to separate file in tools dir. Also changed types for two basic tools ActorTool - calls an Actor; and Internal Tool has call function and does some logic which returns MCP response. Also prepared dir toolkits where we can create basic list of tools like Actor discovery toolkit or auto loading Actor toolkit, ...

@jirispilka
Copy link
Collaborator

@MQ37 thanks! But it would be better to have separate PRs, it is becoming very big and intractable.

First, we need to decouple Actor and server. You also need to separate README, Actor README is going to be different from the package README

@MQ37
Copy link
Contributor Author

MQ37 commented Apr 5, 2025

@MQ37 thanks! But it would be better to have separate PRs, it is becoming very big and intractable.

First, we need to decouple Actor and server. You also need to separate README, Actor README is going to be different from the package README

I agree with you that this is a large PR but I think these changes go hand in hand with each other and it would be easier to do both of them at once for us - I am also working on integrating this into the apify-mcp-server repo.

@jirispilka
Copy link
Collaborator

jirispilka commented Apr 5, 2025

I'm afraid, I don't really like it, there is no clear separation of the Actor code and a new mcp-server code :(
That was the requirement of the issue.
Instead, there is a mix of tools.ts, toolkits, tools directory, which I don't quite get.
I would first finish one thing, settle the structure and then introduce a new stuff

@MQ37
Copy link
Contributor Author

MQ37 commented Apr 6, 2025

I'm afraid, I don't really like it, there is no clear separation of the Actor code and a new mcp-server code :( That was the requirement of the issue. Instead, there is a mix of tools.ts, toolkits, tools directory, which I don't quite get. I would first finish one thing, settle the structure and then introduce a new stuff

It is still a WIP, but the main idea is that all tools will be in the tools/ directory (same for resources/ and prompts/ as suggested in #56) and the server entry points and MCP server class are separated (so we can easily use this in the apify-mcp-server based on #55). So the main.ts is the entry point for the Actor and stdio.ts is the entry point for the stdio version of the server. There are some places that still need work and some moving around. What other project structure do you suggest then?

@jirispilka
Copy link
Collaborator

I think the structure is better now .... but this PR is huge because we couple together structure and tools refactoring.
We will need to live with that and test properly.

There are two things I'm not happy with:

  • I don't like that we are passing apifyMcpServer and mcpServer to a tool
  • We need to handle errors better by sending server.sendLoggingMessage ( )

So this is still work in progress

Copy link
Contributor Author

@MQ37 MQ37 left a comment

Choose a reason for hiding this comment

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

Just a few comments, otherwise nice work @jirispilka 👍

Comment on lines 7 to 11
actors: [
'apify/instagram-scraper',
'apify/rag-web-browser',
'lukaskrivka/google-maps-with-contact-details',
],
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The default list of loaded Actors/tools is not only Actor related (is used in stdio.ts), I think we should move it to src/const.ts

@MQ37 MQ37 force-pushed the feat/decouple branch 3 times, most recently from 0325f4c to 52ccf0c Compare April 11, 2025 13:01
Apify Release Bot and others added 10 commits April 11, 2025 13:04
* docs: document input schema processing (#58)

document Actor input schema processing in README

* add VS Code instructions to README (#62)

* Add vs code instructions

---------

Co-authored-by: mbaiza27 <mbaiza27@outllook.com>
Co-authored-by: Jiří Spilka <jiri.spilka@apify.com>

* ci: run prerelase manually (#70)

run prerelase manually

* get apify api url base from env var

---------

Co-authored-by: Marc Baiza <43151891+mbaiza27@users.noreply.github.com>
Co-authored-by: mbaiza27 <mbaiza27@outllook.com>
Co-authored-by: Jiří Spilka <jiri.spilka@apify.com>
)

* fix: add http request/response, fix lint
* feat: add client for /mcp endpoint
* fix: fork modelcontextprotocol repository
* fix: refactor server.ts
* docs: document input schema processing (#58)

document Actor input schema processing in README

* add VS Code instructions to README (#62)

* Add vs code instructions

---------

Co-authored-by: mbaiza27 <mbaiza27@outllook.com>
Co-authored-by: Jiří Spilka <jiri.spilka@apify.com>

* initial working draft of proxy actorized mcp servers

* fix tests

* fix proxy tool name handling

* ci: run prerelase manually (#70)

run prerelase manually

* organize, fix passing of apify token

* fix env var name

* fix imports

* get standby url from actor id, check if is mcp server based on actor name for now

* Actor MCP server load default Actors

* get standbyUrlBase from env var

* fix standby url base, use dns friendly owner name

* get mcp path from definition

* Remove unused import from actor.ts

* console.log to logger

* Remove extra slash from MCP server URL construction

* Simplify actor tools loading logic

* Refactor actorOwnerDNSFriendly to handle special characters

* Add TODO comment for reworking actor definition fetch logic

* refactor mcp actor and utils, use real Actor ID as standby URL

* fix: get-actor-definition-default-build (#73)

* fix get default build in get actor definition

* fix tests

* fix double import, lint

---------

Co-authored-by: Marc Baiza <43151891+mbaiza27@users.noreply.github.com>
Co-authored-by: mbaiza27 <mbaiza27@outllook.com>
Co-authored-by: Jiří Spilka <jiri.spilka@apify.com>
Co-authored-by: Jiri Spilka <jirka.spilka@gmail.com>
@jirispilka
Copy link
Collaborator

I know, one test is failing x I didn't have time to do it before leaving the office.

@MQ37
Copy link
Contributor Author

MQ37 commented Apr 16, 2025

@jirispilka thank you for fixing the tests 👍 Tested Actorized MCPs and normal Actors in Claude desktop (stdio) and on staging via SSE and everything works ✔️

@jirispilka
Copy link
Collaborator

@MQ37 cool. Thanks! We should also test existing Actor, whether it works via SSE. I'll create a task for this

@jirispilka jirispilka marked this pull request as ready for review April 16, 2025 20:27
@jirispilka jirispilka self-requested a review April 16, 2025 20:27
@jirispilka jirispilka changed the title feat: decouple logic feat: Decouple Actor from mcp-server, add ability to call Actorized MCP and load tools Apr 16, 2025
@MQ37
Copy link
Contributor Author

MQ37 commented Apr 17, 2025

@MQ37 cool. Thanks! We should also test existing Actor, whether it works via SSE. I'll create a task for this

Tested again as Actor and it works 👍

@jirispilka jirispilka merged commit fe8d9c2 into master Apr 17, 2025
2 checks passed
@jirispilka jirispilka deleted the feat/decouple branch April 17, 2025 09:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants