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
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the gist | |
| public | Yes | Whether the gist is public | |
| files | Yes | Files that make up this gist. The key is the filename. |
Implementation Reference
- src/operations/gists.ts:73-92 (handler)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); }
- src/operations/gists.ts:40-48 (schema)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), },
- src/index.ts:657-664 (handler)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) }], }; }