Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions server.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"headers": [
{
"name": "Authorization",
"description": "Apify API token for authentication with Apify platform services. For example 'Bearer <apify-api-token>'",
"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
}
]
Expand Down
2 changes: 1 addition & 1 deletion src/server_card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export function getServerCard(): ServerCard {
tools: { listChanged: true },
},
authentication: {
required: true,
required: false,
schemes: ['bearer', 'oauth2'],
},
tools: 'dynamic',
Expand Down
26 changes: 23 additions & 3 deletions tests/unit/server_card.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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', () => {
Expand Down Expand Up @@ -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();

Expand Down