Skip to main content
Glama

create_repo

Create or update GitHub repositories using natural language commands to manage project descriptions, topics, and website URLs.

Instructions

Create or update GitHub repositories using natural language commands

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
commandYesNatural language command like "Create a repository for my machine learning project with tags python tensorflow" or "Update repository-name description to New description with tags updated ml"

Implementation Reference

  • The core handler function registered for CallToolRequestSchema that implements the 'create_repo' tool logic. It validates input, parses the natural language command, calls GitHub Octokit API to create or update repositories, and formats the response.
    this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
      if (request.params.name !== 'create_repo') {
        throw new McpError(
          ErrorCode.MethodNotFound,
          `Unknown tool: ${request.params.name}`
        );
      }
    
      if (!isValidRepoArgs(request.params.arguments)) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'Invalid command format'
        );
      }
    
      try {
        const parsed = parseCommand(request.params.arguments.command);
    
        let response;
        if (parsed.mode === 'create') {
          // Generate a repository name based on the description
          const repoName = parsed.description!
            .toLowerCase()
            .replace(/[^a-z0-9]+/g, '-')
            .replace(/^-+|-+$/g, '');
    
          // Create the repository
          response = await this.octokit.rest.repos.createForAuthenticatedUser({
            name: repoName,
            description: parsed.description,
            homepage: parsed.website,
            topics: parsed.tags,
            auto_init: true,
          });
        } else {
          // Handle different types of updates
          const [owner, repo] = parsed.name!.split('/');
          
          switch (parsed.mode) {
            case 'update-description':
              response = await this.octokit.rest.repos.update({
                owner,
                repo,
                description: parsed.description,
              });
              break;
    
            case 'update-tags':
              response = await this.octokit.rest.repos.replaceAllTopics({
                owner,
                repo,
                names: parsed.tags || [],
              });
              break;
    
            case 'update-website':
              response = await this.octokit.rest.repos.update({
                owner,
                repo,
                homepage: parsed.website,
              });
              break;
          }
        }
    
        // Format response based on operation type
        const formatResponse = () => {
          switch (parsed.mode) {
            case 'create': {
              const repo = response.data as {
                html_url: string;
                name: string;
                description: string;
                topics: string[];
                homepage: string | null;
              };
              return {
                message: 'Repository created successfully',
                url: repo.html_url,
                name: repo.name,
                description: repo.description,
                topics: repo.topics,
                homepage: repo.homepage,
              };
            }
            case 'update-description': {
              const repo = response.data as {
                name: string;
                description: string;
              };
              return {
                message: 'Repository description updated',
                name: repo.name,
                description: repo.description,
              };
            }
            case 'update-tags': {
              const topics = response.data as {
                names: string[];
              };
              return {
                message: 'Repository topics updated',
                topics: topics.names,
              };
            }
            case 'update-website': {
              const repo = response.data as {
                name: string;
                homepage: string | null;
              };
              return {
                message: 'Repository website updated',
                name: repo.name,
                homepage: repo.homepage,
              };
            }
          }
        };
    
        return {
          content: [
            {
              type: 'text',
              text: JSON.stringify(formatResponse(), null, 2),
            },
          ],
        };
      } catch (error) {
        if (error instanceof Error) {
          return {
            content: [
              {
                type: 'text',
                text: `GitHub API error: ${error.message}`,
              },
            ],
            isError: true,
          };
        }
        throw error;
      }
    });
  • The tool schema definition returned by ListToolsRequestSchema handler, specifying name, description, and inputSchema for 'create_repo'.
    {
      name: 'create_repo',
      description: 'Create or update GitHub repositories using natural language commands',
      inputSchema: {
        type: 'object',
        properties: {
          command: {
            type: 'string',
            description: 'Natural language command like "Create a repository for my machine learning project with tags python tensorflow" or "Update repository-name description to New description with tags updated ml"'
          }
        },
        required: ['command'],
      },
    },
  • src/index.ts:156-173 (registration)
    Registration of the ListToolsRequestSchema handler that advertises the 'create_repo' tool.
    this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
      tools: [
        {
          name: 'create_repo',
          description: 'Create or update GitHub repositories using natural language commands',
          inputSchema: {
            type: 'object',
            properties: {
              command: {
                type: 'string',
                description: 'Natural language command like "Create a repository for my machine learning project with tags python tensorflow" or "Update repository-name description to New description with tags updated ml"'
              }
            },
            required: ['command'],
          },
        },
      ],
    }));
  • Key helper function that parses the natural language 'command' string into a structured ParsedCommand object used by the handler to determine action (create/update) and parameters.
    const parseCommand = (command: string): ParsedCommand => {
      const lowercaseCommand = command.toLowerCase();
      
      // Check for update commands
      if (lowercaseCommand.includes('update') || lowercaseCommand.includes('change') || lowercaseCommand.includes('set')) {
        // Extract repository name - common for all update commands
        const repoMatch = command.match(/(?:update|change|set|modify)\s+(?:the\s+)?(?:repository\s+)?([a-zA-Z0-9-_/]+)/i);
        if (!repoMatch) {
          throw new McpError(ErrorCode.InvalidParams, 'Repository name not found in update command');
        }
        const repoName = repoMatch[1];
    
        // Check for description update
        if (lowercaseCommand.includes('description')) {
          const descMatch = command.match(/description\s+(?:to|as)\s+["']?([^"']+)["']?/i);
          if (!descMatch) {
            throw new McpError(ErrorCode.InvalidParams, 'New description not found in update command');
          }
          return {
            mode: 'update-description',
            name: repoName,
            description: descMatch[1].trim()
          };
        }
    
        // Check for tags update
        if (lowercaseCommand.includes('tags') || lowercaseCommand.includes('topics')) {
          return {
            mode: 'update-tags',
            name: repoName,
            tags: extractTags(command)
          };
        }
    
        // Check for website update
        if (lowercaseCommand.includes('website') || lowercaseCommand.includes('homepage') || lowercaseCommand.includes('url')) {
          const website = extractWebsite(command);
          if (!website) {
            throw new McpError(ErrorCode.InvalidParams, 'New website URL not found in update command');
          }
          return {
            mode: 'update-website',
            name: repoName,
            website
          };
        }
    
        throw new McpError(ErrorCode.InvalidParams, 'Unknown update type. Use "description", "tags", or "website".');
      }
      
      // This is a create command
      const descMatch = command.match(/(?:create|make|new)\s+(?:a\s+)?(?:repository\s+)?(?:for|called|named)?\s+([^,\.]+)/i);
      if (!descMatch) {
        throw new McpError(ErrorCode.InvalidParams, 'Repository description not found in create command');
      }
    
      return {
        mode: 'create',
        description: descMatch[1].trim(),
        tags: extractTags(command),
        website: extractWebsite(command)
      };
    };
  • Type guard helper to validate that tool arguments contain a 'command' string.
    const isValidRepoArgs = (args: any): args is RepoArgs =>
      typeof args === 'object' &&
      args !== null &&
      typeof args.command === 'string';
