{"_id":"@aigne/example-mcp-server-github-integrator","_rev":"2-c65d0e52ae2b2910a4ce4aa73520d62f","name":"@aigne/example-mcp-server-github-integrator","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@aigne/example-mcp-server-github-integrator","version":"1.0.0","author":{"name":"Arcblock","email":"blocklet@arcblock.io"},"license":"ISC","_id":"@aigne/example-mcp-server-github-integrator@1.0.0","maintainers":[{"name":"li-yechao","email":"liyechao@yechao.xyz"},{"name":"wangshijun","email":"shijun@arcblock.io"}],"homepage":"https://github.com/AIGNE-io/aigne-framework/tree/main/examples/mcp-server-github-integrator","bugs":{"url":"https://github.com/AIGNE-io/aigne-framework/issues"},"bin":{"example-mcp-server-github-integrator":"index.ts"},"dist":{"shasum":"c105f6d754bd94af6d2637bb267d845cf0008af4","tarball":"https://registry.npmjs.org/@aigne/example-mcp-server-github-integrator/-/example-mcp-server-github-integrator-1.0.0.tgz","fileCount":5,"integrity":"sha512-TlWCQRuFYqIR/Vou37aDmOoRrDvvJKhkKPpL2LzzLpe6n0C5XH46CJn1xiCawUcy5XFRCQ99ZvjzwtAYhnzorg==","signatures":[{"sig":"MEQCIFRSgiThW5TlrHarM/A/+RovFpfOxgPSluZNRvOJft7EAiByBPd1rHgyju3J6n5nE90PM0TcSGc5x2PwHvKKb985OQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10025},"_from":"file:aigne-example-mcp-server-github-integrator-1.0.0.tgz","scripts":{"lint":"tsc --noEmit","start":"npx -y bun run index.ts"},"_npmUser":{"name":"li-yechao","email":"liyechao@yechao.xyz"},"_resolved":"/tmp/58e7be30aa1d8ba0c05d1826c27c44cd/aigne-example-mcp-server-github-integrator-1.0.0.tgz","_integrity":"sha512-TlWCQRuFYqIR/Vou37aDmOoRrDvvJKhkKPpL2LzzLpe6n0C5XH46CJn1xiCawUcy5XFRCQ99ZvjzwtAYhnzorg==","repository":{"url":"git+https://github.com/AIGNE-io/aigne-framework.git","type":"git"},"_npmVersion":"10.8.2","description":"A demonstration of using AIGNE Framework and GitHub MCP Server to interact with GitHub repositories","directories":{},"_nodeVersion":"20.19.0","dependencies":{"zod":"^3.24.2","openai":"^4.89.0","@aigne/core":"^1.3.0"},"_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/example-mcp-server-github-integrator_1.0.0_1742824206677_0.8307382114044628","host":"s3://npm-registry-packages-npm-production"}}},"time":{"created":"2025-03-24T13:50:06.598Z","modified":"2026-01-21T06:21:16.148Z","1.0.0":"2025-03-24T13:50:06.842Z"},"bugs":{"url":"https://github.com/AIGNE-io/aigne-framework/issues"},"author":{"name":"Arcblock","email":"blocklet@arcblock.io"},"license":"ISC","homepage":"https://github.com/AIGNE-io/aigne-framework/tree/main/examples/mcp-server-github-integrator","repository":{"url":"git+https://github.com/AIGNE-io/aigne-framework.git","type":"git"},"description":"A demonstration of using AIGNE Framework and GitHub MCP Server to interact with GitHub repositories","maintainers":[{"email":"liyechao@yechao.xyz","name":"li-yechao"},{"email":"shijun@arcblock.io","name":"wangshijun"},{"email":"rob@arcblock.io","name":"mave99a"}],"readme":"# GitHub MCP Server Integration\n\nThis is a demonstration of using [AIGNE Framework](https://github.com/AIGNE-io/aigne-framework) and [GitHub MCP Server](https://github.com/modelcontextprotocol/servers/tree/main/src/github) to interact with GitHub repositories.\n\n```mermaid\nflowchart LR\n\nin(In)\nout(Out)\nagent(AI Agent)\ngithub(GitHub MCP Agent)\nsearchRepos(Search Repositories)\ngetContents(Get Contents)\ncreateFile(Create/Update File)\nissue(Issues & PRs)\n\nin --> agent <--> github\n\nsubgraph MCP Agent\n  github <--> searchRepos\n  github <--> getContents\n  github <--> createFile\n  github <--> issue\nend\n\nagent --> out\n\nclassDef inputOutput fill:#f9f0ed,stroke:#debbae,stroke-width:2px,color:#b35b39,font-weight:bolder;\nclassDef processing fill:#F0F4EB,stroke:#C2D7A7,stroke-width:2px,color:#6B8F3C,font-weight:bolder;\n\nclass in inputOutput\nclass out inputOutput\nclass agent processing\nclass github processing\nclass searchRepos processing\nclass getContents processing\nclass createFile processing\nclass issue processing\n```\n\nFollowing is a sequence diagram of the workflow to search for repositories and access contents:\n\n```mermaid\nsequenceDiagram\nparticipant User\nparticipant AI as AI Agent\nparticipant G as GitHub MCP Agent\nparticipant SR as Search Repositories\nparticipant GC as Get Contents\n\nUser ->> AI: Search for repositories related to 'modelcontextprotocol'\nAI ->> G: Use search_repositories function\nG ->> SR: Execute search with query='modelcontextprotocol'\nSR ->> G: Return repository list results\nG ->> AI: Formatted repository information\nAI ->> User: Found these repositories: modelcontextprotocol/servers, etc.\nUser ->> AI: Get README from the servers repo\nAI ->> G: Use get_file_contents function\nG ->> GC: Access README.md in modelcontextprotocol/servers\nGC ->> G: Return file content\nG ->> AI: Formatted file content\nAI ->> User: Here's the README content: ...\n```\n\n## Prerequisites\n\n- [Node.js](https://nodejs.org) and npm installed on your machine\n- [OpenAI API key](https://platform.openai.com/api-keys) used to interact with OpenAI API\n- [GitHub Personal Access Token](https://github.com/settings/tokens) with appropriate permissions\n- [Pnpm](https://pnpm.io) [Optional] if you want to run the example from source code\n\n## Try without Installation\n\n```bash\nexport OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Setup your OpenAI API key\nexport GITHUB_PERSONAL_ACCESS_TOKEN=YOUR_GITHUB_TOKEN # Setup your GitHub token\n\nnpx -y @aigne/example-mcp-server-github # Run the example\n```\n\n## Installation\n\n### Clone the Repository\n\n```bash\ngit clone https://github.com/AIGNE-io/aigne-framework\n```\n\n### Install Dependencies\n\n```bash\ncd aigne-framework/examples/mcp-server-github-integrator\n\npnpm install\n```\n\n### Setup Environment Variables\n\nSetup your API keys in the `.env.local` file:\n\n```bash\nOPENAI_API_KEY=\"\" # Your OpenAI API key\nGITHUB_PERSONAL_ACCESS_TOKEN=\"\" # Your GitHub Personal Access Token\n```\n\n### Run the Example\n\n```bash\npnpm start # Interactive chat interface\n# or\npnpm example # Run predefined examples\n```\n\n## Example\n\nThe following example demonstrates how to use the GitHub MCP server to search for repositories:\n\n```typescript\nimport {\n  AIAgent,\n  OpenAIChatModel,\n  ExecutionEngine,\n  MCPAgent,\n} from \"@aigne/core\";\n\n// Load environment variables\nconst { OPENAI_API_KEY, GITHUB_PERSONAL_ACCESS_TOKEN } = process.env;\n\n// Initialize OpenAI model\nconst model = new OpenAIChatModel({\n  apiKey: OPENAI_API_KEY,\n});\n\n// Initialize GitHub MCP agent\nconst githubMCPAgent = await MCPAgent.from({\n  command: \"npx\",\n  args: [\"-y\", \"@modelcontextprotocol/server-github\"],\n  env: {\n    GITHUB_PERSONAL_ACCESS_TOKEN,\n  },\n});\n\n// Create execution engine\nconst engine = new ExecutionEngine({\n  model,\n  tools: [githubMCPAgent],\n});\n\n// Create AI agent with GitHub-specific instructions\nconst agent = AIAgent.from({\n  instructions: `\\\n## GitHub Interaction Assistant\nYou are an assistant that helps users interact with GitHub repositories.\nYou can perform various GitHub operations like:\n1. Searching repositories\n2. Getting file contents\n3. Creating or updating files\n4. Creating issues and pull requests\n5. And many more GitHub operations\n\nAlways provide clear, concise responses with relevant information from GitHub.\n`,\n});\n\n// Example: Search for repositories\nconst result = await engine.call(\n  agent,\n  \"Search for repositories related to 'modelcontextprotocol'\",\n);\n\nconsole.log(result.text);\n// Output:\n// I found several repositories related to 'modelcontextprotocol':\n//\n// 1. **modelcontextprotocol/servers** - MCP servers for various APIs and services\n// 2. **modelcontextprotocol/modelcontextprotocol** - The main ModelContextProtocol repository\n// ...\n\n// Shutdown the engine when done\nawait engine.shutdown();\n```\n\n## Available GitHub Operations\n\nThe GitHub MCP server provides a wide range of operations including:\n\n1. **Repository Operations**:\n\n   - Search repositories\n   - Create repositories\n   - Get repository information\n\n2. **File Operations**:\n\n   - Get file contents\n   - Create or update files\n   - Push multiple files in a single commit\n\n3. **Issue and PR Operations**:\n\n   - Create issues\n   - Create pull requests\n   - Add comments\n   - Merge pull requests\n\n4. **Search Operations**:\n\n   - Search code\n   - Search issues\n   - Search users\n\n5. **Commit Operations**:\n   - List commits\n   - Get commit details\n\n## License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}