Skip to main content
Glama

brand_brandcode_live

Control live mode to route read-only brand tools through the hosted runtime or fall back to local mirror, with configurable cache TTL for fresh data.

Instructions

Enable, disable, or inspect Live Mode on the Brandcode Studio connector. When ON, read-only tools (brand_runtime, brand_check, brand_audit_content, brand_check_compliance, brand_preview, brand_status) refresh from the hosted runtime on each call, within a short cache TTL (default 60s). Governance edits in Brand Console propagate on the next call without a manual sync. Requires a prior brand_brandcode_connect and brand_brandcode_auth. Use when the user says "go live", "enable live mode", "turn off live mode", "is live mode on?", or "make brand reads live". Returns the current mode, cache freshness, and sync token. Network failures during live reads silently fall back to the local mirror.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNo"on" routes read tools through the hosted runtime. "off" returns to local-mirror reads. "status" (default) reports current live-mode state and cache freshness.status
cache_ttl_secondsNoOptional. When turning on, override the per-call cache TTL. Default 60s. Lower = fresher, higher = less load.

Implementation Reference

  • Main handler function that dispatches to handleOn, handleOff, or handleStatus based on the 'mode' input parameter. Reads connector config from disk first.
    async function handler(input: Params) {
      const cwd = process.cwd();
      const config = await readConnectorConfig(cwd);
    
      if (input.mode === "on") return handleOn(config, input);
      if (input.mode === "off") return handleOff(config);
      return handleStatus(config);
    }
  • Registration function that binds the tool 'brand_brandcode_live' to the MCP server with its paramsShape schema and handler logic.
    export function register(server: McpServer) {
      server.tool(
        "brand_brandcode_live",
        'Enable, disable, or inspect Live Mode on the Brandcode Studio connector. When ON, read-only tools (brand_runtime, brand_check, brand_audit_content, brand_check_compliance, brand_preview, brand_status) refresh from the hosted runtime on each call, within a short cache TTL (default 60s). Governance edits in Brand Console propagate on the next call without a manual sync. Requires a prior brand_brandcode_connect and brand_brandcode_auth. Use when the user says "go live", "enable live mode", "turn off live mode", "is live mode on?", or "make brand reads live". Returns the current mode, cache freshness, and sync token. Network failures during live reads silently fall back to the local mirror.',
        paramsShape,
        async (args) => {
          const parsed = safeParseParams(ParamsSchema, args);
          if (!parsed.success) return parsed.response;
          return handler(parsed.data);
        },
      );
    }
  • Zod schema definition for the tool input: 'mode' (on/off/status with default 'status') and optional 'cache_ttl_seconds' (5-3600).
    const paramsShape = {
      mode: z
        .enum(["on", "off", "status"])
        .default("status")
        .describe(
          '"on" routes read tools through the hosted runtime. "off" returns to local-mirror reads. "status" (default) reports current live-mode state and cache freshness.',
        ),
      cache_ttl_seconds: z
        .number()
        .int()
        .min(5)
        .max(3600)
        .optional()
        .describe(
          "Optional. When turning on, override the per-call cache TTL. Default 60s. Lower = fresher, higher = less load.",
        ),
    };
    
    const ParamsSchema = z.object(paramsShape);
    type Params = z.infer<typeof ParamsSchema>;
  • handleStatus: Reads ConnectorConfig and returns current live mode state, cache status, sync token, and TTL. Provides contextual next_steps.
    async function handleStatus(config: ConnectorConfig | null) {
      if (!config) {
        return buildResponse({
          what_happened: "No Brandcode connection found — Live Mode requires one.",
          next_steps: [
            'Run brand_brandcode_connect url="your-slug" to connect a hosted brand first',
            "Then brand_brandcode_live mode=\"on\" to enable live reads",
          ],
          data: { error: ERROR_CODES.NOT_FOUND, live_mode: false },
        });
      }
    
      const live = !!config.liveMode;
      const ttl = config.liveCacheTTLSeconds ?? DEFAULT_TTL_SECONDS;
      const cached = getLiveCacheEntry(config.slug);
      const lines: string[] = [
        "── Live Mode ────────────────────────",
        `Status:          ${live ? "ON" : "off"}`,
        `Brand:           ${config.slug}`,
        `Cache TTL:       ${ttl}s`,
      ];
      if (live) {
        lines.push(
          `Activated at:    ${config.liveModeActivatedAt ?? "unknown"}`,
        );
        if (cached) {
          const age = Math.round((Date.now() - cached.fetchedAt) / 1000);
          lines.push(`Cache:           warm (age ${age}s of ${ttl}s)`);
          lines.push(`Sync token:      ${cached.syncToken}`);
        } else {
          lines.push(`Cache:           cold — next live call will fetch`);
        }
        lines.push(`Remote:          ${config.pullUrl}`);
      } else {
        lines.push(`Last local sync: ${config.lastSyncedAt}`);
        lines.push(`Local sync tok:  ${config.syncToken}`);
      }
    
      return buildResponse({
        what_happened: live
          ? `Live Mode is ON for "${config.slug}" (cache ${cached ? "warm" : "cold"})`
          : `Live Mode is off for "${config.slug}" — reads serve from local mirror`,
        next_steps: live
          ? [
              'Run brand_brandcode_live mode="off" to return to local-mirror reads',
              "Governance edits in Brand Console propagate on the next read within cache TTL",
            ]
          : [
              'Run brand_brandcode_live mode="on" to route read tools through the hosted runtime',
              "Live Mode requires brand_brandcode_auth; run that first if you haven't",
            ],
        data: {
          status: lines.join("\n"),
          live_mode: live,
          slug: config.slug,
          cache_ttl_seconds: ttl,
          activated_at: config.liveModeActivatedAt,
          cache_warm: !!cached,
          cache_age_seconds: cached
            ? Math.round((Date.now() - cached.fetchedAt) / 1000)
            : null,
          last_synced_at: config.lastSyncedAt,
        },
      });
    }
  • handleOn: Enables live mode by writing updated ConnectorConfig with liveMode=true and invalidating live cache. Requires auth and connector config.
    async function handleOn(config: ConnectorConfig | null, input: Params) {
      const cwd = process.cwd();
    
      if (!config) {
        return buildResponse({
          what_happened: "Cannot enable Live Mode — no Brandcode connection found.",
          next_steps: [
            'Run brand_brandcode_connect url="your-slug" first to connect a hosted brand',
          ],
          data: { error: ERROR_CODES.NOT_FOUND, live_mode: false },
        });
      }
    
      const auth = await readAuthCredentials(cwd);
      if (!auth) {
        return buildResponse({
          what_happened: "Cannot enable Live Mode — not authenticated with Brandcode Studio.",
          next_steps: [
            'Run brand_brandcode_auth mode="activate" email="you@example.com" to authenticate',
            "Then brand_brandcode_live mode=\"on\" to enable live reads",
          ],
          data: { error: ERROR_CODES.NOT_AUTHENTICATED, live_mode: false },
        });
      }
    
      const now = new Date().toISOString();
      const ttl = input.cache_ttl_seconds ?? config.liveCacheTTLSeconds ?? DEFAULT_TTL_SECONDS;
      const updated: ConnectorConfig = {
        ...config,
        liveMode: true,
        liveModeActivatedAt: now,
        liveCacheTTLSeconds: ttl,
      };
      await writeConnectorConfig(cwd, updated);
      invalidateLiveCache(config.slug);
    
      return buildResponse({
        what_happened: `Live Mode enabled for "${config.slug}" — reads will refresh from the hosted runtime.`,
        next_steps: [
          `Cache TTL is ${ttl}s — governance edits propagate on the next read within that window`,
          "Try brand_runtime to see the live-tagged result",
          'Run brand_brandcode_live mode="off" to return to local-mirror reads',
        ],
        data: {
          live_mode: true,
          slug: config.slug,
          activated_at: now,
          cache_ttl_seconds: ttl,
          sync_token: config.syncToken,
        },
      });
    }
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Despite no annotations, the description fully discloses behavior: live mode refreshes read tools from hosted runtime with configurable cache TTL, governance edits propagate automatically, return values include mode, cache freshness, and sync token, and network failures silently fall back to local mirror. This covers all critical behavioral aspects.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise (7 sentences) and front-loaded with the core purpose. Each sentence adds necessary information: purpose, effect when on, governance, prerequisites, triggers, return values, fallback. No redundancy or filler.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the absence of an output schema, the description explains return values. It covers prerequisites, failure behavior, and parameter configuration. The tool has moderate complexity, and the description provides sufficient context for an agent to use it correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% so baseline is 3. The description adds value by explaining the cache TTL default (60s) and its purpose, and contextualizing the mode parameter's effect on read tools. This extra context justifies a score above baseline.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool enables, disables, or inspects Live Mode on the Brandcode Studio connector, with specific verbs and resource. It distinguishes itself from siblings by detailing its effect on read-only tools, making its unique role unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly provides usage triggers like 'go live', 'enable live mode', etc., and lists prerequisites (prior brand_brandcode_connect and brand_brandcode_auth). This guides the agent on when and how to invoke the tool, with no ambiguity.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

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/Brandcode-Studio/brandsystem-mcp'

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