|
1 | | -## General Guidance |
| 1 | +# MCP Agent LangChain.js Project Instructions |
2 | 2 |
|
| 3 | +## Architecture Overview |
| 4 | + |
| 5 | +This is a multi-component LangChain.js demo showcasing AI agents with Model Context Protocol (MCP) integration. The system demonstrates a burger ordering platform with three main service layers: |
| 6 | + |
| 7 | +- **Agent Layer**: AI chat interface (`agent-webapp` + `agent-api`) using LangChain.js agents with MCP tools |
| 8 | +- **Business Layer**: Burger ordering API (`burger-api`) and webapp (`burger-webapp`) |
| 9 | +- **MCP Layer**: Model Context Protocol server (`burger-mcp`) exposing burger API as LLM tools |
| 10 | + |
| 11 | +### Component Communication Flow |
| 12 | +``` |
| 13 | +agent-webapp → agent-api → burger-mcp → burger-api |
| 14 | +``` |
| 15 | + |
| 16 | +The agent uses LangChain.js with Azure OpenAI, connects to the MCP server via StreamableHTTPClientTransport, and the MCP server proxies requests to the burger API. |
| 17 | + |
| 18 | +## Key Architectural Patterns |
| 19 | + |
| 20 | +### Authentication & State Management |
| 21 | +- Azure Static Web Apps authentication provides `userId` context |
| 22 | +- Cosmos DB for chat history storage using `@langchain/azure-cosmosdb` |
| 23 | +- User context flows: SWA auth → agent-api → MCP tools (for user-specific operations) |
| 24 | + |
| 25 | +### TypeScript & Build Conventions |
| 26 | +- Shared XO linting config with project-specific overrides |
| 27 | +- NPM workspace-based dependency management |
| 28 | +- `.js` extensions required in imports for ESM compatibility |
| 29 | +- Keep the code simple and straighforward: avoid unnecessary complexity and ensure clarity in implementation. |
| 30 | +- Do not use comments except where absolutely necessary, code should be self-explanatory. |
| 31 | + |
| 32 | +### Infrastructure as Code |
| 33 | +- Bicep templates in `infra/` for Azure deployment |
| 34 | +- `azure.yaml` defines multi-service deployment strategy: |
| 35 | + - `burger-api`, `agent-api`: Azure Functions (Flex Consumption) |
| 36 | + - `burger-mcp`: Container Apps with Docker |
| 37 | + - `*-webapp`: Static Web Apps |
| 38 | +- Environment variables flow through Azure App Settings |
3 | 39 | - @azure Rule - Use Azure Best Practices: When generating code for Azure, running terminal commands for Azure, or performing operations related to Azure, invoke your `azure_development-get_best_practices` tool if available. |
0 commit comments