Behavior2/5

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

No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool can 'create or update' repositories, implying mutation, but doesn't address permissions, rate limits, error handling, or what happens on updates (e.g., overwriting). For a mutation tool with zero annotation coverage, 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.

Conciseness5/5

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

The description is a single, efficient sentence that directly states the tool's purpose without unnecessary words. It's appropriately sized and front-loaded, making it easy to understand quickly.

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 tool's complexity (mutation operation with no annotations and no output schema), the description is incomplete. It lacks details on behavioral traits, error conditions, or return values, which are critical for a tool that modifies GitHub repositories. The high schema coverage doesn't compensate for these gaps.

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%, with the parameter 'command' fully documented in the schema. The description adds minimal value beyond the schema by reinforcing the natural language aspect but doesn't provide additional syntax, format details, or examples beyond what's already in the schema. This meets the baseline for high coverage.

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 tool's purpose: 'Create or update GitHub repositories using natural language commands.' It specifies the verb (create/update), resource (GitHub repositories), and method (natural language commands). However, with no sibling tools mentioned, there's no explicit differentiation from alternatives, preventing a score of 5.

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 minimal guidance on when to use this tool. It mentions 'using natural language commands' but doesn't specify prerequisites, constraints, or when to prefer this over other methods. No explicit alternatives or exclusions are discussed, leaving usage context vague.

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/PoliTwit1984/github-meta-mcp-server'

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