Skip to main content
Glama

createSiteFromGitHub

Deploy a Netlify site directly from a GitHub repository by specifying build commands, publish directory, and environment variables for automated hosting.

Instructions

Create a new Netlify site from a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
nameYesName for the new site (will be used as subdomain)
repoYesGitHub repository in format owner/repo
branchNoBranch to deploy from (default: main)main
buildCommandYesBuild command to run (e.g., npm run build)
publishDirYesDirectory containing the built files to publish (e.g., dist, build)
envVarsNoEnvironment variables for the build process

Implementation Reference

  • The handler logic for the 'createSiteFromGitHub' tool. Validates input parameters, constructs the site creation payload for the Netlify API, makes a POST request to /sites, and returns the site details or throws appropriate MCP errors on failure.
    case 'createSiteFromGitHub': {
      const args = request.params.arguments as unknown as CreateSiteFromGitHubArgs;
      if (!args?.name || !args?.repo || !args?.buildCommand || !args?.publishDir) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Missing required parameters: name, repo, buildCommand, and publishDir are required'
        );
      }
    
      // Validate repo format
      if (!args.repo.match(/^[\w.-]+\/[\w.-]+$/)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid repo format. Must be in format: owner/repo'
        );
      }
    
      try {
        const siteData = {
          name: args.name,
          repo: {
            provider: 'github',
            repo: args.repo,
            branch: args.branch || 'main',
            cmd: args.buildCommand,
            dir: args.publishDir,
          },
        };
    
        // Add environment variables if provided
        if (args.envVars) {
          siteData.repo['env'] = args.envVars;
        }
    
        const response = await this.axiosInstance.post('/sites', siteData);
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify({
                success: true,
                site: {
                  id: response.data.id,
                  name: response.data.name,
                  url: response.data.url,
                  admin_url: response.data.admin_url,
                  deploy_url: response.data.deploy_url,
                  created_at: response.data.created_at,
                },
                message: `Site created successfully! Visit ${response.data.admin_url} to manage it.`,
              }, null, 2),
            },
          ],
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          throw new McpError(
            ErrorCode.InternalError,
            `Failed to create site: ${this.formatNetlifyError(error)}`
          );
        }
        throw error;
      }
    }
  • src/index.ts:106-141 (registration)
    Tool registration in the ListTools handler, defining the name, description, and JSON inputSchema for 'createSiteFromGitHub'.
    {
      name: 'createSiteFromGitHub',
      description: 'Create a new Netlify site from a GitHub repository',
      inputSchema: {
        type: 'object',
        properties: {
          name: {
            type: 'string',
            description: 'Name for the new site (will be used as subdomain)',
          },
          repo: {
            type: 'string',
            description: 'GitHub repository in format owner/repo',
          },
          branch: {
            type: 'string',
            description: 'Branch to deploy from (default: main)',
            default: 'main',
          },
          buildCommand: {
            type: 'string',
            description: 'Build command to run (e.g., npm run build)',
          },
          publishDir: {
            type: 'string',
            description: 'Directory containing the built files to publish (e.g., dist, build)',
          },
          envVars: {
            type: 'object',
            description: 'Environment variables for the build process',
            additionalProperties: { type: 'string' },
          },
        },
        required: ['name', 'repo', 'buildCommand', 'publishDir'],
      },
    },
  • TypeScript interface defining the shape of arguments for the createSiteFromGitHub handler, used for type assertion.
    interface CreateSiteFromGitHubArgs {
      name: string;
      repo: string;
      branch: string;
      buildCommand: string;
      publishDir: string;
      envVars?: Record<string, string>;
    }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It states the tool creates a site but doesn't mention critical behaviors like whether this requires specific permissions, if it's idempotent, what happens on failure, or if there are rate limits. This leaves significant gaps for an agent to understand the tool's operational characteristics.

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 a single, clear sentence that directly states the tool's purpose without any unnecessary words. It's perfectly front-loaded and wastes no space, making it highly efficient for an agent to parse.

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?

For a creation tool with 6 parameters, no annotations, and no output schema, the description is insufficient. It doesn't explain what the tool returns upon success or failure, doesn't mention authentication requirements, and provides no context about the Netlify platform or GitHub integration. The agent would need to guess about many operational aspects.

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 schema description coverage is 100%, so all parameters are documented in the schema. The description doesn't add any additional parameter semantics beyond what's already in the schema, such as explaining relationships between parameters or providing examples. This meets the baseline expectation when schema coverage is complete.

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

Purpose4/5

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

The description clearly states the action ('Create') and resource ('new Netlify site from a GitHub repository'), making the purpose immediately understandable. However, it doesn't explicitly differentiate from sibling tools like 'deleteSite' or 'getSite' beyond the obvious action difference, which is why it doesn't reach a perfect score.

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 like 'listSites' or 'getSite', nor does it mention prerequisites such as GitHub authentication or Netlify account setup. It simply states what the tool does without contextual usage information.

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

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