Skip to main content
Glama
nextDriveIoE

GitHub Action Trigger MCP Server

by nextDriveIoE

get_github_release

Retrieve the two most recent releases from any GitHub repository to monitor updates, track version changes, or automate workflows using repository owner and name inputs.

Instructions

Get the latest 2 releases from a GitHub repository

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesOwner of the repository (username or organization)
repoYesName of the repository
tokenNoGitHub personal access token (optional)

Implementation Reference

  • The core handler function that implements the tool logic by fetching the latest 2 releases from the GitHub API, formatting the data, and handling errors.
    async function getGitHubReleases(owner: string, repo: string, token?: string) {
      // Use provided token or fall back to config token
      const authToken = token || config.githubToken;
      
      try {
        const headers: Record<string, string> = {
          'Accept': 'application/vnd.github+json',
          'X-GitHub-Api-Version': '2022-11-28'
        };
        
        if (authToken) {
          headers['Authorization'] = `Bearer ${authToken}`;
        }
        
        // Fetch releases from the GitHub API - limit to the latest 2
        const releasesResponse = await axios.get(
          `https://api.github.com/repos/${owner}/${repo}/releases?per_page=2`,
          { headers }
        );
        
        // Format the release information
        const releases = releasesResponse.data.map((release: any) => {
          // Extract asset information
          const assets = release.assets.map((asset: any) => ({
            name: asset.name,
            size: asset.size,
            download_count: asset.download_count,
            browser_download_url: asset.browser_download_url,
            created_at: asset.created_at,
            updated_at: asset.updated_at
          }));
          
          return {
            id: release.id,
            name: release.name || release.tag_name,
            tag_name: release.tag_name,
            published_at: release.published_at,
            draft: release.draft,
            prerelease: release.prerelease,
            html_url: release.html_url,
            body: release.body,
            assets: assets,
            author: {
              login: release.author.login,
              html_url: release.author.html_url
            }
          };
        });
        
        return {
          count: releases.length,
          releases: releases
        };
      } catch (error) {
        if (axios.isAxiosError(error)) {
          // Handle 404 (no releases)
          if (error.response?.status === 404) {
            return {
              count: 0,
              releases: [],
              message: 'No releases found for this repository'
            };
          }
          throw new Error(`GitHub API error: ${error.response?.status} ${error.response?.statusText} - ${error.response?.data?.message || error.message}`);
        }
        throw error;
      }
    }
  • src/index.ts:194-215 (registration)
    Tool registration in the tools array passed to server.setTools(), including name, description, and input schema definition.
    {
      name: "get_github_release",
      description: "Get the latest 2 releases from a GitHub repository",
      inputSchema: {
        type: "object",
        properties: {
          owner: {
            type: "string",
            description: "Owner of the repository (username or organization)"
          },
          repo: {
            type: "string",
            description: "Name of the repository"
          },
          token: {
            type: "string",
            description: "GitHub personal access token (optional)"
          }
        },
        required: ["owner", "repo"]
      }
    },
  • The dispatch handler case within the main CallToolRequestSchema handler that extracts arguments, calls the getGitHubReleases function, and formats the response.
    case "get_github_release": {
      const owner = String(request.params.arguments?.owner);
      const repo = String(request.params.arguments?.repo);
      const token = request.params.arguments?.token ? String(request.params.arguments?.token) : undefined;
      
      if (!owner || !repo) {
        throw new Error("Owner and repo are required");
      }
    
      try {
        const releases = await getGitHubReleases(owner, repo, token);
        
        return {
          content: [{
            type: "text",
            text: JSON.stringify(releases, null, 2)
          }]
        };
      } catch (error) {
        if (error instanceof Error) {
          throw new Error(`Failed to get GitHub releases: ${error.message}`);
        }
        throw error;
      }
    }
  • The input schema definition for the 'get_github_release' tool, specifying parameters and validation.
    inputSchema: {
      type: "object",
      properties: {
        owner: {
          type: "string",
          description: "Owner of the repository (username or organization)"
        },
        repo: {
          type: "string",
          description: "Name of the repository"
        },
        token: {
          type: "string",
          description: "GitHub personal access token (optional)"
        }
      },
      required: ["owner", "repo"]
    }

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/nextDriveIoE/github-action-trigger-mcp'

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