Content
# LLM Agent
High-performance LLM Agent system based on asyncio and MCP protocol, supporting multi-tool collaboration, RAG retrieval-augmented generation, and asynchronous task scheduling.
## Core Features
### 1. Agent Task Loop Scheduling Framework
- **Asynchronous Task Scheduling**: Implemented a complete task loop scheduling mechanism based on asyncio
- **Streaming Response Parsing**: Real-time parsing of LLM streaming output, supporting context management of tool call results
- **Multi-Tool Collaboration**: Supports dynamic tool registration and automatic context injection
### 2. MCP Protocol Client
- **Standardized Implementation**: Fully implemented Model Context Protocol client
- **Tool Integration**: Successfully integrated 2 tool Servers (fetch, filesystem), including 15 native tools
- **Lifecycle Management**: Supports dynamic registration, invocation, and resource cleanup of tools
### 3. Vector Database
- **Implemented from Scratch**: Implemented a vector database based on pure Python, without relying on third-party vector libraries
- **Cosine Similarity Algorithm**: Implemented an efficient semantic retrieval algorithm
- **Performance**:
- 10 documents: 1.25ms
- 100 documents: 12.21ms
- 1000 documents: 117.98ms
- Linearly scalable performance
### 4. RAG Retrieval-Augmented Generation
- **Embedding Pipeline**: Integrated BAAI/bge-large-zh-v1.5 pre-trained model
- **Semantic Retrieval**: Top-K retrieval based on vector similarity
- **Recall Accuracy**: Hit Rate@5 reaches 100%
## Core Module Description
### Agent.py
Implements a complete Agent task loop scheduling framework:
- Tool call routing and result management
- Real-time parsing of streaming responses
- Asynchronous task scheduling
### MCPClient.py
MCP protocol client implementation:
- Connection management with MCP Server
- Tool list acquisition and invocation
- Lifecycle management
### VectorStore.py
Core implementation of the vector database:
- Vector storage and indexing
- Cosine similarity calculation
- Top-K retrieval algorithm
### EmbeddingRetriver.py
Embedding retriever:
- Document embedding
- Query embedding
- Semantic retrieval
## Technical Highlights
1. **Implemented from Scratch**: Core components such as the vector database and MCP client are implemented from scratch, demonstrating underlying technical capabilities
2. **Asynchronous Architecture**: Fully asynchronous design, supporting high-concurrency scenarios
3. **Protocol Standardization**: Adopts the MCP protocol for standardized tool integration
4. **Performance Optimization**: Based on actual test data, performance is linearly scalable
5. **Engineering**: Complete test coverage, quantifiable performance data
## Future Optimization Directions
- [ ] Use NumPy vectorization to optimize vector retrieval performance
- [ ] Integrate professional vector databases (FAISS, Milvus)
- [ ] Implement a caching mechanism to reduce redundant calculations
- [ ] Support more MCP Tool Servers
- [ ] Implement a multi-Agent collaboration mechanism
Connection Info
You Might Also Like
n8n
n8n is a workflow automation platform for technical teams, combining code...
ollama
Get up and running with OpenAI gpt-oss, DeepSeek-R1, Gemma 3 and other models.
dify
Dify is a platform for AI workflows, enabling file uploads and self-hosting.
open-webui
Open WebUI is an extensible web interface for various applications.
NextChat
NextChat is a light and fast AI assistant supporting Claude, DeepSeek, GPT4...
zed
Zed is a high-performance multiplayer code editor from the creators of Atom.
Cline
Cline is a versatile tool available on VS Marketplace for enhancing...
anything-llm
AnythingLLM: An all-in-one AI app for chatting with documents and using AI agents.
cherry-studio
🍒 Cherry Studio is a desktop client that supports for multiple LLM providers.
chatbox
User-friendly Desktop Client App for AI Models/LLMs (GPT, Claude, Gemini, Ollama...)