AA

azurecosmosdb/azurecosmosdb-mcp-chat-app

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

9 stars 7 forks 质量 45 趋势 17

A full-stack chat application powered by Azure Cosmos DB acting as a Model Context Provider (MCP) client.

概览

This repository contains a complete example of a chat application powered by a server written in Python. It demonstrates how to: - Build and run an that interacts with - Use and as MCP clients to build interactive chat UIs - Host both server and client or deploy them to The MCP server exposes tools that let LLM agents insert and query data from Azure Cosmos DB. It uses for authentication and assumes the use of for embeddings and LLM responses (you can modify it to use other providers as needed). https://github.com/user-attachments/assets/e3857c4b-7961-4eaf-b211-7ceb2d4006b6 The MCP server exposes an SSE (Server-Sent Events) endpoint that the client connects to. You can run it locally with Docker or deploy it to Azure using Azure Container Apps or Functions. Create a .env file in the root of your server folder with: Once running, the MCP Server is available at http://localhost:5000/ You can deploy via Azure Container Apps using the VS Code extension. Before that:

README

以下为原文 README 节选,完整内容请查看原文。

🧠 Python MCP Server & Client Example with Azure Cosmos DB

Overview

This repository contains a complete example of a chat application powered by a Model Context Protocol (MCP) server written in Python. It demonstrates how to:

  • Build and run an MCP Server that interacts with Azure Cosmos DB for NoSQL
  • Use chainlit and gradio as MCP clients to build interactive chat UIs
  • Host both server and client locally or deploy them to Azure

The MCP server exposes tools that let LLM agents insert and query data from Azure Cosmos DB. It uses Managed Identity for authentication and assumes the use of Azure OpenAI for embeddings and LLM responses (you can modify it to use other providers as needed).

In action with VS Code

https://github.com/user-attachments/assets/e3857c4b-7961-4eaf-b211-7ceb2d4006b6


🛠️ Project Structure

azure_containers/cosmosdb/   # MCP Server using Azure Container Apps
azure_functions/cosmosdb/    # MCP Server using Azure Functions
mcp_client/                  # MCP Client using Chainlit or Gradio

🚀 Deploying the MCP Server

The MCP server exposes an SSE (Server-Sent Events) endpoint that the client connects to. You can run it locally with Docker or deploy it to Azure using Azure Container Apps or Functions.

1. Set up environment variables

Create a .env file in the root of your server folder with:

ACCOUNT_KEY=
ACCOUNT_ENDPOINT=

2. Local Deployment (with Docker)

Run the following commands:

docker-compose build
docker-compose up -d

Once running, the MCP Server is available at http://localhost:5000/

3. Azure Deployment (Container Apps)

You can deploy via Azure Container Apps using the VS Code extension. Before that:

  • Create an Azure Container App in your subscription.
  • Then deploy via VS Code.

Update your .env with the following GPT model details:

openai_key=
openai_endpoint=
openai_api_version=2025-01-01-preview
openai_embeddings_deployment="text-embedding-3-large-2"
openai_embeddings_model="text-embedding-3-large"

💬 Deploying the MCP Client

The MCP client is located in the mcp_client/ folder. It uses either chainlit or gradio to create a front-end chat UI connected to the MCP server.

1. Set up environment variables

Same .env as above:

CHAT_MODEL_NAME=
CHAT_MODEL_API_KEY=
CHAT_MODEL_BASE_URL=
CHAT_MODEL_API_VERSION=2025-01-01-preview

2. Local Deployment

Install dependencies:

pip install -r requirements.txt

Then run either interface:

Chainlit:

在 GitHub 查看完整 README

安装

This server does not publish a one-line install command.

Open the repository installation guide 新手?先看 mcpskill.org 教程 →