Skip to main content
Glama

contentful-mcp

tools.test.ts2.32 kB
import { describe, it, expect, beforeEach } from "vitest" import { getSpaceEnvProperties } from "../../src/types/tools" describe("getSpaceEnvProperties", () => { const originalEnv = process.env beforeEach(() => { process.env = { ...originalEnv } }) afterEach(() => { process.env = originalEnv }) it("should add spaceId and environmentId properties when environment variables are not set", () => { delete process.env.SPACE_ID delete process.env.ENVIRONMENT_ID const config = { type: "object", properties: { existingProperty: { type: "string" }, }, required: ["existingProperty"], } const result = getSpaceEnvProperties(config) expect(result.properties).toHaveProperty("spaceId") expect(result.properties).toHaveProperty("environmentId") expect(result.required).toContain("spaceId") expect(result.required).toContain("environmentId") }) it("should not add spaceId and environmentId properties when environment variables are set", () => { process.env.SPACE_ID = "test-space-id" process.env.ENVIRONMENT_ID = "test-environment-id" const config = { type: "object", properties: { existingProperty: { type: "string" }, }, required: ["existingProperty"], } const result = getSpaceEnvProperties(config) expect(result.properties).not.toHaveProperty("spaceId") expect(result.properties).not.toHaveProperty("environmentId") expect(result.required).not.toContain("spaceId") expect(result.required).not.toContain("environmentId") }) it("should merge spaceId and environmentId properties with existing properties", () => { delete process.env.SPACE_ID delete process.env.ENVIRONMENT_ID const config = { type: "object", properties: { existingProperty: { type: "string" }, }, required: ["existingProperty"], } const result = getSpaceEnvProperties(config) expect(result.properties).toHaveProperty("existingProperty") expect(result.properties).toHaveProperty("spaceId") expect(result.properties).toHaveProperty("environmentId") expect(result.required).toContain("existingProperty") expect(result.required).toContain("spaceId") expect(result.required).toContain("environmentId") }) })

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/ivo-toby/contentful-mcp'

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