You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
762 B
Python
34 lines
762 B
Python
"""
|
|
GitHub MCP 服务示例
|
|
|
|
注意:需要设置环境变量
|
|
Windows: $env:GITHUB_PERSONAL_ACCESS_TOKEN="your_token_here"
|
|
Linux/macOS: export GITHUB_PERSONAL_ACCESS_TOKEN="your_token_here"
|
|
"""
|
|
|
|
from hello_agents.tools import MCPTool
|
|
|
|
# 创建 GitHub MCP 工具
|
|
github_tool = MCPTool(
|
|
server_command=["npx", "-y", "@modelcontextprotocol/server-github"]
|
|
)
|
|
|
|
# 1. 列出可用工具
|
|
print("📋 可用工具:")
|
|
result = github_tool.run({"action": "list_tools"})
|
|
print(result)
|
|
|
|
# 2. 搜索仓库
|
|
print("\n🔍 搜索仓库:")
|
|
result = github_tool.run({
|
|
"action": "call_tool",
|
|
"tool_name": "search_repositories",
|
|
"arguments": {
|
|
"query": "AI agents language:python",
|
|
"page": 1,
|
|
"perPage": 3
|
|
}
|
|
})
|
|
print(result)
|
|
|