A simple web application that allows you to chat with Azure AI Foundry Agents that are connected to remote MCP (Model Context Protocol) servers.
- Remote MCP servers that are publicly accessible via HTTP/HTTPS
- No authentication required - servers that don't require API keys, tokens, or authentication
- Proper CORS configuration to allow browser connections from Azure App Service
Common examples that work:
- Public demo MCP servers
- Local MCP servers exposed via ngrok or similar tunneling services
- Custom MCP servers deployed without authentication requirements
📚 For more information about MCP servers and App Service samples, see: Integrate AI into your Azure App Service applications
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Web Interface │────│ FastAPI App │────│ Remote MCP │
│ (Single Page) │ │ + Azure AI │ │ Server │
│ │ │ Foundry │ │ (Public/No Auth)│
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌──────────────────┐
│ Azure AI │
│ Foundry + │
│ GPT-4o │
└──────────────────┘
- Python 3.11+
- Azure subscription (for AI features)
- Azure Developer CLI (azd)
-
Clone and setup:
git clone <your-repo-url> cd python-mcp-agent-chat python -m venv .venv .venv\Scripts\activate # Windows (.venv/bin/activate on Linux/Mac) pip install -r requirements.txt
-
Configure environment variables (optional - only needed for local development if you want to run the app locally): Create a
.env
file or set these environment variables:AZURE_AI_PROJECT_ENDPOINT=https://your-ai-project.westus.ai.azure.com/api/projects/your-project AZURE_AI_PROJECT_NAME=your-project-name MODEL_DEPLOYMENT=gpt-4o
These values are available in your Azure AI Foundry project after deployment
-
Set up Azure credentials:
az login
Ensure you're logged into the same Azure account that has access to your AI Foundry resources.
-
Run locally:
python main.py
Visit http://localhost:8000 to access the application.
💡 Recommended: Deploy to Azure first using azd up
below, then optionally set up local development afterward.
Login to the Azure Developer CLI (azd):
azd auth login
Deploy using Azure Developer CLI (azd):
azd up
This will:
- Deploy the FastAPI application to Azure App Service
- Set up Azure AI Foundry integration
- Configure managed identity for secure authentication
The deployed application will be accessible at the URL provided after deployment.
The application provides a simple interface to:
- Connect to MCP Servers: Enter the URL of a remote MCP server
- Chat with AI Agent: The AI agent can use tools from the connected MCP server
- Rich Responses: AI responses are formatted with markdown support and syntax highlighting
- Visit the application homepage
- Enter a remote MCP server URL (e.g.,
https://your-mcp-server.com/mcp
) - Start chatting with the AI agent
- The agent can use tools from the MCP server to help answer your questions