Nareshtt/mcp-server
If you are the rightful owner of mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to dayong@mcphub.com.
The Rathinam MCP Server is a Django backend that leverages AI to perform CRUD operations on external APIs using natural language queries.
Rathinam MCP Server - Backend
AI-powered natural language interface for CRUD operations on external APIs using Model Context Protocol (MCP).
🎯 Project Overview
This Django backend allows admins/developers to perform CRUD operations on existing APIs using natural language queries powered by AI (Claude/GPT). Instead of manually calling APIs or writing code, users can simply type commands like:
- "Add a student named Rahul with age 25"
- "Update all products with price less than 100 to set discount 10%"
- "Show me all orders from last week"
The MCP server interprets these commands, determines the appropriate API calls, and executes them automatically.
📋 Prerequisites
- Python 3.10 or higher
- PostgreSQL 14 or higher
- Redis (for caching and Celery)
- Node.js 18+ (for Next.js frontend - separate project)
🚀 Installation & Setup
1. Clone the Repository
git clone <your-repo-url>
cd rathinam-mcp-backend
2. Create Virtual Environment
# Using uv (recommended)
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Or using standard venv
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
3. Install Dependencies
pip install -r requirements.txt
4. Set Up PostgreSQL Database
# Create database
createdb rathinam_mcp
# Or using psql
psql -U postgres
CREATE DATABASE rathinam_mcp;
\q
5. Configure Environment Variables
# Copy the example env file
cp .env.example .env
# Edit .env and update with your values
nano .env # or use your preferred editor
Important variables to update:
SECRET_KEY- Generate a secure keyDB_PASSWORD- Your PostgreSQL passwordANTHROPIC_API_KEY- Your Anthropic API key for ClaudeCORS_ALLOWED_ORIGINS- Your Next.js frontend URL
6. Create Required Directories
mkdir -p logs media staticfiles static
7. Run Migrations
python manage.py makemigrations
python manage.py migrate
8. Create Initial Admin User
python manage.py create_initial_admin
This will create:
- Super Admin user (username:
admin, password:Admin@123) - Default MCP configurations
- Default AI model (Claude Sonnet 4.5)
⚠️ IMPORTANT: Change the default password immediately!
9. Collect Static Files
python manage.py collectstatic --noinput
10. Run the Development Server
python manage.py runserver
The API will be available at http://localhost:8000
📚 API Documentation
Once the server is running, access:
- Swagger UI: http://localhost:8000/api/docs/
- ReDoc: http://localhost:8000/api/redoc/
- OpenAPI Schema: http://localhost:8000/api/schema/
🔐 Authentication
All API endpoints (except login) require JWT authentication.
Login
POST /api/v1/auth/login/
Content-Type: application/json
{
"username": "admin",
"password": "Admin@123"
}
# Response:
{
"refresh": "eyJ0eXAiOiJKV1QiLCJ...",
"access": "eyJ0eXAiOiJKV1QiLCJ...",
"user": {
"id": 1,
"username": "admin",
"email": "admin@rathinam.edu",
"role": "SUPER_ADMIN"
}
}
Using the Access Token
Include the token in the Authorization header:
GET /api/v1/conversations/
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJ...
Refresh Token
POST /api/v1/auth/token/refresh/
Content-Type: application/json
{
"refresh": "eyJ0eXAiOiJKV1QiLCJ..."
}
📁 Project Structure
rathinam-mcp-backend/
├── config/ # Main project settings
│ ├── settings.py
│ ├── urls.py
│ └── wsgi.py
├── apps/
│ └── core/ # Main application
│ ├── models.py # Database models
│ ├── serializers.py # DRF serializers
│ ├── views.py # API views
│ ├── urls.py # URL routing
│ ├── permissions.py # Custom permissions
│ ├── admin.py # Django admin config
│ └── management/
│ └── commands/
│ └── create_initial_admin.py
├── logs/ # Application logs
├── media/ # User uploads
├── static/ # Static files
├── staticfiles/ # Collected static files
├── requirements.txt
├── .env.example
├── .env
├── .gitignore
├── manage.py
└── README.md
🔑 Key API Endpoints
Authentication
POST /api/v1/auth/login/- LoginPOST /api/v1/auth/logout/- LogoutPOST /api/v1/auth/token/refresh/- Refresh tokenGET /api/v1/auth/me/- Current user infoPUT /api/v1/auth/change-password/- Change password
Conversations
GET /api/v1/conversations/- List conversationsPOST /api/v1/conversations/- Create conversationGET /api/v1/conversations/{id}/- Get conversationPOST /api/v1/conversations/{id}/end/- End conversation
Queries
GET /api/v1/queries/- List queriesPOST /api/v1/queries/- Create queryGET /api/v1/queries/{id}/- Get query details
External APIs
GET /api/v1/external-apis/- List external APIsPOST /api/v1/external-apis/- Add external APIPOST /api/v1/external-apis/{id}/health-check/- Check API health
Dashboard
GET /api/v1/dashboard/overview/- Dashboard statsGET /api/v1/dashboard/recent-conversations/- Recent chatsGET /api/v1/dashboard/recent-queries/- Recent queries
Monitoring
GET /api/v1/alerts/- List alertsPOST /api/v1/alerts/{id}/acknowledge/- Acknowledge alertGET /api/v1/metrics/latest/- Latest system metrics
🛠️ Configuration
Adding External APIs
- Login to admin panel: http://localhost:8000/admin/
- Go to External APIs → Add External API
- Fill in:
- Name (e.g., "Student Management API")
- Base URL (e.g., "https://api.yourdomain.com")
- Auth Type (API_KEY, BEARER_TOKEN, etc.)
- Auth Credentials (JSON format)
- Add API Endpoints for this API
Configuring AI Models
- Go to AI Models in admin panel
- Update the API key for Claude or add OpenAI
- Set one model as default
- Configure max_tokens and temperature
🧪 Testing
# Run tests
python manage.py test
# Run with coverage
coverage run manage.py test
coverage report
📊 Database Models
Core Models
- AdminUser - System users (admins/developers)
- AuditLog - Complete audit trail
- MCPConversation - Chat sessions
- MCPMessage - Individual chat messages
- MCPQuery - Natural language queries
- APICall - External API calls tracking
Configuration
- ExternalAPI - External API configurations
- APIEndpoint - API endpoint catalog
- MCPConfiguration - System settings
- AIModel - AI model configurations
Monitoring
- SystemMetrics - Performance metrics
- Alert - System alerts
- UsageStatistics - User usage tracking
🔒 Security Features
- JWT authentication with token refresh
- Role-based access control (SUPER_ADMIN, ADMIN, DEVELOPER)
- Account lockout after failed login attempts
- Comprehensive audit logging
- Encrypted sensitive data
- CORS protection
- HTTPS enforcement in production
🚀 Production Deployment
Using Gunicorn
gunicorn config.wsgi:application --bind 0.0.0.0:8000 --workers 4
Using Docker (Coming Soon)
docker-compose up -d
Environment Variables for Production
Update your .env:
DEBUG=False
ALLOWED_HOSTS=your-domain.com,www.your-domain.com
SECRET_KEY=<generate-secure-key>
CORS_ALLOWED_ORIGINS=https://your-frontend.com
📝 Next Steps
- ✅ Backend setup complete
- 🔄 Set up MCP server integration (next phase)
- 🎨 Build Next.js frontend
- 🤖 Configure AI models and prompts
- 🔗 Connect to your existing CRUD APIs
🆘 Troubleshooting
Database Connection Error
# Check PostgreSQL is running
sudo systemctl status postgresql
# Verify database exists
psql -U postgres -l
Migration Issues
# Reset migrations (DANGER: loses data)
python manage.py migrate --run-syncdb
Port Already in Use
# Kill process on port 8000
lsof -ti:8000 | xargs kill -9
📞 Support
For issues and questions:
- Create an issue on GitHub
- Email: support@rathinam.edu
📄 License
[Your License Here]
Built with ❤️ for Rathinam College