### Clone Repository and Install Dependencies Source: https://github.com/ofershap/mcp-server-github-gist/blob/main/CONTRIBUTING.md Clone the project repository and install necessary npm packages to set up the development environment. ```bash git clone https://github.com/ofershap/{{PACKAGE_NAME}}.git cd {{PACKAGE_NAME}} npm install ``` -------------------------------- ### AI Assistant Prompts and MCP Tool Invocations Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Illustrates how AI assistant prompts translate into specific MCP tool calls for GitHub Gist operations. These examples cover creating, listing, getting, updating, deleting, and starring gists. ```plaintext // "Save this snippet as a secret gist called auth.ts" // → gist_create({ files: { "auth.ts": "" }, public: false }) // "List my last 5 gists" // → gist_list({ perPage: 5, page: 1 }) // "Show me gist abc123" // → gist_get({ gistId: "abc123" }) // "Update the description of gist abc123 to 'Fixed version'" // → gist_update({ gistId: "abc123", description: "Fixed version" }) // "Delete gist abc123" // → gist_delete({ gistId: "abc123" }) // "Star gist xyz789" // → gist_star({ gistId: "xyz789" }) ``` -------------------------------- ### Local Development Commands (Bash) Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Commands for local development, including installation, building, and testing. ```bash # Local development build npm install npm run build # compiles TypeScript to dist/ via tsup npm test # runs vitest unit tests npm run test:coverage ``` -------------------------------- ### Development Commands for MCP Server GitHub Gist Source: https://github.com/ofershap/mcp-server-github-gist/blob/main/README.md Standard npm commands for installing dependencies, running tests, and building the project. ```bash npm install ``` ```bash npm test ``` ```bash npm run build ``` -------------------------------- ### Conventional Commit Message Examples Source: https://github.com/ofershap/mcp-server-github-gist/blob/main/CONTRIBUTING.md Examples of commit messages following the Conventional Commits specification for automated versioning with semantic-release. ```markdown - `feat: add new feature` (triggers minor release) - `fix: resolve bug` (triggers patch release) - `feat!: breaking change` (triggers major release) ``` -------------------------------- ### Get Single Gist with Content (TypeScript) Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Retrieves a specific gist by its ID, including the full content of every file it contains. Handles potential 404 errors. ```typescript import { getGist, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "abc123"; try { const gist: Gist = await getGist(token, gistId); console.log(`Description: ${gist.description}`); console.log(`Comments: ${gist.comments}`); for (const [filename, file] of Object.entries(gist.files)) { console.log(` --- ${filename} (${file.language ?? "unknown"}, ${file.size} bytes) ---`); console.log(file.content); } // --- auth-middleware.ts (TypeScript, 312 bytes) --- // export function authMiddleware(req, res, next) { ... } } catch (err) { console.error(err); // GitHub API error (404): {"message":"Not Found","documentation_url":"..."} } ``` -------------------------------- ### MCP Server Startup and Gist Creation Tool Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Sets up the MCP server and registers the 'gist_create' tool. Requires GITHUB_TOKEN environment variable. The tool creates a new GitHub Gist with specified files and visibility. ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; const server = new McpServer({ name: "mcp-server-github-gist", version: "0.1.0", }); // Tool registration example — gist_create server.tool( "gist_create", "Create a new GitHub Gist", { description: z.string().optional().describe("Description of the gist"), public: z.boolean().default(false).describe("Whether the gist is public"), files: z.record(z.string(), z.string()).describe("Map of filename to content"), }, async ({ description, public: isPublic, files }) => { const token = getToken(); // reads GITHUB_TOKEN or GITHUB_PERSONAL_ACCESS_TOKEN const fileInput = Object.fromEntries( Object.entries(files).map(([name, content]) => [name, { content }]) ); const gist = await createGist(token, { description, public: isPublic, files: fileInput }); return { content: [{ type: "text", text: `Gist created!\n\nID: ${gist.id}\nURL: ${gist.html_url}` }], }; }, ); // Connect and serve const transport = new StdioServerTransport(); await server.connect(transport); // Server now listens for MCP JSON-RPC messages on stdin ``` -------------------------------- ### Development Build and Test Commands Source: https://github.com/ofershap/mcp-server-github-gist/blob/main/CONTRIBUTING.md Common npm scripts for building the project, type checking, running tests, and code formatting. ```bash npm run build # Build with tsup npm run typecheck # Type-check with tsc npm test # Run tests npm run test:watch # Run tests in watch mode npm run lint # Lint + format check npm run format # Auto-format with Prettier ``` -------------------------------- ### Claude Desktop Configuration for GitHub Gist MCP Server Source: https://github.com/ofershap/mcp-server-github-gist/blob/main/README.md Add this configuration to your `claude_desktop_config.json` to enable the GitHub Gist MCP server. Ensure you replace `ghp_your_token_here` with your actual GitHub token. ```json { "mcpServers": { "github-gist": { "command": "npx", "args": ["-y", "mcp-server-github-gist"], "env": { "GITHUB_TOKEN": "ghp_your_token_here" } } } } ``` -------------------------------- ### gist_create Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Creates a new GitHub Gist with specified files and metadata. The 'description' and 'public' parameters are optional. ```APIDOC ## gist_create ### Description Creates a new GitHub Gist. ### Parameters #### Request Body - **description** (string) - Optional - Description of the gist. - **public** (boolean) - Optional - Whether the gist is public. Defaults to false. - **files** (object) - Required - Map of filename to content. Example: `{"filename.txt": "content"}` ``` -------------------------------- ### MCP Server Configuration (JSON) Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Register the mcp-server-github-gist in your MCP host configuration file. Ensure your GITHUB_TOKEN environment variable is set with a valid personal access token. ```json { "mcpServers": { "github-gist": { "command": "npx", "args": ["-y", "mcp-server-github-gist"], "env": { "GITHUB_TOKEN": "ghp_your_personal_access_token_here" } } } } ``` -------------------------------- ### createGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Creates a new gist with one or more files. Gists are secret by default; pass `public: true` for publicly discoverable gists. ```APIDOC ## createGist ### Description Creates a new gist with one or more files. Gists are **secret by default** (`public: false`); pass `public: true` for publicly discoverable gists. ### Method Signature `createGist(token: string, input: GistCreateInput): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **input** (GistCreateInput) - Required - Object containing gist details: - **description** (string) - Optional - Description of the gist. - **public** (boolean) - Optional - Whether the gist is public (default: false). - **files** (object) - Required - An object where keys are filenames and values are file content objects: - **content** (string) - Required - The content of the file. ### Request Example ```typescript import { createGist, GistCreateInput, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const input: GistCreateInput = { description: "Express auth middleware + test", public: false, // secret gist (default) files: { "auth-middleware.ts": { content: `export function authMiddleware(req, res, next) { const token = req.headers.authorization?.split(" ")[1]; if (!token) return res.status(401).json({ error: "Unauthorized" }); next(); }`, }, "auth-middleware.test.ts": { content: `import { authMiddleware } from "./auth-middleware"; // ... tests`, }, }, }; const gist: Gist = await createGist(token, input); console.log(`Created gist: ${gist.html_url}`); console.log(`ID: ${gist.id}`); ``` ### Response #### Success Response (201 Created) - **gist** (Gist) - The created gist object. - **id** (string) - The ID of the gist. - **html_url** (string) - The URL of the gist. - **files** (object) - Files in the gist. - **description** (string) - Description of the gist. - **public** (boolean) - Whether the gist is public. - **created_at** (string) - Creation timestamp. - **updated_at** (string) - Last update timestamp. ### Response Example ```json { "id": "def456", "html_url": "https://gist.github.com/def456", "files": { "auth-middleware.ts": { "filename": "auth-middleware.ts", "content": "..." }, "auth-middleware.test.ts": { "filename": "auth-middleware.test.ts", "content": "..." } }, "description": "Express auth middleware + test", "public": false, "created_at": "2023-01-01T12:00:00Z", "updated_at": "2023-01-01T12:00:00Z" } ``` ``` -------------------------------- ### Create a New Gist with Files Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `createGist` to create a new gist with one or more files. Gists are secret by default; set `public: true` for public gists. Requires a GitHub token. ```typescript import { createGist, GistCreateInput, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const input: GistCreateInput = { description: "Express auth middleware + test", public: false, // secret gist (default) files: { "auth-middleware.ts": { content: `export function authMiddleware(req, res, next) { const token = req.headers.authorization?.split(" ")[1]; if (!token) return res.status(401).json({ error: "Unauthorized" }); next(); }`, }, "auth-middleware.test.ts": { content: `import { authMiddleware } from "./auth-middleware"; // ... tests`, }, }, }; const gist: Gist = await createGist(token, input); console.log(`Created gist: ${gist.html_url}`); // Created gist: https://gist.github.com/def456 console.log(`ID: ${gist.id}`); // ID: def456 ``` -------------------------------- ### List User Gists (TypeScript) Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Fetches a paginated list of the authenticated user's own gists. Requires the GITHUB_TOKEN environment variable to be set. ```typescript import { listGists, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; // Page 1, 10 results per page const gists: Gist[] = await listGists(token, 10, 1); for (const gist of gists) { console.log(`[${gist.id}] ${gist.description ?? "(no description)"}`); console.log(` URL: ${gist.html_url}`); console.log(` Public: ${gist.public}`); console.log(` Files: ${Object.keys(gist.files).join(", ")}`); console.log(` Updated: ${gist.updated_at}`); } // [abc123] My auth middleware // URL: https://gist.github.com/abc123 // Public: false // Files: auth-middleware.ts // Updated: 2026-01-15T12:00:00Z ``` -------------------------------- ### Generic GitHub API Fetch Helper (TypeScript) Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Internal helper for making authenticated GitHub API requests. It attaches the Bearer token and required headers, parses JSON responses, and throws descriptive errors for non-2xx status codes. Returns undefined for 204 No Content responses. ```typescript import { getGist } from "./src/github.js"; // All exported functions delegate to `request` internally. // Direct usage pattern (illustrative): async function request( path: string, token: string, options: RequestInit = {}, ): Promise { const response = await fetch(`https://api.github.com${path}`, { ...options, headers: { Authorization: `Bearer ${token}`, Accept: "application/vnd.github+json", "X-GitHub-Api-Version": "2022-11-28", "Content-Type": "application/json", ...options.headers, }, }); if (!response.ok) { const text = await response.text(); throw new Error(`GitHub API error (${response.status}): ${text}`); // Example error: "GitHub API error (404): {"message":"Not Found",...}" } if (response.status === 204) return undefined as T; return (await response.json()) as T; } ``` -------------------------------- ### List Gists Starred by Authenticated User Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `listStarredGists` to retrieve a paginated list of gists starred by the authenticated user. Requires a GitHub token, number of results, and page number. ```typescript import { listStarredGists, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const starred: Gist[] = await listStarredGists(token, 20, 1); if (starred.length === 0) { console.log("No starred gists found."); } else { starred.forEach((g) => console.log(`⭐ [${g.id}] ${g.description ?? "(no description)"} — ${g.html_url}`) ); // ⭐ [xyz789] Useful bash aliases — https://gist.github.com/xyz789 } ``` -------------------------------- ### gist_list Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Retrieves a list of GitHub Gists, with support for pagination. ```APIDOC ## gist_list ### Description Lists GitHub Gists. ### Parameters #### Query Parameters - **perPage** (integer) - Optional - Number of gists to return per page. - **page** (integer) - Optional - The page number to retrieve. ``` -------------------------------- ### gist_star Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Stars a GitHub Gist, marking it as a favorite. ```APIDOC ## gist_star ### Description Stars a GitHub Gist. ### Parameters #### Query Parameters - **gistId** (string) - Required - The ID of the gist to star. ``` -------------------------------- ### listStarredGists Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Returns a paginated list of gists that the authenticated user has starred, regardless of who owns them. ```APIDOC ## listStarredGists ### Description Returns a paginated list of gists that the authenticated user has starred, regardless of who owns them. ### Method Signature `listStarredGists(token: string, perPage: number, page: number): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **perPage** (number) - Optional - Number of gists to return per page (default: 30, max: 100). - **page** (number) - Optional - Page number of the results to fetch. ### Request Example ```typescript import { listStarredGists, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const starred: Gist[] = await listStarredGists(token, 20, 1); if (starred.length === 0) { console.log("No starred gists found."); } else { starred.forEach((g) => console.log(`⭐ [${g.id}] ${g.description ?? "(no description)"} — ${g.html_url}`) ); // ⭐ [xyz789] Useful bash aliases — https://gist.github.com/xyz789 } ``` ### Response #### Success Response (200 OK) - **starredGists** (Array) - An array of gist objects. - Each gist object contains: - **id** (string) - The ID of the gist. - **html_url** (string) - The URL of the gist. - **description** (string) - Description of the gist. - **public** (boolean) - Whether the gist is public. - **created_at** (string) - Creation timestamp. - **updated_at** (string) - Last update timestamp. ### Response Example ```json [ { "id": "xyz789", "html_url": "https://gist.github.com/xyz789", "description": "Useful bash aliases", "public": true, "created_at": "2022-01-01T10:00:00Z", "updated_at": "2022-01-01T10:00:00Z" } ] ``` ``` -------------------------------- ### listGists Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Fetches a paginated list of the authenticated user's own gists. It requires a GitHub personal access token and allows specifying the number of results per page and the page number. ```APIDOC ## listGists ### Description Fetches a paginated list of the authenticated user's own gists. ### Method GET (Implicit, as it's a read operation) ### Endpoint (Not explicitly defined, but implies interaction with the GitHub API for listing gists) ### Parameters #### Path Parameters None #### Query Parameters - **per_page** (integer) - Optional - Number of results per page. - **page** (integer) - Optional - The page number to retrieve. #### Request Body None ### Request Example ```typescript import { listGists, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; // Page 1, 10 results per page const gists: Gist[] = await listGists(token, 10, 1); for (const gist of gists) { console.log(`[${gist.id}] ${gist.description ?? "(no description)"}`); console.log(` URL: ${gist.html_url}`); console.log(` Public: ${gist.public}`); console.log(` Files: ${Object.keys(gist.files).join(", ")}`); console.log(` Updated: ${gist.updated_at}`); } ``` ### Response #### Success Response (200) - **Gist[]** (array of Gist objects) - A list of gist objects. #### Response Example ```json [ { "id": "abc123", "description": "My auth middleware", "html_url": "https://gist.github.com/abc123", "public": false, "files": { "auth-middleware.ts": { "filename": "auth-middleware.ts", "type": "application/typescript", "language": "TypeScript", "size": 312, "raw_url": "...", "content": "export function authMiddleware(req, res, next) { ... }" } }, "created_at": "2026-01-15T12:00:00Z", "updated_at": "2026-01-15T12:00:00Z", "comments": 0, "user": null, "owner": { "login": "user", "id": 12345, "avatar_url": "...", "url": "..." }, "truncated": false, "forks_url": "...", "forks": [], "commits_url": "...", "id": "abc123", "git_pull_url": "...", "git_push_url": "...", "html_url": "https://gist.github.com/abc123", "url": "...", "reviews_url": "...", "open_issues_count": 0, "public": false, "created_at": "2026-01-15T12:00:00Z", "updated_at": "2026-01-15T12:00:00Z", "description": "My auth middleware", "user": null, "comments": 0, "num_comments": 0, "owner": { "login": "user", "id": 12345, "avatar_url": "...", "url": "..." }, "truncated": false, "file_count": 1 } ] ``` ``` -------------------------------- ### getGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Retrieves a specific gist by its ID, including the full content of every file it contains. Requires a GitHub personal access token. ```APIDOC ## getGist ### Description Retrieves a specific gist by its ID, including the full content of every file it contains. ### Method GET (Implicit, as it's a read operation) ### Endpoint (Not explicitly defined, but implies interaction with the GitHub API for retrieving a specific gist) ### Parameters #### Path Parameters - **gistId** (string) - Required - The ID of the gist to retrieve. #### Query Parameters None #### Request Body None ### Request Example ```typescript import { getGist, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "abc123"; try { const gist: Gist = await getGist(token, gistId); console.log(`Description: ${gist.description}`); console.log(`Comments: ${gist.comments}`); for (const [filename, file] of Object.entries(gist.files)) { console.log(`\n--- ${filename} (${file.language ?? "unknown"}, ${file.size} bytes) ---`); console.log(file.content); } } catch (err) { console.error(err); // GitHub API error (404): {"message":"Not Found","documentation_url":"..."} } ``` ### Response #### Success Response (200) - **Gist** (object) - A Gist object with full file contents. #### Response Example ```json { "id": "abc123", "description": "My auth middleware", "comments": 0, "files": { "auth-middleware.ts": { "filename": "auth-middleware.ts", "type": "application/typescript", "language": "TypeScript", "size": 312, "raw_url": "...", "content": "export function authMiddleware(req, res, next) { ... }" } }, "created_at": "2026-01-15T12:00:00Z", "updated_at": "2026-01-15T12:00:00Z", "user": null, "owner": { "login": "user", "id": 12345, "avatar_url": "...", "url": "..." }, "truncated": false, "forks_url": "...", "forks": [], "commits_url": "...", "git_pull_url": "...", "git_push_url": "...", "html_url": "https://gist.github.com/abc123", "url": "...", "reviews_url": "...", "open_issues_count": 0, "public": false, "num_comments": 0, "file_count": 1 } ``` ``` -------------------------------- ### starGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Stars a gist by ID. Returns `void` on success (HTTP 204). ```APIDOC ## starGist ### Description Stars a gist by ID. Returns `void` on success (HTTP 204). ### Method Signature `starGist(token: string, gistId: string): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **gistId** (string) - Required - The ID of the gist to star. ### Request Example ```typescript import { starGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "xyz789"; try { await starGist(token, gistId); console.log(`Gist ${gistId} starred successfully.`); } catch (err) { console.error(err); // GitHub API error (404): {"message":"Not Found"} } ``` ### Response #### Success Response (204 No Content) - No response body. #### Error Response (e.g., 404 Not Found) - **message** (string) - Error message from GitHub API. ``` -------------------------------- ### TypeScript Gist Interface Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Defines the TypeScript interfaces for GitHub Gist objects and their associated files. Includes structures for creating and updating gists. ```typescript export interface Gist { id: string; // e.g. "abc123def456" url: string; // API URL: "https://api.github.com/gists/abc123" html_url: string; // Browser URL: "https://gist.github.com/abc123" description: string | null; public: boolean; files: Record; created_at: string; // ISO 8601, e.g. "2026-01-01T00:00:00Z" updated_at: string; comments: number; } export interface GistFile { filename: string; content: string; // Full content (only present in getGist responses) language?: string; // e.g. "TypeScript", "Python" size?: number; // Byte count } export interface GistCreateInput { description?: string; public?: boolean; files: Record; } export interface GistUpdateInput { description?: string; files?: Record; // null = delete the file } ``` -------------------------------- ### Star a Gist by ID Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `starGist` to star a specific gist by its ID. Returns `void` on success (HTTP 204). Requires a GitHub token and the gist ID. ```typescript import { starGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "xyz789"; try { await starGist(token, gistId); console.log(`Gist ${gistId} starred successfully.`); // Gist xyz789 starred successfully. } catch (err) { console.error(err); // GitHub API error (404): {"message":"Not Found"} } ``` -------------------------------- ### gist_unstar Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Unstars a GitHub Gist, removing it from favorites. ```APIDOC ## gist_unstar ### Description Unstars a GitHub Gist. ### Parameters #### Query Parameters - **gistId** (string) - Required - The ID of the gist to unstar. ``` -------------------------------- ### gist_get Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Retrieves a specific GitHub Gist by its ID. ```APIDOC ## gist_get ### Description Retrieves a specific GitHub Gist. ### Parameters #### Query Parameters - **gistId** (string) - Required - The ID of the gist to retrieve. ``` -------------------------------- ### gist_starred Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Retrieves a list of the authenticated user's starred GitHub Gists, with support for pagination. ```APIDOC ## gist_starred ### Description Lists the authenticated user's starred GitHub Gists. ### Parameters #### Query Parameters - **perPage** (integer) - Optional - Number of gists to return per page. - **page** (integer) - Optional - The page number to retrieve. ``` -------------------------------- ### Update Gist Description or File Contents Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `updateGist` to patch an existing gist's description or file contents. Set a file's content to `null` to delete it. Requires a GitHub token and the gist ID. ```typescript import { updateGist, GistUpdateInput, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "def456"; const input: GistUpdateInput = { description: "Express auth middleware + test (v2)", files: { // Update existing file "auth-middleware.ts": { content: `export function authMiddleware(req, res, next) { const token = req.headers.authorization?.split(" ")[1]; if (!token) return res.status(401).json({ error: "No token provided" }); // Additional validation... next(); }`, }, // Delete a file by setting content to null "auth-middleware.test.ts": null, }, }; const updated: Gist = await updateGist(token, gistId, input); console.log(`Updated: ${updated.updated_at}`); // Updated: 2026-02-01T09:30:00Z console.log(`Files now: ${Object.keys(updated.files).join(", ")}`); // Files now: auth-middleware.ts ``` -------------------------------- ### updateGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Patches an existing gist. Pass `null` as a file's content value to delete that file from the gist. ```APIDOC ## updateGist ### Description Patches an existing gist. Pass `null` as a file's content value to delete that file from the gist. ### Method Signature `updateGist(token: string, gistId: string, input: GistUpdateInput): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **gistId** (string) - Required - The ID of the gist to update. - **input** (GistUpdateInput) - Required - Object containing updated gist details: - **description** (string) - Optional - New description for the gist. - **files** (object) - Optional - An object where keys are filenames and values are file content objects or `null` to delete: - **content** (string | null) - Required - The new content of the file, or `null` to delete the file. ### Request Example ```typescript import { updateGist, GistUpdateInput, Gist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "def456"; const input: GistUpdateInput = { description: "Express auth middleware + test (v2)", files: { // Update existing file "auth-middleware.ts": { content: `export function authMiddleware(req, res, next) { const token = req.headers.authorization?.split(" ")[1]; if (!token) return res.status(401).json({ error: "No token provided" }); // Additional validation... next(); }`, }, // Delete a file by setting content to null "auth-middleware.test.ts": null, }, }; const updated: Gist = await updateGist(token, gistId, input); console.log(`Updated: ${updated.updated_at}`); console.log(`Files now: ${Object.keys(updated.files).join(", ")}`); ``` ### Response #### Success Response (200 OK) - **updatedGist** (Gist) - The updated gist object. - **id** (string) - The ID of the gist. - **html_url** (string) - The URL of the gist. - **files** (object) - Files in the gist. - **description** (string) - Description of the gist. - **public** (boolean) - Whether the gist is public. - **created_at** (string) - Creation timestamp. - **updated_at** (string) - Last update timestamp. ### Response Example ```json { "id": "def456", "html_url": "https://gist.github.com/def456", "files": { "auth-middleware.ts": { "filename": "auth-middleware.ts", "content": "...updated content..." } }, "description": "Express auth middleware + test (v2)", "public": false, "created_at": "2023-01-01T12:00:00Z", "updated_at": "2026-02-01T09:30:00Z" } ``` ``` -------------------------------- ### gist_update Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Updates an existing GitHub Gist, allowing modification of its description and files. Files can be added, updated, or deleted (by setting their value to null). ```APIDOC ## gist_update ### Description Updates an existing GitHub Gist. ### Parameters #### Request Body - **gistId** (string) - Required - The ID of the gist to update. - **description** (string) - Optional - The new description for the gist. - **files** (object) - Optional - Map of filename to content or null to delete. Example: `{"filename.txt": "new content"}` or `{"filename.txt": null}` ``` -------------------------------- ### unstarGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Removes a star from a gist. Returns `void` on success (HTTP 204). ```APIDOC ## unstarGist ### Description Removes a star from a gist. Returns `void` on success (HTTP 204). ### Method Signature `unstarGist(token: string, gistId: string): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **gistId** (string) - Required - The ID of the gist to unstar. ### Request Example ```typescript import { unstarGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "xyz789"; await unstarGist(token, gistId); console.log(`Gist ${gistId} unstarred.`); ``` ### Response #### Success Response (204 No Content) - No response body. ``` -------------------------------- ### deleteGist Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Permanently deletes a gist by ID. Returns `void` on success (GitHub responds with HTTP 204). This operation is irreversible. ```APIDOC ## deleteGist ### Description Permanently deletes a gist by ID. Returns `void` on success (GitHub responds with HTTP 204). This operation is irreversible. ### Method Signature `deleteGist(token: string, gistId: string): Promise` ### Parameters - **token** (string) - Required - GitHub authentication token. - **gistId** (string) - Required - The ID of the gist to delete. ### Request Example ```typescript import { deleteGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "def456"; try { await deleteGist(token, gistId); console.log(`Gist ${gistId} permanently deleted.`); } catch (err) { console.error(err); // GitHub API error (403): {"message":"Must have push access to delete a gist"} } ``` ### Response #### Success Response (204 No Content) - No response body. #### Error Response (e.g., 403 Forbidden) - **message** (string) - Error message from GitHub API. ``` -------------------------------- ### Delete a Gist Permanently Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `deleteGist` to permanently delete a gist by its ID. This operation is irreversible and requires appropriate permissions. Returns `void` on success. ```typescript import { deleteGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "def456"; try { await deleteGist(token, gistId); console.log(`Gist ${gistId} permanently deleted.`); // Gist def456 permanently deleted. } catch (err) { console.error(err); // GitHub API error (403): {"message":"Must have push access to delete a gist"} } ``` -------------------------------- ### Unstar a Gist by ID Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Use `unstarGist` to remove a star from a specific gist by its ID. Returns `void` on success (HTTP 204). Requires a GitHub token and the gist ID. ```typescript import { unstarGist } from "./src/github.js"; const token = process.env.GITHUB_TOKEN!; const gistId = "xyz789"; await unstarGist(token, gistId); console.log(`Gist ${gistId} unstarred.`); // Gist xyz789 unstarred. ``` -------------------------------- ### gist_delete Source: https://context7.com/ofershap/mcp-server-github-gist/llms.txt Deletes a specific GitHub Gist by its ID. ```APIDOC ## gist_delete ### Description Deletes a GitHub Gist. ### Parameters #### Query Parameters - **gistId** (string) - Required - The ID of the gist to delete. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.