安装命令
openclawmp install plugin/@u-a553402ca21449db9813/github-api标签
README
GitHub API Plugin
为 OpenClaw Agent 提供 GitHub REST API 集成能力。
功能
- 🔍 搜索仓库(
searchRepos) - 📋 查询 Issues(
getIssues) - ➕ 创建 Issue(
createIssue) - 🔀 查询 Pull Requests(
getPullRequests) - ✅ 合并 PR(
mergePullRequest) - 📜 获取提交记录(
getCommits)
安装
# 1. 生成 GitHub Personal Access Token
# 去 https://github.com/settings/tokens 生成,勾选 repo 权限
# 2. 设置环境变量
export GITHUB_TOKEN=ghp_your_token_here
# 3. 安装插件
openclawmp install plugin/@your-username/github-api
配置 Agent
{
"plugins": [
{
"id": "github-api",
"config": {
"token": "${GITHUB_TOKEN}",
"apiUrl": "https://api.github.com"
}
}
]
}
工具列表
1. searchRepos(query, sort='stars', order='desc', perPage=30)
搜索 GitHub 仓库。
参数:
query(string): 搜索关键词,如"openclaw language:typescript"sort(string): 排序方式:stars、forks、updatedorder(string): 顺序:desc或ascperPage(number): 每页数量(1-100)
返回:
{
"total_count": 1234,
"items": [
{
"full_name": "owner/repo",
"description": "...",
"stars": 1000,
"language": "TypeScript",
"url": "https://github.com/owner/repo"
}
]
}
示例:
调用: searchRepos("openclaw agent", "stars", "desc", 5)
2. getIssues(owner, repo, state='open', labels=[], perPage=30)
获取仓库的 Issues 列表。
参数:
owner(string): 仓库所有者repo(string): 仓库名state(string):open、closed或alllabels(string[]): 标签过滤perPage(number): 每页数量
返回:
[
{
"number": 123,
"title": "Bug: something broken",
"state": "open",
"user": { "login": "author" },
"created_at": "2025-03-01T10:00:00Z",
"html_url": "https://github.com/owner/repo/issues/123"
}
]
3. createIssue(owner, repo, title, body='', labels=[])
创建新 Issue。
参数:
owner(string)repo(string)title(string)body(string): 内容(Markdown)labels(string[]): 标签列表
返回:
{
"number": 456,
"html_url": "https://github.com/owner/repo/issues/456",
"title": "..."
}
4. getPullRequests(owner, repo, state='open', head='', base='', perPage=30)
获取 Pull Requests。
参数:
owner(string)repo(string)state(string):open、closed、allhead(string): 头分支(如"user:branch")base(string): 基础分支(如"main")perPage(number)
返回: PR 对象数组(含 number、title、user、state、html_url)
5. mergePullRequest(owner, repo, pullNumber, mergeMethod='merge')
合并 PR。
参数:
owner(string)repo(string)pullNumber(number)mergeMethod(string):merge(合并提交)、squash(压缩)、rebase(变基)
返回:
{
"sha": "abc123...",
"merged": true,
"message": "Pull Request successfully merged"
}
6. getCommits(owner, repo, ref='main', perPage=30)
获取提交记录。
参数:
owner(string)repo(string)ref(string): 分支名或 commit SHAperPage(number)
返回:
[
{
"sha": "abc123...",
"commit": {
"author": { "name": "Alice", "date": "..." },
"message": "Fix bug"
},
"author": { "login": "alice" },
"html_url": "https://github.com/owner/repo/commit/abc123"
}
]
使用示例
场景 1:搜索热门的 OpenClaw 插件
使用 github-api 插件:
搜索 stars > 100 的 TypeScript 写的 OpenClaw 插件
call searchRepos("openclaw plugin language:typescript stars:>100", "stars", "desc", 10)
场景 2:自动回复 Issue
读取最新 Issue
call getIssues("myorg/myrepo", "open", [], 5)
如果 Issue 标题包含 "bug",自动回复:
call createIssue("myorg/myrepo", "Acknowledged: {{title}}", "We'll look into this.", ["acknowledged"])
场景 3:每周自动合并 PR
获取所有 PR
call getPullRequests("myorg/myrepo", "open", base="main")
全部合并(谨慎使用)
for pr in prs:
mergePullRequest(owner, repo, pr.number, "squash")
错误处理
常见错误码:
401: Token 无效或过期403: 权限不足(检查 scopes)404: 仓库/Issue 不存在422: 参数错误(如合并冲突)
插件会抛出异常,Agent 可捕获并重试或通知用户。
安全建议
- 🔐 Token 存储为环境变量,不要硬编码
- 🔐 使用最小权限 token(如仅
public_repo) - 🧹 定期清理旧 token
License
MIT © 2026
相关推荐
yahoo-finance-pluginv1.0.0
接入 Yahoo Finance API 的金融数据插件
Brave搜索v1.0.1
通过Brave Search API进行网络搜索和内容提取,用于搜索文档、事实或任何网络内容,轻量级且无需浏览器。
精英长期记忆v1.2.3
为 Cursor、Claude、ChatGPT 和 Copilot 提供的终极 AI 代理记忆系统。采用 WAL 协议 + 向量搜索 + git-notes + 云备份。再也不丢失上下文。Vibe-coding 就绪。
飞书工具库v1.0.1
飞书开放平台工具库,支持文档读写、消息发送、群聊管理、文件上传等功能。同时支持Lark国际版和飞书中国版。已移除硬编码密钥,使用环境变量配置。