Skip to main content
Glama

upload_release_asset

Add files like binaries or documentation to GitHub releases for distribution. Specify repository details, release ID, asset name, content type, and base64-encoded content to attach assets to releases.

Instructions

Upload an asset to a GitHub release

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ownerYesRepository owner (username or organization)
repoYesRepository name
release_idYesThe ID of the release
nameYesThe name of the asset
labelNoAn alternate short description of the asset
contentYesThe content of the asset (base64 encoded)
content_typeYesThe content type of the asset

Implementation Reference

  • The main handler function that implements the upload_release_asset tool logic. It fetches the release upload URL, constructs the final upload URL with parameters, and performs the POST request to upload the base64-encoded asset content.
    export async function uploadReleaseAsset(
      github_pat: string,
      owner: string,
      repo: string,
      release_id: number,
      name: string,
      content: string,
      content_type: string,
      label?: string
    ): Promise<z.infer<typeof ReleaseAssetSchema>> {
      // Get the release to get the upload_url
      const release = await githubRequest(
        github_pat,
        `https://api.github.com/repos/${owner}/${repo}/releases/${release_id}`
      );
      
      const uploadUrl = (release as any).upload_url.replace(
        "{?name,label}",
        ""
      );
      
      const url = new URL(uploadUrl);
      url.searchParams.append("name", name);
      if (label) url.searchParams.append("label", label);
      
      const response = await githubRequest(
        github_pat,
        url.toString(),
        {
          method: "POST",
          body: Buffer.from(content, "base64").toString(),
          headers: {
            "Content-Type": content_type,
          },
        }
      );
      
      return ReleaseAssetSchema.parse(response);
    }
  • Zod schemas defining the input parameters for the upload_release_asset tool. UploadReleaseAssetSchema for public inputs, _UploadReleaseAssetSchema extends it internally with github_pat.
    export const UploadReleaseAssetSchema = z.object({
      owner: z.string().describe("Repository owner (username or organization)"),
      repo: z.string().describe("Repository name"),
      release_id: z.number().describe("The ID of the release"),
      name: z.string().describe("The name of the asset"),
      label: z.string().optional().describe("An alternate short description of the asset"),
      content: z.string().describe("The content of the asset (base64 encoded)"),
      content_type: z.string().describe("The content type of the asset")
    });
    
    export const _UploadReleaseAssetSchema = UploadReleaseAssetSchema.extend({
      github_pat: z.string().describe("GitHub Personal Access Token"),
    });
  • src/index.ts:184-188 (registration)
    Tool registration in the MCP server's listTools handler, defining the tool name, description, and input schema.
    {
      name: "upload_release_asset",
      description: "Upload an asset to a GitHub release",
      inputSchema: zodToJsonSchema(releases.UploadReleaseAssetSchema),
    },
  • src/index.ts:567-576 (registration)
    Dispatch/registration logic in the CallToolRequest handler's switch statement, parsing arguments and calling the uploadReleaseAsset function.
    case "upload_release_asset": {
      const args = releases._UploadReleaseAssetSchema.parse(params.arguments);
      const { github_pat, owner, repo, release_id, name, content, content_type, label } = args;
      const result = await releases.uploadReleaseAsset(
        github_pat, owner, repo, release_id, name, content, content_type, label
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }

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/MissionSquad/mcp-github'

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