get_gist
Retrieve a specific GitHub gist by providing its ID. Use this tool to access and manage gist content efficiently within the mcp-github server.
Instructions
Get a specific gist
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| gist_id | Yes | The ID of the gist |
Implementation Reference
- src/operations/gists.ts:112-121 (handler)Core handler function that performs the GitHub API request to fetch a specific gist by ID and parses the response using GistSchema.export async function getGist( github_pat: string, gist_id: string ): Promise<z.infer<typeof GistSchema>> { const response = await githubRequest( github_pat, `https://api.github.com/gists/${gist_id}` ); return GistSchema.parse(response); }
- src/index.ts:243-247 (registration)Registration of the 'get_gist' tool in the list returned by ListToolsRequestHandler.{ name: "get_gist", description: "Get a specific gist", inputSchema: zodToJsonSchema(gists.GetGistSchema), },
- src/index.ts:675-682 (handler)MCP server request handler for 'get_gist' tool: parses arguments, calls gists.getGist, and formats response.case "get_gist": { const args = gists._GetGistSchema.parse(params.arguments); const { github_pat, gist_id } = args; const result = await gists.getGist(github_pat, gist_id); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }], }; }
- src/operations/gists.ts:64-70 (schema)Zod input schemas for get_gist: GetGistSchema (public) and _GetGistSchema (internal with github_pat). Used for validation and JsonSchema conversion.export const GetGistSchema = z.object({ gist_id: z.string().describe("The ID of the gist"), }); export const _GetGistSchema = GetGistSchema.extend({ github_pat: z.string().describe("GitHub Personal Access Token"), });
- src/operations/gists.ts:18-37 (schema)Output schema for parsing GitHub Gist API response in getGist.export const GistSchema = z.object({ url: z.string(), forks_url: z.string(), commits_url: z.string(), id: z.string(), node_id: z.string(), git_pull_url: z.string(), git_push_url: z.string(), html_url: z.string(), files: GistFileSchema, public: z.boolean(), created_at: z.string(), updated_at: z.string(), description: z.string().nullable(), comments: z.number(), user: GitHubIssueAssigneeSchema.nullable(), comments_url: z.string(), owner: GitHubIssueAssigneeSchema.nullable(), truncated: z.boolean().optional(), });