Templates / AI agent tools
GitHub issue MCP tool: let an AI agent file bugs
An MCP tool that creates GitHub issues in one repository with a fine-grained token — so Claude or Cursor can file bugs without access to anything else.
Give an agent exactly one power: opening issues in one repository. The function holds a fine-grained token limited to that repo; the agent sees only a tool with a title, body and labels.
Build it with Wisp
Type this into Wisp, or press Build this — it writes the code below, deploys it and gives you a URL:
An MCP-only tool create_issue that creates an issue in the GITHUB_REPO repository with title, body and optional labels using GITHUB_TOKEN, and returns the issue number and URL.
The code
create-issue · MCP
import { config } from 'wisp';
export async function handler(req) {
const { title, body = '', labels = [] } = req.body ?? {};
if (typeof title !== 'string' || !title.trim()) return { status: 400, body: { error: 'title is required' } };
const res = await fetch(`https://api.github.com/repos/${config.require('GITHUB_REPO')}/issues`, {
method: 'POST',
headers: {
authorization: `Bearer ${config.require('GITHUB_TOKEN')}`,
accept: 'application/vnd.github+json',
'x-github-api-version': '2022-11-28',
'user-agent': 'wisp-issue-tool',
},
body: JSON.stringify({ title: title.slice(0, 256), body: String(body).slice(0, 20_000), labels: Array.isArray(labels) ? labels.slice(0, 5) : [] }),
});
if (!res.ok) return { status: 502, body: { error: `GitHub said ${res.status}: ${(await res.text()).slice(0, 200)}` } };
const issue = await res.json();
return { body: { number: issue.number, url: issue.html_url } };
}
Set it up
Add these in the project’s Variables & secrets (secrets are encrypted and never shown in logs):
GITHUB_TOKEN— GitHub → Settings → Developer settings → Fine-grained tokens: one repository, Issues read & write. Nothing else.GITHUB_REPO— A variable:owner/name.
Try it
Connect the project’s MCP URL to Claude or Cursor and say “file an issue: the export button does nothing on Safari”. The agent calls create-issue and links the new issue.
How it works
- The function is MCP-only: there’s no public URL, so only agents connected to the project’s MCP server can call it.
- A fine-grained token scoped to one repository limits the blast radius to “can open issues there”.
- Titles, bodies and labels are length-capped before they reach GitHub.
Variations
- Add a
search_issuestool so the agent checks for duplicates first. - Create Linear or Jira tickets instead.
- Always add a
from-agentlabel for triage.
Questions
Is it safe to give an AI agent a GitHub token? The agent never sees the token — only the tool. Keep the token minimal (one repo, issues only) and the worst case is unwanted issues, which you can close.
Build it with Wisp — free trial