用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/ag2ai/resource-hub --skill use-github-tools命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
REST and WebSocket endpoint patterns, error handling, and Pydantic schema conventions for the backend
Architecture, directory layout, communication protocol, and conventions for the full-stack multi-agent application
Step-by-step guide to add a new REST or WebSocket endpoint to the backend
基于 SOC 职业分类
正在显示 SKILL.md
| name | use-github-tools |
| description | Connect AG2 agents to GitHub via MCP for repository, issue, and code search operations |
| version | 1.0.0 |
| authors | ["ag2ai"] |
| tags | ["github","mcp","tools","ag2"] |
The github-mcp server exposes GitHub operations as MCP tools that AG2 agents can call:
list_repos(owner) — List public repositories for a GitHub user or organization.get_issue(owner, repo, number) — Get full details of an issue or pull request.search_code(query, language) — Search code across all of GitHub.The server communicates over stdio using the Model Context Protocol and requires a GITHUB_TOKEN environment variable for authenticated API access.
repo, read:org).uv available on PATH.pip install "mcp[cli]>=1.0" "httpx>=0.27"
The server is configured in artifact.json with this MCP config block:
{
"command": "uv",
"args": ["run", "--directory", "${toolDir}", "src/server.py"],
"env": {"GITHUB_TOKEN": "${GITHUB_TOKEN}"}
}
You can also run the server directly for testing:
export GITHUB_TOKEN="ghp_your_token_here"
uv run src/server.py
import asyncio
import os
import autogen
from autogen.tools.experimental import MCPToolAdapter
# Ensure the token is set
os.environ["GITHUB_TOKEN"] = "ghp_your_token_here"
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
async def main():
# Create the MCP adapter pointing to the server
mcp_adapter = MCPToolAdapter(
command="uv",
args=["run", "--directory", "tools/github-mcp", "src/server.py"],
env={"GITHUB_TOKEN": os.environ["GITHUB_TOKEN"]},
)
# Connect and discover tools
async with mcp_adapter:
tools = await mcp_adapter.discover_tools()
assistant = autogen.AssistantAgent(
name="github_assistant",
system_message=(
"You are a helpful assistant with access to GitHub tools. "
"Use them to look up repositories, issues, and search code "
"when asked."
),
llm_config={"config_list": config_list},
)
user_proxy = autogen.UserProxyAgent(
name="user",
human_input_mode="NEVER",
code_execution_config=False,
)
# Register all discovered MCP tools
for tool in tools:
tool.register(caller=assistant, executor=user_proxy)
user_proxy.initiate_chat(
assistant,
message=,
)
asyncio.run(main())
If you want to call the GitHub API directly without the MCP server, you can import the underlying functions and register them as standard AG2 tools:
import asyncio
import autogen
from autogen import register_function
# Import the server module to access the async tool functions
from tools.github_mcp.src.server import get_issue, list_repos, search_code
config_list = [{"model": "gpt-4o", "api_key": "YOUR_KEY"}]
assistant = autogen.ConversableAgent(
name="assistant",
llm_config={"config_list": config_list},
)
user_proxy = autogen.ConversableAgent(
name="user",
human_input_mode="NEVER",
code_execution_config=False,
)
register_function(
list_repos,
caller=assistant,
executor=user_proxy,
name="list_repos",
description="List GitHub repositories for a user or org",
)
register_function(
get_issue,
caller=assistant,
executor=user_proxy,
name="get_issue",
description="Get details of a GitHub issue",
)
register_function(
search_code,
caller=assistant,
executor=user_proxy,
name="search_code",
description="Search code across GitHub repositories",
)
list_repos| Parameter | Type | Description |
|---|---|---|
owner | str | GitHub username or organization name |
Returns up to 30 public repositories sorted by most recently updated, including name, description, star count, and primary language.
get_issue| Parameter | Type | Description |
|---|---|---|
owner | str | Repository owner (user or org) |
repo | str | Repository name |
number | int | Issue or pull request number |
Returns title, state, author, creation date, labels, and body text. Works for both issues and pull requests.
search_code| Parameter | Type | Description |
|---|---|---|
query | str | Search query (GitHub code search syntax) |
language | str or None | Optional language filter (e.g., "python") |
Returns up to 15 results with repository name, file path, and URL. Uses the GitHub code search API.
The server reads GITHUB_TOKEN from the environment. Without a token:
repo scope.Create a fine-grained token at https://github.com/settings/tokens with the permissions you need.