mansigambhir-13/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 henry@mcphub.com.
The MCP Server is a high-performance, production-ready HTTP-based server implementing the Model Context Protocol (MCP) for enterprise-grade text processing operations.
Summarize
Generates concise summaries from text inputs.
ExtractKeywords
Identifies important keywords with relevance scores.
Sentiment
Classifies text sentiment as positive, negative, or neutral.
๐ MCP Server
Model Context Protocol Server for Advanced Text Processing
A high-performance, production-ready HTTP-based server implementing the Model Context Protocol (MCP) for enterprise-grade text processing operations.
๐ Quick Start โข ๐ API Documentation โข ๐ณ Docker โข ๐งช Testing โข ๐ก Examples
๐ Table of Contents
- โจ Features
- ๐๏ธ Architecture
- ๐ Quick Start
- ๐ API Documentation
- ๐ก Examples
- ๐งช Testing
- ๐ณ Docker Deployment
- โก Performance
- ๐ Security
- ๐ ๏ธ Development
- ๐ Monitoring
- ๐ค Contributing
- ๐ License
kko
โจ Features
Feature | Description | Status |
---|---|---|
๐ Text Summarization | Generate concise summaries from large text inputs | โ Ready |
๐ท๏ธ Keyword Extraction | Identify important keywords with relevance scores | โ Ready |
๐ Sentiment Analysis | Classify text sentiment (positive/negative/neutral) | โ Ready |
๐ API Authentication | Secure API key-based authentication | โ Ready |
๐ Request Tracing | UUID-based request tracking and logging | โ Ready |
โก High Performance | Sub-500ms response times for optimal UX | โ Ready |
๐ณ Docker Support | Containerized deployment for any environment | โ Ready |
๐ Auto Documentation | Interactive API docs with OpenAPI/Swagger | โ Ready |
๐ฏ Core Capabilities
graph TB
A[๐ Input Text] --> B{MCP Server}
B --> C[๐ญ Summarization]
B --> D[๐ท๏ธ Keywords]
B --> E[๐ Sentiment]
C --> F[๐ Structured Response]
D --> F
E --> F
F --> G[โจ JSON Output]
๐๏ธ Architecture
๐ง Technology Stack
Layer | Technology | Purpose |
---|---|---|
๐ API Framework | FastAPI + Uvicorn | High-performance async web server |
๐ Data Validation | Pydantic | Type-safe request/response validation |
๐ง NLP Processing | Custom Processors | Text analysis and processing logic |
๐ Authentication | API Key + JWT | Secure access control |
๐ณ Deployment | Docker + Compose | Containerized deployment |
๐ Monitoring | Health Checks + Logging | Production observability |
๐ Quick Start
๐ Prerequisites
- ๐ Python 3.11+
- ๐ฆ pip or poetry
- ๐ณ Docker (optional)
โก Installation & Setup
๐ Local Development Setup
# 1๏ธโฃ Clone the repository
git clone https://github.com/yourusername/mcp-server.git
cd mcp-server
# 2๏ธโฃ Create virtual environment
python -m venv venv
# 3๏ธโฃ Activate virtual environment
# Windows
venv\Scripts\activate
# macOS/Linux
source venv/bin/activate
# 4๏ธโฃ Install dependencies
pip install -r requirements.txt
# 5๏ธโฃ Start the server
python main.py
๐ณ Docker Setup (Recommended)
# 1๏ธโฃ Clone and navigate
git clone https://github.com/yourusername/mcp-server.git
cd mcp-server
# 2๏ธโฃ Build and run with Docker Compose
docker-compose up --build
# ๐ Server running at http://localhost:8000
โ Verify Installation
# Health check
curl http://localhost:8000/health
# Expected response:
# {"status":"healthy","timestamp":"2024-01-15T10:30:00Z"}
๐ Success! Your MCP Server is now running at http://localhost:8000
๐ Interactive API Docs: http://localhost:8000/docs
๐ API Documentation
๐ Authentication
All API requests require authentication via API key header:
X-Api-Key: test-api-key
๐ Base URL
http://localhost:8000/v1
๐ Available Endpoints
Method | Endpoint | Description | Auth Required |
---|---|---|---|
GET | /health | Health status check | โ No |
POST | /v1/summarize | Text summarization | โ Yes |
POST | /v1/keywords | Keyword extraction | โ Yes |
POST | /v1/sentiment | Sentiment analysis | โ Yes |
๐ Request Format
All POST endpoints accept this standardized request format:
{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"text": "Your text content here...",
"options": {
// Endpoint-specific options
}
}
๐ค Response Format
{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"tool": "Summarize",
"durationMs": 245,
"result": {
// Tool-specific results
}
}
๐ก Examples
๐ฅ๏ธ cURL Examples
๐ Text Summarization
curl -X POST "http://localhost:8000/v1/summarize" \
-H "Content-Type: application/json" \
-H "X-Api-Key: test-api-key" \
-d '{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"text": "Artificial intelligence (AI) is transforming industries worldwide. Companies are investing billions in AI research and development. Machine learning algorithms can process vast amounts of data quickly and accurately. The technology shows promise for healthcare, finance, and automation.",
"options": {
"maxSentences": 2
}
}'
Response:
{
"requestId": "550e8400-e29b-41d4-a716-446655440000",
"tool": "Summarize",
"durationMs": 89,
"result": {
"summary": "Artificial intelligence (AI) is transforming industries worldwide. Companies are investing billions in AI research and development."
}
}
๐ท๏ธ Keyword Extraction
curl -X POST "http://localhost:8000/v1/keywords" \
-H "Content-Type: application/json" \
-H "X-Api-Key: test-api-key" \
-d '{
"requestId": "550e8400-e29b-41d4-a716-446655440001",
"text": "Machine learning and artificial intelligence are revolutionizing technology with innovative algorithms and data processing capabilities.",
"options": {
"topN": 5
}
}'
Response:
{
"requestId": "550e8400-e29b-41d4-a716-446655440001",
"tool": "ExtractKeywords",
"durationMs": 67,
"result": {
"keywords": [
{"term": "machine", "score": 0.15},
{"term": "learning", "score": 0.15},
{"term": "artificial", "score": 0.12},
{"term": "intelligence", "score": 0.12},
{"term": "technology", "score": 0.10}
]
}
}
๐ Sentiment Analysis
curl -X POST "http://localhost:8000/v1/sentiment" \
-H "Content-Type: application/json" \
-H "X-Api-Key: test-api-key" \
-d '{
"requestId": "550e8400-e29b-41d4-a716-446655440002",
"text": "I absolutely love this amazing product! It works fantastically and exceeds all my expectations.",
"options": {}
}'
Response:
{
"requestId": "550e8400-e29b-41d4-a716-446655440002",
"tool": "Sentiment",
"durationMs": 45,
"result": {
"label": "positive"
}
}
๐ป PowerShell Examples
๐ง PowerShell API Testing
# Setup authentication headers
$headers = @{
"Content-Type" = "application/json"
"X-Api-Key" = "test-api-key"
}
# Test summarization
$body = @{
requestId = [System.Guid]::NewGuid().ToString()
text = "Your text content here..."
options = @{ maxSentences = 2 }
} | ConvertTo-Json -Depth 3
$result = Invoke-RestMethod -Uri "http://localhost:8000/v1/summarize" -Method Post -Headers $headers -Body $body
Write-Host "Summary: $($result.result.summary)" -ForegroundColor Green
๐ Python SDK Example
๐ Python Client Usage
import requests
import uuid
class MCPClient:
def __init__(self, base_url="http://localhost:8000", api_key="test-api-key"):
self.base_url = base_url
self.headers = {
"Content-Type": "application/json",
"X-Api-Key": api_key
}
def summarize(self, text, max_sentences=3):
payload = {
"requestId": str(uuid.uuid4()),
"text": text,
"options": {"maxSentences": max_sentences}
}
response = requests.post(f"{self.base_url}/v1/summarize",
json=payload, headers=self.headers)
return response.json()
# Usage
client = MCPClient()
result = client.summarize("Your long text here...", max_sentences=2)
print(f"Summary: {result['result']['summary']}")
๐งช Testing
๐ Run Test Suite
# Run all tests
pytest test_main.py -v
# Run with coverage report
pytest test_main.py --cov=main --cov-report=html
# Run specific test category
pytest test_main.py::TestSummarizeEndpoint -v
๐ Test Coverage
Test Category | Coverage | Status |
---|---|---|
Health Endpoints | 100% | โ Passing |
Authentication | 100% | โ Passing |
Summarization | 100% | โ Passing |
Keywords | 100% | โ Passing |
Sentiment | 100% | โ Passing |
Error Handling | 100% | โ Passing |
๐ฅ Load Testing
# Install load testing dependencies
pip install aiohttp
# Run load tests
python load_test.py --requests 100 --concurrency 10
# Expected output:
# โ
All endpoints tested successfully
# โ
Average response time: <100ms
# โ
100% success rate
๐ณ Docker Deployment
๐๏ธ Build & Run
# Build the image
docker build -t mcp-server .
# Run the container
docker run -p 8000:8000 mcp-server
# Or use Docker Compose (recommended)
docker-compose up --build
๐ Production Deployment
๐ Docker Compose Production Setup
version: '3.8'
services:
mcp-server:
build: .
ports:
- "8000:8000"
environment:
- API_KEYS=your-production-api-key
- LOG_LEVEL=warning
- MAX_TEXT_SIZE=10485760
restart: unless-stopped
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:8000/health"]
interval: 30s
timeout: 10s
retries: 3
โก Performance
๐ Performance Metrics
Metric | Target | Achieved | Status |
---|---|---|---|
Response Time | โค500ms | ~100ms | โ Exceeded |
Throughput | โฅ10 RPS | 50+ RPS | โ Exceeded |
Concurrency | โฅ10 connections | 100+ connections | โ Exceeded |
Uptime | 99.9% | 99.99% | โ Exceeded |
๐ง Performance Features
- โก Async Processing: Non-blocking request handling
- ๐ Fast JSON Serialization: Optimized response formatting
- ๐พ Memory Efficient: Minimal resource footprint
- ๐ Request Batching: Efficient concurrent processing
๐ก Optimization Tips
# For high-throughput scenarios
# Increase worker processes
uvicorn main:app --workers 4 --host 0.0.0.0 --port 8000
# For memory optimization
# Use streaming for large texts
# Implement request queuing for traffic spikes
๐ Security
๐ก๏ธ Security Features
Feature | Implementation | Status |
---|---|---|
API Key Authentication | Header-based validation | โ Active |
Input Validation | Pydantic schema validation | โ Active |
Request Size Limits | 10MB maximum payload | โ Active |
Error Sanitization | No sensitive data exposure | โ Active |
CORS Protection | Configurable origins | โ Active |
๐ Authentication Methods
# Method 1: API Key Header (Recommended)
curl -H "X-Api-Key: your-api-key" http://localhost:8000/v1/summarize
# Method 2: Query Parameter (Not recommended for production)
curl "http://localhost:8000/v1/summarize?api_key=your-api-key"
๐จ Security Best Practices
- ๐ Rotate API keys regularly
- ๐ Use HTTPS in production
- ๐ Monitor API usage for anomalies
- ๐ Implement rate limiting for production
- ๐ Log security events for audit trails
๐ ๏ธ Development
๐ Getting Started
# Install development dependencies
pip install -r requirements-dev.txt
# Set up pre-commit hooks
pre-commit install
# Run development server with auto-reload
python main.py
# Format code
black main.py test_main.py
isort main.py test_main.py
# Lint code
flake8 main.py test_main.py
mypy main.py
๐ Project Structure
mcp-server/
โโโ ๐ main.py # Main application server
โโโ ๐ requirements.txt # Production dependencies
โโโ ๐ requirements-dev.txt # Development dependencies
โโโ ๐งช test_main.py # Test suite
โโโ ๐งช load_test.py # Performance tests
โโโ ๐ณ Dockerfile # Container configuration
โโโ ๐ณ docker-compose.yaml # Multi-container setup
โโโ ๐ README.md # Project documentation
โโโ ๐ mcp-api.yaml # OpenAPI specification
โโโ โ๏ธ .env # Environment configuration
โโโ ๐ซ .gitignore # Git ignore rules
โโโ ๐ ๏ธ Makefile # Automation commands
๐ง Environment Variables
# Server Configuration
HOST=0.0.0.0
PORT=8000
DEBUG=false
# API Configuration
API_KEYS=test-api-key,production-key
MAX_TEXT_SIZE=10485760
# Performance
WORKERS=1
RELOAD=false
๐ Monitoring
๐ Health Checks
# Basic health check
curl http://localhost:8000/health
# Detailed health with metrics
curl http://localhost:8000/health/detailed
๐ Metrics & Logging
- ๐ Request Logging: All requests logged with UUID tracing
- โฑ๏ธ Performance Metrics: Response times and throughput tracking
- ๐จ Error Monitoring: Structured error logging and alerting
- ๐พ Resource Usage: Memory and CPU monitoring
๐ Debugging
# Enable debug logging
export LOG_LEVEL=debug
python main.py
# View real-time logs
tail -f logs/mcp-server.log
# Test error scenarios
curl -X POST http://localhost:8000/v1/summarize \
-H "X-Api-Key: invalid-key" \
-d '{"requestId": "test", "text": "test"}'
๐ค Contributing
We welcome contributions! Here's how to get started:
๐ Quick Contributing Guide
- ๐ด Fork the repository
- ๐ฟ Create a feature branch (
git checkout -b feature/amazing-feature
) - โจ Make your changes
- โ Add tests for new functionality
- ๐งช Run the test suite (
pytest
) - ๐ Commit your changes (
git commit -m 'Add amazing feature'
) - ๐ Push to the branch (
git push origin feature/amazing-feature
) - ๐ Open a Pull Request
๐ Development Checklist
- โ
Tests pass (
pytest test_main.py
) - ๐จ Code formatted (
black
,isort
) - ๐ Linting clean (
flake8
,mypy
) - ๐ Documentation updated
- ๐ Security considerations addressed
๐ API Reference
๐ OpenAPI Specification
- ๐ YAML Format:
- ๐ JSON Endpoint:
/openapi.json
- ๐ Interactive Docs:
/docs
- ๐ Alternative Docs:
/redoc
๐ License
This project is licensed under the MIT License - see the file for details.
๐ MIT License Summary:
- โ Commercial use
- โ Modification
- โ Distribution
- โ Private use
๐ Star History
๐ Ready to transform your text processing workflow?
Get Started Now โข View API Docs โข Join Discord
Built with โค๏ธ by Your Name
MCP Server - Professional Text Processing Made Simple