Generate a Focused GitHub REST API MCP Server

Generate a minimal, auditable GitHub Issues & Triage MCP server from OpenAPI JSON—zero black-box Docker containers, zero unnecessary repo-admin scopes.

Fine-grained GitHub PAT (Bearer github_pat_...)Recommended: TypeScript SDK + Zod
Presets:
Context Footprint~861 tok
Lean context footprintOpenAPI 3.0.3

MCP Tool Selection

6 / 10 Free

6 endpoints parsed • 1 safety-guarded

GET/repos/{owner}/{repo}/issues~154t

List issues in a GitHub repository

tool:
readOnly5 params
POST/repos/{owner}/{repo}/issues~160t

Open a new GitHub issue

tool:
6 params
GET/repos/{owner}/{repo}/issues/{issue_number}~109t

Get details for a single GitHub issue

tool:
readOnly3 params
PATCH/repos/{owner}/{repo}/issues/{issue_number}~165t

Update issue title, state, or labels

tool:
6 params
POST/repos/{owner}/{repo}/issues/{issue_number}/comments~128t

Post a comment on an issue

tool:
4 params
PUT/repos/{owner}/{repo}/issues/{issue_number}/lock~145t

Lock an issue conversation thread

tool:
4 params
src/index.ts283 lines
1#!/usr/bin/env node
2/**
3 * Generated by Spec2MCP (https://spec2mcp.com)
4 * Server: github-issues-rest-api v2022-11-28
5 * Tools exposed: 6
6 */
7import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
8import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
9import { z } from "zod";
10
11const BASE_URL = (process.env.GITHUB_ISSUES_REST_API_BASE_URL ?? "https://api.github.com").replace(/\/+$/, "");
12const API_TOKEN = process.env.GITHUB_ISSUES_REST_API_API_TOKEN ?? "";
13function buildAuthHeaders(): Record<string, string> {
14 return API_TOKEN ? { Authorization: `Bearer ${API_TOKEN}` } : {};
15}
16
17interface UpstreamRequest {
18 method: string;
19 path: string;
20 query?: URLSearchParams;
21 body?: Record<string, unknown>;
22}
23
24async function callUpstream(req: UpstreamRequest) {
25 const qs = req.query && req.query.toString() ? `?${req.query.toString()}` : "";
26 const url = `${BASE_URL}${req.path}${qs}`;
27
28 const headers: Record<string, string> = {
29 Accept: "application/json",
30 "User-Agent": "spec2mcp/github-issues-rest-api",
31 ...buildAuthHeaders(),
32 };
33
34 if (req.body !== undefined) {
35 headers["Content-Type"] = "application/json";
36 }
37
38 try {
39 const controller = new AbortController();
40 const timer = setTimeout(() => controller.abort(), 20_000);
41 const response = await fetch(url, {
42 method: req.method,
43 headers,
44 body: req.body !== undefined ? JSON.stringify(req.body) : undefined,
45 signal: controller.signal,
46 });
47 clearTimeout(timer);
48
49 const rawText = await response.text();
50 let formatted = rawText;
51 try {
52 formatted = JSON.stringify(JSON.parse(rawText), null, 2);
53 } catch {
54 // keep raw text if upstream returned non-JSON
55 }
56
57 if (!response.ok) {
58 return {
59 isError: true,
60 content: [
61 {
62 type: "text" as const,
63 text: `HTTP ${response.status} ${response.statusText} from ${req.method} ${req.path}\n${formatted}`,
64 },
65 ],
66 };
67 }
68
69 return {
70 content: [
71 {
72 type: "text" as const,
73 text: formatted || `HTTP ${response.status} (empty body)`,
74 },
75 ],
76 };
77 } catch (err) {
78 const message = err instanceof Error ? err.message : String(err);
79 return {
80 isError: true,
81 content: [
82 {
83 type: "text" as const,
84 text: `Network error calling ${req.method} ${url}: ${message}`,
85 },
86 ],
87 };
88 }
89}
90
91const server = new McpServer({
92 name: "github-issues-rest-api",
93 version: "2022-11-28",
94});
95
96server.tool(
97 "list_repo_issues",
98 "List issues in a GitHub repository [GET /repos/{owner}/{repo}/issues]",
99 {
100 "owner": z.string().describe("Repository owner"),
101 "repo": z.string().describe("Repository name"),
102 "state": z.enum(["open", "closed", "all"]).describe("Filter by issue state").optional(),
103 "labels": z.string().describe("Comma-separated label names").optional(),
104 "per_page": z.number().int().describe("Results per page (max 100)").optional(),
105 },
106 {
107 title: "List issues in a GitHub repository",
108 readOnlyHint: true,
109 destructiveHint: false,
110 idempotentHint: true,
111 openWorldHint: true,
112 },
113 async (args) => {
114 const query = new URLSearchParams();
115 if (args["state"] !== undefined) query.set("state", String(args["state"]));
116 if (args["labels"] !== undefined) query.set("labels", String(args["labels"]));
117 if (args["per_page"] !== undefined) query.set("per_page", String(args["per_page"]));
118 return callUpstream({
119 method: "GET",
120 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues`,
121 query,
122 });
123 }
124);
125
126server.tool(
127 "create_repo_issue",
128 "Open a new GitHub issue [POST /repos/{owner}/{repo}/issues]",
129 {
130 "owner": z.string().describe("Repository owner"),
131 "repo": z.string().describe("Repository name"),
132 "title": z.string().describe("Issue title"),
133 "body": z.string().describe("Markdown description of the issue").optional(),
134 "labels": z.array(z.unknown()).describe("List of label names").optional(),
135 "assignees": z.array(z.unknown()).describe("GitHub usernames to assign").optional(),
136 },
137 {
138 title: "Open a new GitHub issue",
139 readOnlyHint: false,
140 destructiveHint: false,
141 idempotentHint: false,
142 openWorldHint: true,
143 },
144 async (args) => {
145 const bodyPayload: Record<string, unknown> = {};
146 if (args["title"] !== undefined) bodyPayload["title"] = args["title"];
147 if (args["body"] !== undefined) bodyPayload["body"] = args["body"];
148 if (args["labels"] !== undefined) bodyPayload["labels"] = args["labels"];
149 if (args["assignees"] !== undefined) bodyPayload["assignees"] = args["assignees"];
150 return callUpstream({
151 method: "POST",
152 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues`,
153 body: bodyPayload,
154 });
155 }
156);
157
158server.tool(
159 "get_issue",
160 "Get details for a single GitHub issue [GET /repos/{owner}/{repo}/issues/{issue_number}]",
161 {
162 "owner": z.string().describe("Repository owner"),
163 "repo": z.string().describe("Repository name"),
164 "issue_number": z.number().int().describe("Issue number"),
165 },
166 {
167 title: "Get details for a single GitHub issue",
168 readOnlyHint: true,
169 destructiveHint: false,
170 idempotentHint: true,
171 openWorldHint: true,
172 },
173 async (args) => {
174 return callUpstream({
175 method: "GET",
176 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues/${encodeURIComponent(String(args["issue_number"]))}`,
177 });
178 }
179);
180
181server.tool(
182 "update_issue",
183 "Update issue title, state, or labels [PATCH /repos/{owner}/{repo}/issues/{issue_number}]",
184 {
185 "owner": z.string().describe("Repository owner"),
186 "repo": z.string().describe("Repository name"),
187 "issue_number": z.number().int().describe("Issue number"),
188 "title": z.string().describe("Updated title").optional(),
189 "state": z.enum(["open", "closed"]).describe("New issue state").optional(),
190 "labels": z.array(z.unknown()).describe("Replacement labels list").optional(),
191 },
192 {
193 title: "Update issue title, state, or labels",
194 readOnlyHint: false,
195 destructiveHint: false,
196 idempotentHint: false,
197 openWorldHint: true,
198 },
199 async (args) => {
200 const bodyPayload: Record<string, unknown> = {};
201 if (args["title"] !== undefined) bodyPayload["title"] = args["title"];
202 if (args["state"] !== undefined) bodyPayload["state"] = args["state"];
203 if (args["labels"] !== undefined) bodyPayload["labels"] = args["labels"];
204 return callUpstream({
205 method: "PATCH",
206 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues/${encodeURIComponent(String(args["issue_number"]))}`,
207 body: bodyPayload,
208 });
209 }
210);
211
212server.tool(
213 "create_issue_comment",
214 "Post a comment on an issue [POST /repos/{owner}/{repo}/issues/{issue_number}/comments]",
215 {
216 "owner": z.string().describe("Repository owner"),
217 "repo": z.string().describe("Repository name"),
218 "issue_number": z.number().int().describe("Issue number"),
219 "body": z.string().describe("Markdown comment body"),
220 },
221 {
222 title: "Post a comment on an issue",
223 readOnlyHint: false,
224 destructiveHint: false,
225 idempotentHint: false,
226 openWorldHint: true,
227 },
228 async (args) => {
229 const bodyPayload: Record<string, unknown> = {};
230 if (args["body"] !== undefined) bodyPayload["body"] = args["body"];
231 return callUpstream({
232 method: "POST",
233 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues/${encodeURIComponent(String(args["issue_number"]))}/comments`,
234 body: bodyPayload,
235 });
236 }
237);
238
239server.tool(
240 "lock_issue_conversation",
241 "Lock an issue conversation thread [PUT /repos/{owner}/{repo}/issues/{issue_number}/lock]",
242 {
243 "owner": z.string().describe("Repository owner"),
244 "repo": z.string().describe("Repository name"),
245 "issue_number": z.number().int().describe("Issue number"),
246 "lock_reason": z.enum(["off-topic", "too heated", "resolved", "spam"]).describe("Moderation lock reason").optional(),
247 confirm_destructive_action: z.boolean().describe("Safety guard: must be explicitly set to true to execute this PUT operation."),
248 },
249 {
250 title: "Lock an issue conversation thread",
251 readOnlyHint: false,
252 destructiveHint: true,
253 idempotentHint: true,
254 openWorldHint: true,
255 },
256 async (args) => {
257 if (!args.confirm_destructive_action) {
258 return {
259 isError: true,
260 content: [{ type: "text", text: "Blocked by safety guard: set confirm_destructive_action=true after user confirmation." }],
261 };
262 }
263 const bodyPayload: Record<string, unknown> = {};
264 if (args["lock_reason"] !== undefined) bodyPayload["lock_reason"] = args["lock_reason"];
265 return callUpstream({
266 method: "PUT",
267 path: `/repos/${encodeURIComponent(String(args["owner"]))}/${encodeURIComponent(String(args["repo"]))}/issues/${encodeURIComponent(String(args["issue_number"]))}/lock`,
268 body: bodyPayload,
269 });
270 }
271);
272
273async function main() {
274 const transport = new StdioServerTransport();
275 await server.connect(transport);
276 console.error("github-issues-rest-api MCP server listening on stdio (6 tools)");
277}
278
279main().catch((err) => {
280 console.error("Fatal MCP server error:", err);
281 process.exit(1);
282});
283
$ npm install && npm run build && GITHUB_ISSUES_REST_API_API_TOKEN=... node build/index.js
6 tools • ~861 tokens

How to export & compile your GitHub REST OpenAPI spec

Try the built-in 'GitHub Issues' preset right now, or upload a subset of github/rest-api-description.

$GITHUB_ISSUES_REST_API_API_TOKEN=github_pat_xxx node build/index.js

High-Signal GitHub REST MCP Tools to Expose First

MethodEndpoint PathMCP Tool Name
GET/repos/{owner}/{repo}/issueslist_repo_issues
POST/repos/{owner}/{repo}/issuescreate_repo_issue
PATCH/repos/{owner}/{repo}/issues/{issue_number}update_issue
POST/repos/{owner}/{repo}/issues/{issue_number}/commentscreate_issue_comment

Best Practices for GitHub REST

  • Use GitHub Fine-Grained Personal Access Tokens restricted to a single repository and read/write Issues only.
  • Keep lock_issue_conversation and destructive moderation actions behind the confirmation guard.
  • Add X-GitHub-Api-Version: 2022-11-28 inside callUpstream() if your organization pins GitHub REST API versions.

Common GitHub REST MCP Gotchas

  • GitHub's official OpenAPI description has 1,000+ operations; never load the unpruned spec into an MCP server.
  • GitHub returns Pull Requests inside /issues GET responses—remind agents via tool descriptions to inspect the pull_request field if filtering issues only.
  • Authenticated PATs get 5,000 requests/hour, whereas unauthenticated calls fail quickly at 60/hour.

GitHub REST API to MCP Server — Frequently Asked Questions

Why generate my own GitHub MCP server instead of using a generic binary?

You own 100% of the ~180 lines of auditable TypeScript or Python code, expose only the exact 5–8 endpoints your workflow needs, and keep your agent's context window lean.

Does it work with GitHub Enterprise Server?

Yes—override GITHUB_ISSUES_REST_API_BASE_URL in mcp.json to https://github.yourcompany.com/api/v3.

Can I add Pull Request diff endpoints too?

Yes. Paste any additional GitHub OpenAPI path definitions (such as /repos/{owner}/{repo}/pulls) into the JSON editor and regenerate immediately.

Related OpenAPI-to-MCP Converters

View all 20
Transparent Developer Pricing

Free locally forever. Upgrade when your team goes remote.

Compile focused local TypeScript & Python MCP servers in your browser for $0. Move to Pro Cloud or Team when you need unlimited endpoints, hosted Remote MCP URLs, OAuth2 proxying, and CI sync.

Free Local Studio
$0/ forever

Everything solo engineers need to turn REST APIs into local stdio MCP servers with zero login.

  • Local TypeScript SDK + Zod codegen
  • Local Python FastMCP + httpx codegen
  • Up to 10 endpoints per MCP server
  • Live context-window token estimator
  • Destructive action confirmation guards
  • Claude Desktop, Cursor, Windsurf & Antigravity mcp.json
  • 100% client-side — specs stay in browser
Use Free Studio Now
Most Popular
Pro Cloud
$29/ month

Compile unlimited endpoints and publish a hosted Remote MCP URL with encrypted credential vaulting.

  • Unlimited OpenAPI endpoints & tool grouping
  • 1-click hosted Remote MCP endpoint (Streamable HTTP)
  • Encrypted OAuth2 & API-Key secret vault
  • Custom tool presets & OpenAPI overlay persistence
  • Response payload truncation to stop context blowups
  • Priority email & Discord support
Team
$79/ month

Built for engineering orgs keeping internal MCP servers automatically synced with OpenAPI repos.

  • Everything in Pro Cloud
  • GitHub / GitLab CI auto-sync on OpenAPI PR merges
  • Per-tool invocation audit logs & latency metrics
  • Per-user rate limits & destructive-tool approval policies
  • Role-based access across engineering & ops teams
  • Dedicated onboarding & custom auth helpers