| 123456789101112131415161718192021222324252627282930313233 |
- """
- 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)
|