create_gist
Generate and share code snippets or text files as GitHub gists. Specify public or private visibility, add descriptions, and include multiple files for organized sharing.
Instructions
Create a new gist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| description | No | Description of the gist | |
| files | Yes | Files that make up this gist. The key is the filename. | |
| public | Yes | Whether the gist is public |
Implementation Reference
- src/operations/gists.ts:73-92 (handler)The core handler function that executes the tool logic by making a POST request to GitHub's gists API and parsing the response.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)The public input schema definition for the create_gist tool, referenced in registration.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 list of tools returned by ListToolsRequestHandler.name: "create_gist", description: "Create a new gist", inputSchema: zodToJsonSchema(gists.CreateGistSchema), },
- src/index.ts:657-664 (registration)Dispatch handler in CallToolRequestHandler that parses arguments and calls the 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) }], }; }
- src/operations/gists.ts:50-52 (schema)Internal extended schema used for argument parsing in the dispatch handler.export const _CreateGistSchema = CreateGistSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });