Skip to main content
Glama

create_gist

Create and share code snippets or text files on GitHub as gists for collaboration or reference, with options for public or private visibility.

Instructions

Create a new gist

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
descriptionNoDescription of the gist
publicYesWhether the gist is public
filesYesFiles that make up this gist. The key is the filename.

Implementation Reference

  • Core handler function that executes the logic to create a GitHub gist via API POST request.
    export async function createGist(
      github_pat: string,
      description: string | undefined,
      isPublic: boolean,
      files: Record<string, { content: string }>
    ): Promise<z.infer<typeof GistSchema>> {
      const response = await githubRequest(
        github_pat,
        "https://api.github.com/gists",
        {
          method: "POST",
          body: {
            description,
            public: isPublic,
            files,
          },
        }
      );
      return GistSchema.parse(response);
    }
  • Input schema definition used for tool validation (public schema without PAT).
    export const CreateGistSchema = z.object({
      description: z.string().optional().describe("Description of the gist"),
      public: z.boolean().describe("Whether the gist is public"),
      files: z.record(
        z.object({
          content: z.string().describe("Content of the file"),
        })
      ).describe("Files that make up this gist. The key is the filename."),
    });
  • src/index.ts:234-237 (registration)
    Tool registration in the ListTools response, specifying name, description, and input schema.
      name: "create_gist",
      description: "Create a new gist",
      inputSchema: zodToJsonSchema(gists.CreateGistSchema),
    },
  • Dispatch handler in the main tool call switch statement that invokes the gists.createGist function.
    case "create_gist": {
      const args = gists._CreateGistSchema.parse(params.arguments);
      const { github_pat, description, public: isPublic, files } = args;
      const result = await gists.createGist(github_pat, description, isPublic, files);
      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