Skip to main content
Glama
netlify

Netlify MCP Server

Official
by netlify

netlify-coding-rules

Read-only

Apply coding rules to ensure proper implementation of Netlify serverless functions, edge functions, blobs, and other services before development.

Instructions

ALWAYS call when writing serverless or Netlify code. required step before creating or editing any type of functions, Netlify sdk/library usage, etc.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
creationTypeYes

Implementation Reference

  • netlify-mcp.ts:82-104 (registration)
    Registers the 'netlify-coding-rules' tool, including its input schema (creationType enum), description, and inline handler function that fetches and returns Netlify coding context.
    server.registerTool(
      "netlify-coding-rules",
      {
        description: "ALWAYS call when writing serverless or Netlify code. required step before creating or editing any type of functions, Netlify sdk/library  usage, etc.",
        inputSchema:{
          creationType: creationTypeEnum
        },
        annotations: {
          readOnlyHint: true
        }
      },
      async ({creationType}: {creationType: z.infer<typeof creationTypeEnum>}) => {
    
        checkCompatibility();
    
        const context = await getNetlifyCodingContext(creationType);
        const text = context?.content || '';
    
        return ({
          content: [{type: "text", text}]
        });
      }
    );
  • The core handler function for the tool, which calls getNetlifyCodingContext and returns the context content as text.
    async ({creationType}: {creationType: z.infer<typeof creationTypeEnum>}) => {
    
      checkCompatibility();
    
      const context = await getNetlifyCodingContext(creationType);
      const text = context?.content || '';
    
      return ({
        content: [{type: "text", text}]
      });
    }
  • Tool schema definition including input schema for creationType (dynamic enum from context scopes) and annotations.
    {
      description: "ALWAYS call when writing serverless or Netlify code. required step before creating or editing any type of functions, Netlify sdk/library  usage, etc.",
      inputSchema:{
        creationType: creationTypeEnum
      },
      annotations: {
        readOnlyHint: true
      }
    },
  • Main helper function that implements the context fetching logic for the tool, including caching and fetching from remote endpoint based on consumer config.
    export async function getNetlifyCodingContext(contextKey: string): Promise<ContextFile | undefined> {
      const now = Date.now();
    
      // Check if we have a cached version that's less than 10 minutes old
      // If so, return the cached version otherwise fetch fresh data
      if (contextCache[contextKey] && (now - contextCache[contextKey].timestamp) < TEN_MINUTES_MS) {
        return contextCache[contextKey]?.data;
      }
    
      const consumer = await getContextConsumerConfig();
    
      if(!consumer || !consumer.contextScopes[contextKey]?.endpoint){
        console.error('unable to find the context you are looking for. Check docs.netlify.com for more information.');
        return;
      }
    
      const endpoint = new URL(consumer.contextScopes[contextKey].endpoint);
      endpoint.searchParams.set('consumer', getConsumer());
    
      let data = '';
      try {
        const response = await unauthenticatedFetch(endpoint.toString())
        data = await response.text() as string;
    
        if(!data){
          console.error('unable to find the context you are looking for. Check docs.netlify.com for more information.');
          return;
        }
    
        const contextFile: ContextFile = {
          key: contextKey,
          config: consumer.contextScopes[contextKey],
          content: data
        };
    
        contextCache[contextKey] = {
          data: contextFile,
          timestamp: Date.now()
        };
    
      } catch (error) {
        console.error('Error fetching context:', error);
      }
    
      return contextCache[contextKey]?.data;
    }
  • Helper function to load and cache the context consumer configuration, used to determine available context scopes and endpoints.
    export async function getContextConsumerConfig(){
      const now = Date.now();
    
      // Return cached consumer if it exists and is less than 10 minutes old
      if(contextConsumer && (now - contextConsumerTimestamp) < TEN_MINUTES_MS) {
        return contextConsumer;
      }
    
      try {
        const response = await unauthenticatedFetch(`https://docs.netlify.com/ai-context/context-consumers`)
        const data = await response.json() as ConsumersData;
    
        if(data?.consumers?.length > 0){
          contextConsumer = data.consumers.find(c => c.key === getConsumer());
        }
    
      } catch (error) {
        appendErrorToLog('Error fetching context consumers:', error);
      }
    
      // Update timestamp when we get fresh data
      if (contextConsumer) {
        contextConsumerTimestamp = Date.now();
      }
    
      return contextConsumer;
    }
Behavior3/5

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

Annotations provide readOnlyHint=true, indicating this is a safe read operation. The description adds context by specifying it's a 'required step' for coding activities, which suggests it might provide guidelines or validation without modifying resources. However, it doesn't disclose additional behavioral traits like rate limits, authentication needs, or what specific information is returned. With annotations covering safety, the description adds some value but lacks rich behavioral details.

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 concise with two sentences that are front-loaded with key information ('ALWAYS call...'). It avoids unnecessary details, but could be more structured by explicitly stating the tool's action (e.g., 'retrieves coding rules'). Every sentence earns its place by emphasizing usage, making it efficient though slightly repetitive.

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

Completeness3/5

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

Given the tool has 1 parameter with an enum but no output schema and annotations only cover read-only status, the description is incomplete. It explains when to use the tool but not what it returns or how the parameter influences the output. For a tool with coding rules, more context on the return type or behavior would be helpful, but the usage guidelines partially compensate.

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?

The input schema has 1 parameter with 0% description coverage, but includes an enum defining possible values (e.g., 'serverless', 'edge-functions'). The description does not mention the parameter or explain its semantics, leaving the agent to infer from the schema alone. Since schema coverage is low, the description fails to compensate, but the enum provides some clarity. Baseline is adjusted to 3 due to the presence of an enum, though no additional meaning is added.

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

Purpose2/5

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

The description states 'ALWAYS call when writing serverless or Netlify code' and mentions it's a 'required step before creating or editing any type of functions, Netlify sdk/library usage, etc.' This is tautological as it essentially restates the tool name 'netlify-coding-rules' without specifying what the tool actually does (e.g., retrieves coding guidelines, validates code, or provides best practices). It distinguishes from siblings by focusing on coding rules rather than deployment/extension/project services, but the purpose remains vague.

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?

The description provides explicit usage guidelines: 'ALWAYS call when writing serverless or Netlify code' and 'required step before creating or editing any type of functions, Netlify sdk/library usage, etc.' This clearly indicates when to use the tool (during code writing for Netlify-related tasks) and implies alternatives are not applicable for this specific preparatory step. It effectively guides the agent on timing and context.

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/netlify/netlify-mcp'

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