Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

1.3 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { getMcpActionLogConfigErrors } from "./mcp-action-log-config";

describe("MCP action log configuration", () => {
  it("is inert by default", () => {
    expect(getMcpActionLogConfigErrors({})).toEqual([]);
  });

  it("requires primary database authentication before enabling storage", () => {
    expect(
      getMcpActionLogConfigErrors({ MCP_ACTION_LOG_STORAGE_ENABLED: true }),
    ).toEqual([
      expect.objectContaining({ path: "MCP_ACTION_LOG_STORAGE_ENABLED" }),
    ]);
  });

  it("requires storage and a non-empty secret before enabling writes", () => {
    const errors = getMcpActionLogConfigErrors({
      MCP_ACTION_LOG_WRITES_ENABLED: true,
      MCP_ACTION_LOG_SECRET: "   ",
    });
    expect(errors.map(error => error.path)).toEqual([
      "MCP_ACTION_LOG_WRITES_ENABLED",
      "MCP_ACTION_LOG_SECRET",
      "PUBSUB_CREDENTIALS",
    ]);
  });

  it("accepts the fully enabled production configuration", () => {
    expect(
      getMcpActionLogConfigErrors({
        MCP_ACTION_LOG_STORAGE_ENABLED: true,
        MCP_ACTION_LOG_WRITES_ENABLED: true,
        MCP_ACTION_LOG_SECRET: "secret",
        PUBSUB_CREDENTIALS: "credentials",
        USE_DB_AUTHENTICATION: true,
      }),
    ).toEqual([]);
  });
});