|
1 |
| -## Lesson in Progress |
| 1 | +# Lesson 11: Model Context Protocol (MCP) Integration |
2 | 2 |
|
3 |
| -This written lesson is in progress but a code sample has been included. |
| 3 | +## Learning Objectives |
| 4 | +- Understand what MCP is and its role in AI agent development |
| 5 | +- Set up and configure an MCP server for GitHub integration |
| 6 | +- Build a multi-agent system using MCP tools |
| 7 | +- Implement RAG (Retrieval Augmented Generation) with Azure Cognitive Search |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | +- Python 3.8+ |
| 11 | +- Node.js 14+ |
| 12 | +- Azure subscription |
| 13 | +- GitHub account |
| 14 | +- Basic understanding of Semantic Kernel |
| 15 | + |
| 16 | +## Setup Instructions |
| 17 | + |
| 18 | +1. **Environment Setup** |
| 19 | + ```bash |
| 20 | + python -m venv venv |
| 21 | + source venv/bin/activate # On Windows: venv\Scripts\activate |
| 22 | + pip install -r requirements.txt |
| 23 | + ``` |
| 24 | + |
| 25 | +2. **Configure Azure Services** |
| 26 | + - Create an Azure Cognitive Search resource |
| 27 | + - Set up Azure OpenAI service |
| 28 | + - Configure environment variables in `.env` |
| 29 | + |
| 30 | +3. **MCP Server Setup** |
| 31 | + ```bash |
| 32 | + npm install -g @modelcontextprotocol/server-github |
| 33 | + ``` |
| 34 | + |
| 35 | +## Project Structure |
| 36 | + |
| 37 | +``` |
| 38 | +11-mcp/ |
| 39 | +├── code_samples/ |
| 40 | +│ └── github-mcp/ |
| 41 | +│ ├── app.py # Main application |
| 42 | +│ ├── event-descriptions.md # Event data |
| 43 | +│ └── MCP_SETUP.md # Setup guide |
| 44 | +├── README.md |
| 45 | +└── requirements.txt |
| 46 | +``` |
| 47 | + |
| 48 | +## Core Components |
| 49 | + |
| 50 | +### 1. Multi-Agent System |
| 51 | +- GitHub Agent: Repository analysis |
| 52 | +- Hackathon Agent: Project recommendations |
| 53 | +- Events Agent: Tech event suggestions |
| 54 | + |
| 55 | +### 2. Azure Integration |
| 56 | +- Cognitive Search for event indexing |
| 57 | +- Azure OpenAI for agent intelligence |
| 58 | +- RAG pattern implementation |
| 59 | + |
| 60 | +### 3. MCP Tools |
| 61 | +- GitHub repository analysis |
| 62 | +- Code inspection |
| 63 | +- Metadata extraction |
| 64 | + |
| 65 | +## Code Walkthrough |
| 66 | + |
| 67 | +The sample demonstrates: |
| 68 | +1. MCP server integration |
| 69 | +2. Multi-agent orchestration |
| 70 | +3. Azure Cognitive Search integration |
| 71 | +4. RAG pattern implementation |
| 72 | + |
| 73 | +Key features: |
| 74 | +- Real-time GitHub repository analysis |
| 75 | +- Intelligent project recommendations |
| 76 | +- Event matching using Azure Search |
| 77 | +- Streaming responses with Chainlit |
| 78 | + |
| 79 | +## Running the Sample |
| 80 | + |
| 81 | +1. Start the MCP server: |
| 82 | + ```bash |
| 83 | + npx @modelcontextprotocol/server-github |
| 84 | + ``` |
| 85 | + |
| 86 | +2. Launch the application: |
| 87 | + ```bash |
| 88 | + chainlit run app.py -w |
| 89 | + ``` |
| 90 | + |
| 91 | +3. Test the integration: |
| 92 | + ``` |
| 93 | + Example query: "Analyze repositories for username: <github_username>" |
| 94 | + ``` |
| 95 | + |
| 96 | +## Troubleshooting |
| 97 | + |
| 98 | +Common issues and solutions: |
| 99 | +1. MCP Connection Issues |
| 100 | + - Verify server is running |
| 101 | + - Check port availability |
| 102 | + - Confirm GitHub tokens |
| 103 | + |
| 104 | +2. Azure Search Issues |
| 105 | + - Validate connection strings |
| 106 | + - Check index existence |
| 107 | + - Verify document upload |
| 108 | + |
| 109 | +## Next Steps |
| 110 | +- Explore additional MCP tools |
| 111 | +- Implement custom agents |
| 112 | +- Enhance RAG capabilities |
| 113 | +- Add more event sources |
| 114 | + |
| 115 | +## Resources |
| 116 | +- [MCP for Beginners](https://aka.ms/mcp-for-beginners) |
| 117 | +- [MCP Documentation](https://github.com/microsoft/semantic-kernel/tree/main/python/semantic-kernel/semantic_kernel/connectors/mcp) |
| 118 | +- [Azure Cognitive Search Docs](https://learn.microsoft.com/azure/search/) |
| 119 | +- [Semantic Kernel Guides](https://learn.microsoft.com/semantic-kernel/) |
0 commit comments