Content
# MCP In Action







## Introduction
MCP In Action is a practical project designed to help developers quickly master the development and application of the Model Context Protocol (MCP). This project demonstrates how to build MCP-based applications through practical examples, enabling large language models to interact with external tools and data sources, thereby enhancing the model's capabilities.
## Documentation
1. [MCP实战入门:让AI模型获取实时天气信息](https://mp.weixin.qq.com/s/cJhHf7caaezehEff2GSY_A)
2. [MCP实战进阶:集成DeepSeek模型与MCP的天气信息助手](https://mp.weixin.qq.com/s/1YIYRVw8yF1zeeLtmnhtYQ)
3. [MCP实战高阶:借助LangChain快速打造MCP天气助手](https://mp.weixin.qq.com/s/Qq3C85Bi3NHDQ9MnnBZvZQ)
4. [RAG不好用?试试MCP这个“知识库优化大师”](https://mp.weixin.qq.com/s/SOVXbU8Lw131EFCMmMlpmA)
### Related Videos
- [极客时间《MCP实战》](
https://u.geekbang.org/subject/intro/1010607)
## Project Architecture
This repository contains the following main projects:
### Project 1: [mcp-opensource](https://github.com/FlyAIBox/mcp-in-action/tree/main/mcp-opensource)
This project showcases MCP's open-source tools, platforms, etc.
### Project 2: [mcp-demo](https://github.com/FlyAIBox/mcp-in-action/tree/main/mcp-demo)
This project demonstrates the basic application of MCP. By building a client-server architecture, it allows AI models to access real-time weather information.
#### Core Features
- **MCP Server Development**: Build a server that complies with MCP specifications from scratch
- **MCP Server Debugging**: Provide debugging methods and best practices
- **MCP Client Development**: Implement a client that communicates with the server
- **DeepSeek Integration**: Integrate the DeepSeek large model with the MCP client
- **LangChain Integration**: Use the MCP server in the LangChain framework
#### MCP Server Advanced
- **Desktop Loading**: Integrate the MCP service into a desktop application
- **Prompt Management**: Optimize and manage model prompts
- **Resource Handling**: External resource invocation and management
- **Lifecycle Management**: Control the complete lifecycle of the MCP service
- **Cloud Deployment**: Deploy the MCP service to the cloud (阿里云/mcp.so)
### Project 3: [mcp-rag](https://github.com/FlyAIBox/mcp-in-action/tree/main/mcp-rag)
This project focuses on combining MCP with Retrieval-Augmented Generation (RAG) technology, demonstrating how to achieve more advanced knowledge retrieval and information integration capabilities through MCP.
#### Project Goal
This project aims to **build an enterprise RAG system based on MCP**, achieving the following specific goals:
**Goal**
- Build a knowledge base service and client that supports the MCP protocol
- Implement intelligent document segmentation and automatic FAQ extraction functions
- Support complex problem decomposition and mixed retrieval strategies
#### Project System Design and Implementation
> The system design of this project is based on [alibabacloud-tablestore-mcp-server](https://github.com/aliyun/alibabacloud-tablestore-mcp-server). Since the `alibabacloud-tablestore-mcp-server` project uses Tablestore for storage and Java for the MCP Server, it is not convenient for later expansion and iteration.
>
> This project is transformed to use Milvus for storage and Python for the MCP Server and MCP Client. The code is completely rewritten (with a lot of help from cursor).
>
> The following design and processes are from `alibabacloud-tablestore-mcp-server`. Thanks to @xjtushilei for open-sourcing `alibabacloud-tablestore-mcp-server`.
The MCP-based RAG system we built mainly includes three core parts:
1. **Knowledge Base Service (MCP Server)**: A backend service implemented based on the Milvus vector database, responsible for document storage and retrieval
2. **Client Tool (MCP Client)**: A client that communicates with the MCP Server, implementing knowledge base construction and retrieval functions
3. **Large Model Integration**: Implements core functions such as document segmentation, FAQ extraction, problem decomposition, and answer generation through LLM

It is mainly divided into two parts: knowledge base construction and retrieval.
1. **Knowledge Base Construction**
1. **Text Segmentation:** Segment the text, ensuring that the segmented content maintains text integrity and semantic integrity.
2. **Extract FAQ:** Extract FAQs based on the text content as a supplement to knowledge base retrieval to improve retrieval effectiveness.
3. **Import Knowledge Base:** Import the text and FAQs into the knowledge base and import the vectors after embedding.
2. **Knowledge Retrieval (RAG)**
1. **Problem Decomposition:** Decompose and rewrite the input question into more atomic sub-problems.
2. **Retrieval:** Retrieve relevant texts and FAQs for each sub-problem separately. Vector retrieval is used for texts, and full-text and vector mixed retrieval is used for FAQs.
3. **Knowledge Base Content Screening:** Screen the retrieved content and retain the content most relevant to the question for reference answers.
Compared to traditional Naive RAG, some common optimizations have been made in knowledge base construction and retrieval, including Chunk segmentation optimization, FAQ extraction, Query Rewrite, mixed retrieval, etc.
##### Process

The overall architecture of this Agent is divided into three parts:
1. **Knowledge Base:** Internally includes Knowledge Store and FAQ Store, which store text content and FAQ content respectively, and support mixed vector and full-text retrieval.
2. **MCP Server:** Provides read and write operations to the Knowledge Store and FAQ Store, providing a total of 4 Tools.
3. **Function Implementation Part:** The import, retrieval, and question answering functions of the knowledge base are completely implemented through Prompt + LLM.
#### Project Structure
The project structure is divided into two parts:
1. **`milvus-mcp-client`:** The Client side implemented in Python, which realizes the interaction with the large model, obtains Tools through the MCP Client, and calls basic capabilities such as Tools according to the feedback of the large model. The three main functions of knowledge base construction, retrieval, and question answering are realized through Prompt.
2. **`milvus-mcp-server`:** The Server side implemented in Python, a service based on the MCP framework, provides an interface to connect to the Milvus vector database, and supports knowledge base storage and retrieval functions.
## Contribution Guide
You are welcome to contribute to the project in the following ways:
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Commit your changes (`git commit -m 'Add some amazing feature'`)
4. Push to the branch (`git push origin feature/amazing-feature`)
5. Create a Pull Request
Contributions are what make the open-source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated. If you have any suggestions or feature requests, please open an issue first to discuss what you would like to change.
<a href='https://github.com/repo-reviews/repo-reviews.github.io/blob/main/create.md' target="_blank"><img alt='Github' src='https://img.shields.io/badge/review_me-100000?style=flat&logo=Github&logoColor=white&labelColor=888888&color=555555'/></a>
## License
This project is licensed under the terms of the Apache-2.0 license. See the [LICENSE](LICENSE) file for details.
This project uses the [Apache License](LICENSE).
## Contact Information
- Project Maintainer: [FlyAIBox](https://github.com/FlyAIBox)
- Issue Feedback: Please use [GitHub Issues](https://github.com/FlyAIBox/mcp-in-action/issues)
---
**Model Context Protocol** - Give AI models the ability to interact with the world
# ⭐️⭐️⭐️⭐️⭐️
<a href="https://star-history.com/#FlyAIBox/mcp-in-action&Date">
<picture>
<source media="(prefers-color-scheme: dark)" srcset="https://api.star-history.com/svg?repos=FlyAIBox/mcp-in-action&type=Date&theme=dark" />
<source media="(prefers-color-scheme: light)" srcset="https://api.star-history.com/svg?repos=FlyAIBox/mcp-in-action&type=Date" />
<img alt="Star History Chart" src="https://api.star-history.com/svg?repos=FlyAIBox/mcp-in-action&type=Date" />
</picture>
</a>
Connection Info
You Might Also Like
markitdown
MarkItDown-MCP is a lightweight server for converting URIs to Markdown.
servers
Model Context Protocol Servers
Time
A Model Context Protocol server for time and timezone conversions.
Filesystem
Node.js MCP Server for filesystem operations with dynamic access control.
Sequential Thinking
A structured MCP server for dynamic problem-solving and reflective thinking.
git
A Model Context Protocol server for Git automation and interaction.