Skip to content

Conversation

@MQ37
Copy link
Contributor

@MQ37 MQ37 commented Sep 9, 2025

Integrates Skyfire PAY tokens into the MCP server that is passed via tool input props.

Remains backwards compatible with the existing Apify token use case.

closes #263

Changes

Auth middleware

  • Auth middleware does not require Apify token when using ?payment=skyfire and adds bool skyfireMode to request object.

Apify token passing

  • Instead of passing apifyToken throughout the whole code base the interface of the functions changes to accept apifyClient instead, this is requires since in the Skyfire mode the client will set skyfire-pay-id header instead of the Apify token bearer (this is also more flexible and future proof).

Tools

  • Injected skyfire-pay-id input prop into all the actor tools types and the call-actor tools (only required in the call step).
  • When these tools are called without the skyfire-pay-id we return the instructions with a notice that this input is required.
  • Injected Skyfire usage instructions into the Actor and call-actor tool descriptions and also call-actor tools info step result

Resources

  • Added usage guide/README resource explaining the Skyfire usage mode

Other

  • Removed the try catch that was just rethrowing a generic error in callActorGetDataset

@MQ37 MQ37 marked this pull request as draft September 9, 2025 11:26
@MQ37 MQ37 changed the title feat: agentci payments v2 feat: agentic payments v2 Sep 9, 2025
Base automatically changed from feat/improve-actor-tool-output to master September 9, 2025 11:40
MQ37 added 3 commits September 9, 2025 15:13
commit 20e6753
Author: Apify Release Bot <[email protected]>
Date:   Tue Sep 9 11:41:31 2025 +0000

    chore(release): Update changelog, package.json and manifest.json versions [skip ci]

commit 7ef726d
Author: Jakub Kopecký <[email protected]>
Date:   Tue Sep 9 13:40:04 2025 +0200

    feat: improve actor tool output (#260)

    * feat: improve actor tool output

    * update readme

    * fix output tool, write test for that

    * add test based on Zuzka suggestion

    * lint

    * fix output response order so LLM does not lose the instructions

    * refactor: unify string list parsing logic

    * fix the tests - order of the Actor run response messages

    * Update src/utils/schema-generation.ts

    Co-authored-by: Michal Kalita <[email protected]>

    * address review comments

    * add get-actor-output tools note about when its loaded

    ---------

    Co-authored-by: Michal Kalita <[email protected]>

commit 279293f
Author: Michal Kalita <[email protected]>
Date:   Mon Sep 8 12:05:25 2025 +0200

    fix: error when content type is json (#265)

    * fix: error when content type is json

    * fix: do not make json schema formatted for human readable

commit 4659e03
Author: Apify Release Bot <[email protected]>
Date:   Thu Sep 4 12:30:50 2025 +0000

    chore(release): Update changelog, package.json and manifest.json versions [skip ci]
@MQ37 MQ37 force-pushed the feat/skyfire-payments-v2 branch from 4ee5a1c to 07a8d19 Compare September 9, 2025 13:49
@github-actions github-actions bot added t-ai Issues owned by the AI team. tested Temporary label used only programatically for some analytics. labels Sep 9, 2025
@MQ37 MQ37 added the beta Create beta prereleases label Sep 10, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Sep 10, 2025

Open in StackBlitz

npm i https://pkg.pr.new/apify/apify-mcp-server/@apify/actors-mcp-server@266

commit: c2015e3

@jirispilka
Copy link
Collaborator

@MQ37 I think it is good.

@MichalKalita

It makes the public interface a bit more complicated.

  1. What if we remove the need to pass a token when the API allows anonymous access?
  2. Junie suggested creating a client factory function that would allow you to pass a client, a function to create a client, or a token.

I’ve created this PR but haven’t tested it yet—it was vibe-coded only!!!
Just a proposal:
https://github.com/apify/apify-mcp-server/pull/268/files

*/
if (skyfirePayId) {
requestInterceptors.push((config) => {
const updatedConfig = { ...config };
Copy link
Contributor

Choose a reason for hiding this comment

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

This type of first level clone don't have any effect. Config object itself is not mutated.
This function mutates config.headers, and the input config object is updated.

Here is simple preview how it works
image

Use structuredClone for full clone. Or nothing if mutation is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I just copied to logic from the add user agent header and it uses this exact logic. I dont quite get what is the issue exactly here? Is there any major flaw?

@MQ37
Copy link
Contributor Author

MQ37 commented Sep 10, 2025

@MQ37 I think it is good.

@MichalKalita

It makes the public interface a bit more complicated.

1. What if we remove the need to pass a token when the API allows anonymous access?

2. Junie suggested creating a client factory function that would allow you to pass a client, a function to create a client, or a token.

I’ve created this PR but haven’t tested it yet—it was vibe-coded only!!! Just a proposal: https://github.com/apify/apify-mcp-server/pull/268/files

Thank you for review 👍 Guys want to test that tomorrow before AH and I still need to do some changes (we made some decisions during todays meeting) so I would definitely not refactor this now - we can always refactor later.

@MQ37
Copy link
Contributor Author

MQ37 commented Sep 10, 2025

What if we remove the need to pass a token when the API allows anonymous access?

@jirispilka I think only API where we can safely disable is the store search since that does not really require user account. Other endpoints like get Actor, build, etc. in some cases require user account - for example when user wants to use private Actor on their own account.

@jirispilka
Copy link
Collaborator

@jirispilka I think only API where we can safely disable is the store search since that does not really require user account. Other endpoints like get Actor, build, etc. in some cases require user account - for example when user wants to use private Actor on their own account.

oh, make sense! I forgot about private Actors.

@MQ37 MQ37 marked this pull request as ready for review September 12, 2025 08:20
@MQ37 MQ37 merged commit 2733d4e into master Sep 12, 2025
5 checks passed
@MQ37 MQ37 deleted the feat/skyfire-payments-v2 branch September 12, 2025 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix Apify API errors messages and return them instead of the generic one

3 participants