github WebMCP
Browser tool configuration for github
Tools (8)
github_fork()
Fork a GitHub repository
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.repo) return {error: 'Missing argument: repo'};
const resp = await fetch('https://api.github.com/repos/' + args.repo + '/forks', {
method: 'POST',
credentials: 'include',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({})
});
if (!resp.ok) {
const status = resp.status;
if (status === 401 || status === 403) return {error: 'HTTP ' + status, hint: 'Not logged in to GitHub'};
if (status === 404) return {error: 'Repo not found: ' + args.repo};
return {error: 'HTTP ' + status};
}
const fork = await resp.json();
return {
full_name: fork.full_name,
url: fork.html_url,
clone_url: fork.clone_url
};
};
return run(params || {});
}
github_get_repo_info()
Get current repository information
Parameters
No parameters
JavaScript Handler
(params) => {
const repoName = document.querySelector('[itemprop="name"] a')?.textContent?.trim();
const description = document.querySelector('[data-pjax="#repo-content-pjax-container"] p')?.textContent?.trim();
const stars = document.querySelector('#repo-stars-counter-star')?.getAttribute('title');
const forks = document.querySelector('#repo-network-counter')?.getAttribute('title');
return {
success: true,
repo: { name: repoName, description, stars, forks }
};
}
github_issue_create()
Create a GitHub issue
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.repo) return {error: 'Missing argument: repo'};
if (!args.title) return {error: 'Missing argument: title'};
const resp = await fetch('https://api.github.com/repos/' + args.repo + '/issues', {
method: 'POST',
credentials: 'include',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({title: args.title, body: args.body || ''})
});
if (!resp.ok) {
const status = resp.status;
if (status === 401 || status === 403) return {error: 'HTTP ' + status, hint: 'Not logged in to GitHub'};
if (status === 404) return {error: 'Repo not found: ' + args.repo};
return {error: 'HTTP ' + status};
}
const issue = await resp.json();
return {
number: issue.number,
title: issue.title,
url: issue.html_url,
state: issue.state
};
};
return run(params || {});
}
github_issues()
获取 GitHub 仓库的 issue 列表
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.repo) return {error: 'Missing argument: repo'};
const state = args.state || 'open';
const resp = await fetch('https://api.github.com/repos/' + args.repo + '/issues?state=' + state + '&per_page=30', {credentials: 'include'});
if (!resp.ok) return {error: 'HTTP ' + resp.status};
const issues = await resp.json();
return {
repo: args.repo, state, count: issues.length,
issues: issues.map(i => ({
number: i.number, title: i.title, state: i.state,
url: i.html_url,
author: i.user?.login, labels: i.labels?.map(l => l.name),
comments: i.comments, created_at: i.created_at,
is_pr: !!i.pull_request
}))
};
};
return run(params || {});
}
github_me()
获取当前 GitHub 登录用户信息
Parameters
No parameters
JavaScript Handler
(params) => {
const run = async function(args) {
const resp = await fetch('https://api.github.com/user', {credentials: 'include'});
if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 401 ? 'Not logged into github.com' : 'API error'};
const d = await resp.json();
return {
login: d.login, name: d.name, bio: d.bio,
url: d.html_url || ('https://github.com/' + d.login),
public_repos: d.public_repos, followers: d.followers, following: d.following,
created_at: d.created_at
};
};
return run(params || {});
}
github_pr_create()
Create a GitHub pull request
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.repo) return {error: 'Missing argument: repo'};
if (!args.title) return {error: 'Missing argument: title'};
if (!args.head) return {error: 'Missing argument: head', hint: 'Provide source branch as "user:branch" or "branch"'};
const resp = await fetch('https://api.github.com/repos/' + args.repo + '/pulls', {
method: 'POST',
credentials: 'include',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
title: args.title,
head: args.head,
base: args.base || 'main',
body: args.body || ''
})
});
if (!resp.ok) {
const status = resp.status;
if (status === 401 || status === 403) return {error: 'HTTP ' + status, hint: 'Not logged in to GitHub'};
if (status === 404) return {error: 'Repo not found: ' + args.repo};
if (status === 422) {
const d = await resp.json().catch(() => null);
const msg = d?.errors?.[0]?.message || d?.message || 'Validation failed';
return {error: msg, hint: 'Check that the head branch exists and has commits ahead of base'};
}
return {error: 'HTTP ' + status};
}
const pr = await resp.json();
return {
number: pr.number,
title: pr.title,
url: pr.html_url,
state: pr.state
};
};
return run(params || {});
}
github_repo()
获取 GitHub 仓库信息
Parameters
JavaScript Handler
(params) => {
const run = async function(args) {
if (!args.repo) return {error: 'Missing argument: repo', hint: 'Use owner/repo format'};
const resp = await fetch('https://api.github.com/repos/' + args.repo, {credentials: 'include'});
if (!resp.ok) return {error: 'HTTP ' + resp.status, hint: resp.status === 404 ? 'Repo not found: ' + args.repo : 'API error'};
const d = await resp.json();
return {
full_name: d.full_name, description: d.description, language: d.language,
url: d.html_url || ('https://github.com/' + d.full_name),
stars: d.stargazers_count, forks: d.forks_count, open_issues: d.open_issues_count,
created_at: d.created_at, updated_at: d.updated_at, default_branch: d.default_branch,
topics: d.topics, license: d.license?.spdx_id
};
};
return run(params || {});
}
github_star_repo()
Star the current repository
Parameters
No parameters
JavaScript Handler
(params) => {
const starButton = document.querySelector('button[data-ga-click*="star"]');
if (starButton && !starButton.textContent.includes('Unstar')) {
starButton.click();
return { success: true, message: 'Starred the repository' };
}
return { success: false, message: 'Star button not found or already starred' };
}
🔌 Chrome MCP Server Extension
Use these tools with Claude, ChatGPT, and other AI assistants.
How to Use WebMCP
WebMCP tools are designed for browser extensions or automation frameworks. The browser extension matches the current URL against the pattern and executes the JavaScript handler when the tool is invoked.
API Endpoint:
GET /api/webmcp/match?url=https://www.github.com/...