Skip to main content
Glama

actors-mcp-server

Official
by apify
MIT License
7,198
465
  • Apple
mcp.actors.test.ts2.47 kB
import type { ActorDefinition } from 'apify-client'; import { describe, expect, it } from 'vitest'; import { MCP_STREAMABLE_ENDPOINT } from '../../src/const.js'; import { getActorMCPServerPath } from '../../src/mcp/actors.js'; // Helper to create a valid ActorDefinition and allow webServerMcpPath for testing function makeActorDefinitionWithPath(webServerMcpPath?: unknown): ActorDefinition { return { actorSpecification: 0, name: 'dummy', version: '0.0', ...(webServerMcpPath !== undefined ? { webServerMcpPath } : {}), }; } describe('getActorMCPServerPath', () => { it('should return null if webServerMcpPath is missing', () => { const actorDefinition = makeActorDefinitionWithPath(); const result = getActorMCPServerPath(actorDefinition); expect(result).toBeNull(); }); it('should return null if webServerMcpPath is not a string', () => { const actorDefinition = makeActorDefinitionWithPath(123); const result = getActorMCPServerPath(actorDefinition); expect(result).toBeNull(); }); it('should return the single path if only one is present', () => { const actorDefinition = makeActorDefinitionWithPath('/mcp'); const result = getActorMCPServerPath(actorDefinition); expect(result).toBe('/mcp'); }); it('should return the streamable path if present among multiple', () => { const actorDefinition = makeActorDefinitionWithPath(`/foo, ${MCP_STREAMABLE_ENDPOINT}, /bar`); const result = getActorMCPServerPath(actorDefinition); expect(result).toBe(MCP_STREAMABLE_ENDPOINT); }); it('should return the first path if streamable is not present', () => { const actorDefinition = makeActorDefinitionWithPath('/foo, /bar, /baz'); const result = getActorMCPServerPath(actorDefinition); expect(result).toBe('/foo'); }); it('should trim whitespace from paths', () => { const actorDefinition = makeActorDefinitionWithPath(' /foo , /bar '); const result = getActorMCPServerPath(actorDefinition); expect(result).toBe('/foo'); }); it('should handle streamable path with whitespace', () => { const actorDefinition = makeActorDefinitionWithPath(` /foo , ${MCP_STREAMABLE_ENDPOINT} , /bar `); const result = getActorMCPServerPath(actorDefinition); expect(result).toBe(MCP_STREAMABLE_ENDPOINT); }); });

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/apify/actors-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server