Sponsored by Deepsite.site

Aspire.MCP.Sample

创建者
elbrunoa year ago
Sample MCP Server and MCP client with Aspire
内容

Aspire.MCP.Sample

Sample MCP Server and MCP client using Aspire.

Overview

This sample demonstrates a Model Context Protocol (MCP) Server and client setup using Aspire. It showcases how to establish and manage MCP communication, using C# in a structured Aspire environment.

Quick Demo

Check out this 5-minute video overview to see the project in action.

5-Minute Overview of the Project

Check out this 5-minute video overview to see how to deploy the solution to Azure, and how to consume the deployed MCP Server in Azure from Visual Studio Code.

5-Minute Overview on how to deploy the solution to Azure

Features

  • Aspire Integration: Uses Aspire for containerized orchestration and service management.
  • MCP Server: Implements an MCP server to manage client communication.
  • MCP Client: Sample Blazor Chat client demonstrating how to connect and communicate with the MCP server.
  • Model Selection: The Chat Client can use LLMs from Azure AI Foundry, Ollama or GitHub models. The selected model must support function calling to be able to call the MCP server functions.
  • Function Calling: Demonstrates how to call functions from the MCP server using the selected model.
  • Tool Result: Displays the result of the function call in the chat interface.
  • Azure Deployment: The project can be easily deployed to Azure using azd commands.

Getting Started

Prerequisites

  • .NET SDK 9.0 or later
  • Visual Studio 2022 or Visual Studio code
  • LLM or SLM that supports function calling.
    • Azure AI Foundry to run models in the cloud. IE: gpt-4o-mini
    • GitHub Models to run models in the cloud. IE: gpt-4o-mini
    • Ollama for running local models. Suggested: phi4-mini, llama3.2 or Qwq

Run locally

  1. Clone the repository:

  2. Navigate to the Aspire project directory:

    cd .\src\McpSample.AppHost\
    
  3. Run the project:

    dotnet run
    
  4. In the Aspire Dashboard, navigate to the Blazor Chat client project.

    Aspire Dashboard

  5. In the Chat Settings page, define the model to be used. You choose to use models in Azure AI Foundry (suggested gpt-4o-mini), GitHub Models or locally with ollama (suggested llama3.2)

    Chat Settings

  6. Now you can chat with the model. Everytime that one of the functions of the MCP server is called, the Tool Result section will be displayed in the chat.

    Chat Demo

Architecture Diagram

Architecture Diagram

GitHub Codespaces

(WIP)

  • Codespaces configuration will be added soon.

Deployment

Once you've opened the project in Codespaces, or locally, you can deploy it to Azure.

From a Terminal window, open the folder with the clone of this repo and run the following commands.

  1. Login to Azure:

    azd auth login
    
  2. Provision and deploy all the resources:

    azd up
    

    It will prompt you to provide an azd environment name (like "aspiremcp"), select a subscription from your Azure account, and select a location.

  3. When azd has finished deploying, you'll see the list of resources created in Azure and a set of URIs in the command output.

  4. Visit the blazorchat URI, and you should see the MCP Chat App! 🎉

Note: The deploy files are located in the ./src/McpSample.AppHost/infra/ folder. They are generated by the Aspire AppHost project.

Contributing

Contributions are welcome! Feel free to submit issues and pull requests.

License

This project is licensed under the MIT License.

推荐的 MCP Server
TraeBuild with Free GPT-4.1 & Claude 3.7. Fully MCP-Ready.
MCP AdvisorMCP Advisor & Installation - Use the right MCP server for your needs
Jina AI MCP ToolsA Model Context Protocol (MCP) server that integrates with Jina AI Search Foundation APIs.
Zhipu Web SearchZhipu Web Search MCP Server is a search engine specifically designed for large models. It integrates four search engines, allowing users to flexibly compare and switch between them. Building upon the web crawling and ranking capabilities of traditional search engines, it enhances intent recognition capabilities, returning results more suitable for large model processing (such as webpage titles, URLs, summaries, site names, site icons, etc.). This helps AI applications achieve "dynamic knowledge acquisition" and "precise scenario adaptation" capabilities.
Tavily Mcp
WindsurfThe new purpose-built IDE to harness magic
Visual Studio Code - Open Source ("Code - OSS")Visual Studio Code
DeepChatYour AI Partner on Desktop
Amap Maps高德地图官方 MCP Server
BlenderBlenderMCP connects Blender to Claude AI through the Model Context Protocol (MCP), allowing Claude to directly interact with and control Blender. This integration enables prompt assisted 3D modeling, scene creation, and manipulation.
Y GuiA web-based graphical interface for AI chat interactions with support for multiple AI models and MCP (Model Context Protocol) servers.
Serper MCP ServerA Serper MCP Server
Howtocook Mcp基于Anduin2017 / HowToCook (程序员在家做饭指南)的mcp server,帮你推荐菜谱、规划膳食,解决“今天吃什么“的世纪难题; Based on Anduin2017/HowToCook (Programmer's Guide to Cooking at Home), MCP Server helps you recommend recipes, plan meals, and solve the century old problem of "what to eat today"
AiimagemultistyleA Model Context Protocol (MCP) server for image generation and manipulation using fal.ai's Stable Diffusion model.
MiniMax MCPOfficial MiniMax Model Context Protocol (MCP) server that enables interaction with powerful Text to Speech, image generation and video generation APIs.
EdgeOne Pages MCPAn MCP service designed for deploying HTML content to EdgeOne Pages and obtaining an accessible public URL.
RedisA Model Context Protocol server that provides access to Redis databases. This server enables LLMs to interact with Redis key-value stores through a set of standardized tools.
Baidu Map百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
ChatWiseThe second fastest AI chatbot™
CursorThe AI Code Editor
Playwright McpPlaywright MCP server