Skip to content

feat: Add X-Apify-Request-Origin: MCP header to API requests#835

Merged
RobertCrupa merged 3 commits into
masterfrom
feat/add-mcp-into-headers
May 14, 2026
Merged

feat: Add X-Apify-Request-Origin: MCP header to API requests#835
RobertCrupa merged 3 commits into
masterfrom
feat/add-mcp-into-headers

Conversation

@RobertCrupa
Copy link
Copy Markdown
Contributor

@RobertCrupa RobertCrupa commented May 13, 2026

Summary

  • Adds X-Apify-Request-Origin: MCP header to all outbound Apify API requests via a new addRequestOrigin interceptor in ApifyClient
  • Keeps existing Origin/mcp-server token in User-Agent unchanged
  • All 13 ApifyClient instantiation sites pick up the new header automatically — no call-site changes needed

New Request Header

image

I cut out the auth ;)

Closes #832

@github-actions github-actions Bot added the t-ai Issues owned by the AI team. label May 13, 2026
@RobertCrupa RobertCrupa requested review from MQ37 and jirispilka and removed request for jirispilka May 13, 2026 07:49
Copy link
Copy Markdown
Contributor

@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.

Thx bro!

Copy link
Copy Markdown
Collaborator

@jirispilka jirispilka left a comment

Choose a reason for hiding this comment

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

Nice!

@gippy this will be deployed tomorrow. Do you need anything else from us? Verification?

Btw, pre-existing issue:

Two functions to update headers

        const { paymentHeaders, ...clientOptions } = options;
        const requestInterceptors = [addUserAgent, addRequestOrigin];

directly followed with another update:

        if (paymentHeaders && Object.keys(paymentHeaders).length > 0) {
            requestInterceptors.push((config) => {
                const updatedConfig = { ...config };
                updatedConfig.headers = updatedConfig.headers ?? {};
                Object.assign(updatedConfig.headers, paymentHeaders);
                return updatedConfig;
            });
        }

This should be consistent, worth of a separate PR though.

Comment thread src/apify_client.ts Outdated
Co-authored-by: Jiří Spilka <jiri.spilka@apify.com>
@jirispilka jirispilka marked this pull request as draft May 14, 2026 11:00
@jirispilka jirispilka marked this pull request as ready for review May 14, 2026 11:03
@jirispilka
Copy link
Copy Markdown
Collaborator

@RobertCrupa this can be merged.
I was first told by Jarda not to merge it and then he said it is ok :)

@RobertCrupa RobertCrupa merged commit 3068106 into master May 14, 2026
14 checks passed
@RobertCrupa RobertCrupa deleted the feat/add-mcp-into-headers branch May 14, 2026 11:59
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add X-Apify-Request-Origin: MCP into headers

4 participants