diff --git a/server.json b/server.json index badd2dd6..3561bbd1 100644 --- a/server.json +++ b/server.json @@ -14,8 +14,8 @@ "headers": [ { "name": "Authorization", - "description": "Apify API token for authentication with Apify platform services. For example 'Bearer '", - "isRequired": true, + "description": "Optional Apify API token. Required for the default tool set and non-public tools. Anonymous access is available with ?tools=search-actors,fetch-actor-details,search-apify-docs,fetch-apify-docs.", + "isRequired": false, "isSecret": true } ] diff --git a/src/server_card.ts b/src/server_card.ts index bafd3a01..7f46cdae 100644 --- a/src/server_card.ts +++ b/src/server_card.ts @@ -55,7 +55,7 @@ export function getServerCard(): ServerCard { tools: { listChanged: true }, }, authentication: { - required: true, + required: false, schemes: ['bearer', 'oauth2'], }, tools: 'dynamic', diff --git a/tests/unit/server_card.test.ts b/tests/unit/server_card.test.ts index 7b7c3d8d..4524e19a 100644 --- a/tests/unit/server_card.test.ts +++ b/tests/unit/server_card.test.ts @@ -6,7 +6,17 @@ import { getServerCard, getServerInfo } from '../../src/server_card.js'; import { readJsonFile } from '../../src/utils/generic.js'; import { getPackageVersion } from '../../src/utils/version.js'; -const serverJson = readJsonFile<{ description: string }>(import.meta.url, '../../server.json'); +const serverJson = readJsonFile<{ + description: string; + remotes: { + headers: { + name: string; + description: string; + isRequired: boolean; + isSecret: boolean; + }[]; + }[]; +}>(import.meta.url, '../../server.json'); describe('getServerCard', () => { it('should return a valid MCP server card object', () => { @@ -38,13 +48,23 @@ describe('getServerCard', () => { expect(card.capabilities.tools.listChanged).toBe(true); }); - it('should require authentication with bearer and oauth2 schemes', () => { + it('declares authentication as optional with bearer and oauth2 schemes', () => { const card = getServerCard(); - expect(card.authentication.required).toBe(true); + expect(card.authentication.required).toBe(false); expect(card.authentication.schemes).toEqual(['bearer', 'oauth2']); }); + it('declares the authorization header as optional for selected public tools', () => { + const authorizationHeader = serverJson.remotes[0].headers.find((header) => header.name === 'Authorization'); + + expect(authorizationHeader).toMatchObject({ + isRequired: false, + isSecret: true, + }); + expect(authorizationHeader?.description).toContain('?tools='); + }); + it('should declare tools as dynamic', () => { const card = getServerCard();