Skip to main content
Glama

cache_purge_by_url

Remove specific URLs from CDN cache to instantly reflect content changes. Targets individual pages for cache purging.

Instructions

Purge specific URLs from CDN cache.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
paramsNoAction parameters as a JSON object

Implementation Reference

  • The handler function for the cache_purge_by_url tool. Validates input using CachePurgeByUrlSchema, enforces rate limiting, rejects wildcard URLs, and iterates over each URL calling fastly.purgeUrl() via FastlyClient.
      handler: async (params: Record<string, unknown>, _context: ActionContext) => {
        const validated = CachePurgeByUrlSchema.parse(params);
        guardrails.requireConfirmation(RiskTier.Risk, params);
        checkRateLimit(config);
    
        // No wildcard purge allowed
        for (const url of validated.urls) {
          if (url.includes('*')) {
            throw new Error('Wildcard purge is not allowed. Specify exact URLs.');
          }
        }
    
        if (!config.fastlyServiceId || !config.fastlyApiToken) {
          return {
            message: 'Fastly not configured. Set FASTLY_SERVICE_ID and FASTLY_API_TOKEN environment variables.',
            purged: false,
          };
        }
    
        const fastly = new FastlyClient(config.fastlyServiceId, config.fastlyApiToken);
        const results: Array<{ url: string; success: boolean; id?: string }> = [];
    
        for (const url of validated.urls) {
          try {
            const result = await fastly.purgeUrl(url);
            results.push({ url, success: result.ok, id: result.id });
          } catch (err) {
            results.push({ url, success: false });
          }
        }
    
        const successCount = results.filter((r) => r.success).length;
        return {
          message: `Purged ${successCount}/${validated.urls.length} URLs.`,
          results,
        };
      },
    },
  • Zod validation schema for the cache_purge_by_url tool. Expects an array of 1-50 valid URLs, a confirm field set to true, and a non-empty reason string.
    export const CachePurgeByUrlSchema = z.object({
      urls: z.array(z.string().url()).min(1).max(50),
      confirm: z.literal(true),
      reason: z.string().min(1),
    });
  • src/index.ts:77-79 (registration)
    Registration loop in index.ts that converts action names (dots to underscores) and registers them as MCP tools. The action name 'cache.purge_by_url' becomes the MCP tool name 'cache_purge_by_url'.
    // Convert dots to underscores for MCP tool names (e.g. "auth.login" -> "auth_login")
    const toolName = action.name.replace(/\./g, '_');
  • The ActionDefinition object where the tool is defined with its metadata (name 'cache.purge_by_url', description, risk tier, auth requirement, and handler).
    {
      name: 'cache.purge_by_url',
      description: 'Purge specific URLs from CDN cache.',
      riskTier: RiskTier.Risk,
      requiresAuth: true,
  • FastlyClient.purgeUrl helper method that sends a PURGE HTTP request to the target URL with the Fastly API token, returning the purge result status and ID.
    async purgeUrl(url: string): Promise<FastlyPurgeResult> {
      const response = await fetch(url, {
        method: 'PURGE',
        headers: {
          'Fastly-Key': this.apiToken,
        },
      });
      const data = await response.json() as Record<string, unknown>;
      return {
        status: response.status,
        id: data['id'] as string | undefined,
        ok: response.ok,
      };
    }
Behavior2/5

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

No annotations are provided, so the description alone must disclose behavioral traits. It only states the action, not side effects (e.g., cache invalidation, potential performance impact), authorization needs, or destructive nature. This is insufficient.

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

Conciseness4/5

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

The description is a single, concise sentence. It is front-loaded and efficient, though could be expanded slightly without losing conciseness.

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

Completeness2/5

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

Given the single, nested parameter and lack of output schema, the description should specify the URL format (e.g., list, string), required structure, and behavior (e.g., immediate purge, confirmation). Currently too vague for reliable use.

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

Parameters3/5

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

Schema describes the parameter 'params' as an object with additional properties, achieving 100% schema coverage. However, the description adds no meaning beyond the schema—it does not specify expected keys or value formats for the URLs.

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 verb 'Purge' and resource 'specific URLs from CDN cache'. This distinguishes it from sibling tools like cache_purge_category and cache_purge_product, which target different granularities.

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

Usage Guidelines2/5

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

The description provides no guidance on when to use this tool versus alternatives. It does not mention scenario differences with cache_purge_category or cache_purge_product, nor any prerequisites.

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/thomastx05/magento-mcp'

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