diff --git a/package-lock.json b/package-lock.json index 0d37de1..96354d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@decodo/mcp-server", - "version": "1.3.0", + "version": "1.3.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@decodo/mcp-server", - "version": "1.3.0", + "version": "1.3.1", "license": "ISC", "dependencies": { "@decodo/sdk-ts": "^2.4.0", diff --git a/package.json b/package.json index 25e59e4..97d269c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@decodo/mcp-server", - "version": "1.3.0", + "version": "1.3.1", "description": "Decodo MCP Server", "bin": { "decodo-mcp": "./build/index.js" diff --git a/server.json b/server.json index 21fda50..f8432a8 100644 --- a/server.json +++ b/server.json @@ -7,13 +7,13 @@ "url": "https://github.com/Decodo/mcp-server", "source": "github" }, - "version": "1.3.0", + "version": "1.3.1", "packages": [ { "registryType": "npm", "registryBaseUrl": "https://registry.npmjs.org", "identifier": "@decodo/mcp-server", - "version": "1.3.0", + "version": "1.3.1", "transport": { "type": "stdio" } diff --git a/src/clients/__tests__/scraper-api-client.test.ts b/src/clients/__tests__/scraper-api-client.test.ts index 9cd457d..e91bf09 100644 --- a/src/clients/__tests__/scraper-api-client.test.ts +++ b/src/clients/__tests__/scraper-api-client.test.ts @@ -65,6 +65,18 @@ describe('ScraperApiClient', () => { }); }); + it('sends a custom integration header when configured', async () => { + const hostedClient = new ScraperApiClient({ + maxRetries: 1, + delayMs: 0, + integrationHeader: 'mcp-hosted', + }); + + await hostedClient.scrape(defaultArgs); + + expect(lastRequest().init.headers).toMatchObject({ 'x-integration': 'mcp-hosted' }); + }); + it('posts to the data API with Bearer auth when given an API key', async () => { await client.scrape({ ...defaultArgs, auth: apiKeyAuth }); diff --git a/src/clients/scraper-api-client.ts b/src/clients/scraper-api-client.ts index 11b1a62..fac804e 100644 --- a/src/clients/scraper-api-client.ts +++ b/src/clients/scraper-api-client.ts @@ -24,7 +24,6 @@ import { WAITING_INTERVAL_MS, } from './retry'; -const INTEGRATION_HEADER = 'mcp'; const REQUEST_TIMEOUT_MS = 180_000; const API_PARAM_ALIASES = new Map([ @@ -44,21 +43,26 @@ export class ScraperApiClient { hosts: ScrapingApiHosts; + integrationHeader: string; + constructor({ maxRetries = MAX_RETRIES, delayMs = BASE_RETRY_DELAY_MS, onAuthenticationError, hosts = scrapingApiHostsFromEnv(), + integrationHeader = 'mcp', }: { maxRetries?: number; delayMs?: number; onAuthenticationError?: AuthenticationErrorListener; hosts?: ScrapingApiHosts; + integrationHeader?: string; } = {}) { this.maxRetries = maxRetries; this.delayMs = delayMs; this.onAuthenticationError = onAuthenticationError; this.hosts = hosts; + this.integrationHeader = integrationHeader; } transformScrapingParams = ({ @@ -186,7 +190,7 @@ export class ScraperApiClient { const { webScrapingApi } = new DecodoClient({ webScrapingApi: { ...this.sdkTransport(auth), - integrationHeader: INTEGRATION_HEADER, + integrationHeader: this.integrationHeader, }, timeoutMs: REQUEST_TIMEOUT_MS, }); diff --git a/src/server/__tests__/server-registration.test.ts b/src/server/__tests__/server-registration.test.ts index 18f2b5c..f36a08d 100644 --- a/src/server/__tests__/server-registration.test.ts +++ b/src/server/__tests__/server-registration.test.ts @@ -25,7 +25,7 @@ describe('Server registration', () => { expect(McpServer).toHaveBeenCalledWith({ name: 'decodo', - version: '1.3.0', + version: '1.3.1', }); }); diff --git a/src/server/sapi-base-server.ts b/src/server/sapi-base-server.ts index 5418333..d1bc961 100644 --- a/src/server/sapi-base-server.ts +++ b/src/server/sapi-base-server.ts @@ -51,16 +51,18 @@ export class ScraperAPIBaseServer { auth, toolsets = [], onAuthenticationError, + integrationHeader, }: { auth: AuthCredential; toolsets: TOOLSET[]; onAuthenticationError?: AuthenticationErrorListener; + integrationHeader?: string; }) { this.server = new McpServer({ name: 'decodo', version: PACKAGE_VERSION, }); - this.sapiClient = new ScraperApiClient({ onAuthenticationError }); + this.sapiClient = new ScraperApiClient({ onAuthenticationError, integrationHeader }); this.auth = auth; diff --git a/src/server/sapi-http-server.ts b/src/server/sapi-http-server.ts index 1c0671f..c871dbc 100644 --- a/src/server/sapi-http-server.ts +++ b/src/server/sapi-http-server.ts @@ -19,6 +19,6 @@ export class ScraperAPIHttpServer extends ScraperAPIBaseServer { auth: AuthCredential; onAuthenticationError?: AuthenticationErrorListener; }) { - super({ auth, toolsets, onAuthenticationError }); + super({ auth, toolsets, onAuthenticationError, integrationHeader: 'mcp-hosted' }); } }