MCP RAG Agent Server
README.md
# ๐ MCP RAG Agent โ AI-Powered API Testing Framework





---
## ๐ Overview
The **MCP RAG Agent** is an AI-driven modular testing framework that combines:
* ๐ **RAG (Retrieval Augmented Generation)** โ Knowledge-based context retrieval
* โ๏ธ **MCP Layer (Tool Execution Engine)** โ Executes tools dynamically
* ๐งช **API Testing Agent** โ Automates API validation like Postman
It enables **natural language โ API execution โ validation โ intelligent response generation**.
---
# ๐ง System Architecture
```mermaid
graph TD
A[User Query] --> B[API Agent - NLP Parser]
B --> C[MCP Server - Tool Router]
C --> D[RAG Engine - Knowledge Retrieval]
C --> E[API Execution Tool]
D --> C
E --> F[External API / System]
F --> G[Response Validation Layer]
G --> H[Final AI Response]
```
---
## ๐งฉ Architecture Explanation
### 1๏ธโฃ API Agent Layer
* Accepts natural language input
* Converts request into structured API test case
### 2๏ธโฃ MCP Server Layer
* Central orchestration layer
* Routes requests to appropriate tools
### 3๏ธโฃ RAG Layer
* Fetches contextual knowledge from documents
* Enhances API validation logic
### 4๏ธโฃ Execution Layer
* Executes API calls (GET/POST/PUT/DELETE)
* Captures response payloads
### 5๏ธโฃ Validation Layer
* Compares expected vs actual response
* Returns structured test result
---
# ๐ End-to-End Flow
```
User Input
โ
API Agent (Intent Detection)
โ
MCP Server (Tool Selection)
โ
RAG (Context Injection)
โ
API Execution Engine
โ
Response Validation
โ
Final Result Output
```
---
# โ๏ธ Installation Guide
## 1๏ธโฃ Clone Repository
```bash
git clone https://github.com/karthikeyanramu/MCP_RAG_AGENT.git
cd MCP_RAG_AGENT
```
---
## 2๏ธโฃ Create Virtual Environment
```bash
python -m venv venv
```
Activate:
```bash
# Windows
venv\Scripts\activate
# Mac/Linux
source venv/bin/activate
```
---
## 3๏ธโฃ Install Dependencies
```bash
pip install -r requirements.txt
```
---
## 4๏ธโฃ Start MCP Server
```bash
python server/mcp_server.py
```
Expected:
```
MCP Server running on http://localhost:5000
```
---
## 5๏ธโฃ Run API Agent
```bash
python -m qa_agent.api_agent_runner
```
---
# ๐งช Postman Integration (Manual Testing Support)
Even though this system is AI-driven, it supports Postman-style API testing.
## ๐ Example Request
### ๐น Endpoint
```
POST http://localhost:5000/execute
```
### ๐น Headers
```json
{
"Content-Type": "application/json",
"Authorization": "Bearer <token-if-needed>"
}
```
### ๐น Sample Payload
```json
{
"tool": "api_executor",
"method": "POST",
"url": "https://api.example.com/login",
"headers": {
"Content-Type": "application/json"
},
"body": {
"username": "test_user",
"password": "Test@123"
}
}
```
---
## ๐ Sample Response
```json
{
"status": 200,
"message": "Login Successful",
"token": "eyJhbGciOiJIUzI1NiIs...",
"validation": "PASSED"
}
```
---
# ๐ CI/CD Pipeline (QA Maturity Model)
This system can be integrated into CI/CD pipelines for **automated API validation**.
## ๐ Pipeline Flow
```mermaid
graph LR
A[Code Push] --> B[CI Trigger - GitHub Actions]
B --> C[Install Dependencies]
C --> D[Run API Tests via MCP Agent]
D --> E[RAG Validation Layer]
E --> F[Test Report Generation]
F --> G[Deploy / Fail Pipeline]
```
---
## ๐งช CI/CD Benefits
โ Automated API regression testing
โ AI-driven validation (reduces manual QA effort)
โ Early defect detection
โ Domain knowledge injection via RAG
โ Scalable test execution
---
## ๐ Sample GitHub Actions Workflow
```yaml
name: MCP API Tests
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Python
uses: actions/setup-python@v4
with:
python-version: 3.10
- name: Install dependencies
run: pip install -r requirements.txt
- name: Run MCP API Agent
run: python -m qa_agent.api_agent_runner
```
---
# ๐งฐ Available Tools
| Tool | Purpose |
| ---------------- | ---------------------------- |
| knowledge_search | RAG-based document retrieval |
| calculator | Arithmetic operations |
| api_executor | Executes HTTP requests |
---
# ๐ Real-World Use Cases
* Banking API automation (AML / KYC)
* Collateral management system testing
* Microservices regression testing
* AI-driven QA automation frameworks
---
# โ ๏ธ Troubleshooting
## โ Port conflict
```bash
netstat -ano | findstr :5000
taskkill /PID <pid> /F
```
## โ Module error
```bash
pip install -r requirements.txt
```
---
# ๐ Future Enhancements
* OpenAI / LLM integration
* UI dashboard for test execution
* Kubernetes deployment
* Advanced embedding-based RAG
* Postman collection auto-import
---
# ๐จโ๐ป Summary
This project demonstrates:
โ AI-powered API testing
โ MCP-based tool orchestration
โ RAG-enhanced validation
โ Enterprise-grade QA automation architecture
This server cannot be deployed
Maintenance
ActivityInactive
ResponsivenessNo issues