MCP server by harshcoder7
MCP Data Flow Visualizer 🚀
A fascinating demonstration of the Model Context Protocol (MCP) with visual data flow through the OSI 7-layer model. Features both local (stdio) and remote (SSE) transports with real-time packet inspection, colorful visualizations, and educational OSI layer mapping.
✨ Features
-
5 Fascinating Server Tools:
- 🌦️ Weather Simulator - Realistic multi-day forecasts for major cities
- 🔐 Crypto Tools - Encrypt/decrypt with Caesar, ROT13, Base64, XOR
- 🎨 ASCII Art Generator - Convert text to beautiful ASCII art
- 💻 System Stats Monitor - Real-time CPU, memory, disk, network stats
- 🔍 Request Tracer - Meta-tool showing MCP internal flow
-
Two Transport Mechanisms:
- 📡 Stdio - Local process communication (lower latency)
- 🌐 SSE - HTTP-based remote communication (network-capable)
-
Rich Visualizations:
- 📦 JSON-RPC packet inspection with syntax highlighting
- 🔢 Hex dumps for binary analysis
- 📊 OSI 7-layer mapping showing active layers
- ⏱️ Timing waterfall charts
- 🎯 Flow diagrams with color-coded components
- 🎨 ANSI color-coded terminal output
-
Deployment Options:
- 💻 Local execution
- 🐳 Docker containerization
- ☁️ Remote server deployment
📋 Prerequisites
- Python 3.11+
- pip or uv package manager
- Docker (optional, for containerized deployment)
🚀 Quick Start
1. Installation
cd "D:\projects\MCP PROJECTS\mcp-fascinating-demo"
# Create virtual environment
python -m venv .venv
# Activate virtual environment
# Windows:
.venv\Scripts\activate
# Linux/Mac:
source .venv/bin/activate
# Install dependencies
pip install -r requirements.txt
2. Run Locally with Stdio Transport
# The stdio client will automatically start the server
python client/client_stdio.py
This will:
- ✅ Start MCP server as subprocess
- ✅ Connect via stdio pipes
- ✅ Run all 5 tool demonstrations
- ✅ Display OSI layer mapping (Layers 4-7 active)
- ✅ Show packet inspection and timing
3. Run with SSE Transport (Local)
Terminal 1 - Start Server:
python server/server.py --transport sse
Terminal 2 - Run Client:
python client/client_sse.py
This will:
- ✅ Connect to server via HTTP
- ✅ Run all 5 tool demonstrations
- ✅ Display OSI layer mapping (All 7 layers active!)
- ✅ Show network stack activity
4. Run with Docker (Remote-Ready)
Build and start server:
docker-compose up -d
Check server status:
docker-compose logs -f
Connect from client:
# Set server URL (can be remote IP/domain)
export MCP_SERVER_URL=http://localhost:8050
# Or for remote: export MCP_SERVER_URL=http://your-server-ip:8050
python client/client_sse.py
Stop server:
docker-compose down
📂 Project Structure
mcp-fascinating-demo/
├── server/
│ ├── server.py # Main FastMCP server
│ ├── tools/
│ │ ├── weather.py # Weather simulation
│ │ ├── crypto.py # Encryption/decryption
│ │ ├── ascii_art.py # ASCII art generator
│ │ ├── system_stats.py # System monitoring
│ │ └── tracer.py # Request flow tracer
│ └── utils/
│ └── visualizer.py # Shared utilities
├── client/
│ ├── client_stdio.py # Stdio transport demo
│ ├── client_sse.py # SSE transport demo
│ ├── visualizer/
│ │ ├── packet_inspector.py # JSON-RPC visualization
│ │ ├── osi_mapper.py # OSI layer mapping
│ │ └── flow_diagram.py # Flow visualization
│ └── utils/
│ ├── colors.py # ANSI colors
│ └── logger.py # Enhanced logging
├── docs/
│ ├── OSI_MAPPING.md # OSI layer details
│ └── ARCHITECTURE.md # System architecture
├── Dockerfile # Docker build config
├── docker-compose.yml # Docker orchestration
├── requirements.txt # Python dependencies
└── README.md # This file
🎯 What is MCP Host?
The MCP Host is the application that wants to use MCP tools. In this demo:
- Stdio Mode: Python client script IS the host (spawns server as subprocess)
- SSE Mode: Python client script IS the host (connects to remote server via HTTP)
- Production: Claude Desktop, IDEs, or custom applications act as hosts
Data Flow
MCP Host (Your Application)
│
├─ Contains MCP Client (protocol implementation)
│ │
│ └─ Communicates with MCP Server (stdio or HTTP)
│ │
│ └─ Executes Tools
│ │
│ └─ Returns Results
🌐 OSI 7-Layer Model Mapping
Stdio Transport (Local)
| Layer | Name | MCP Component | Active | |-------|------|---------------|--------| | 7 | Application | Tool execution, MCP logic | ✅ | | 6 | Presentation | JSON-RPC serialization | ✅ | | 5 | Session | ClientSession management | ✅ | | 4 | Transport | stdin/stdout pipes | ✅ | | 3 | Network | N/A (local IPC) | ❌ | | 2 | Data Link | N/A (local IPC) | ❌ | | 1 | Physical | CPU/memory bus | ⚠️ |
SSE Transport (Network)
| Layer | Name | MCP Component | Active | |-------|------|---------------|--------| | 7 | Application | Tool execution, MCP logic | ✅ | | 6 | Presentation | JSON-RPC serialization | ✅ | | 5 | Session | HTTP session management | ✅ | | 4 | Transport | TCP connection | ✅ | | 3 | Network | IP routing (localhost or remote) | ✅ | | 2 | Data Link | Ethernet frames on NIC | ✅ | | 1 | Physical | Network hardware (cable/WiFi) | ✅ |
Key Insight: SSE transport uses ALL 7 layers even on localhost, demonstrating the full network stack!
🔧 Available Tools
1. Weather Simulator
weather(city: str, days: int = 3)
Generate realistic forecasts for London, New York, Tokyo, Sydney, Paris, Moscow, Dubai.
2. Encrypt Message
encrypt(message: str, method: str = "caesar", key: int = 3)
Encrypt using caesar, rot13, base64, or xor.
3. Decrypt Message
decrypt(encrypted: str, method: str = "caesar", key: int = 3)
Decrypt previously encrypted messages.
4. ASCII Art
ascii_art(text: str, style: str = "standard")
Generate ASCII art with styles: standard, banner, big, block, simple.
5. System Stats
system_stats(metrics: list[str] = ["all"])
Get real-time stats for: cpu, memory, disk, network, system, all.
6. Request Tracer
trace(tool_name: str, params: dict = {})
Educational tool showing request flow through MCP layers.
🎨 Visual Output Examples
The demo produces fascinating visual output:
- Colorful ASCII art banners for headers
- JSON syntax highlighting (keys=cyan, strings=green, numbers=yellow)
- Box diagrams with Unicode characters
- Flow arrows showing request/response journey
- OSI layer stacks with active/inactive indicators
- Progress bars and timing waterfalls
- Hex dumps showing byte-level data
🐳 Docker Deployment
Local Docker
# Build and run
docker-compose up -d
# View logs
docker-compose logs -f
# Stop
docker-compose down
Remote Deployment
- Push to Docker Hub:
docker build -t yourusername/mcp-dataflow:latest .
docker push yourusername/mcp-dataflow:latest
- Deploy to remote server:
# On remote server
docker pull yourusername/mcp-dataflow:latest
docker run -d -p 8050:8050 --name mcp-server yourusername/mcp-dataflow:latest
- Connect from client:
# On your local machine
export MCP_SERVER_URL=http://your-server-ip:8050
python client/client_sse.py
🧪 Testing
# Run all tests
pytest tests/ -v
# Run with coverage
pytest tests/ --cov=server --cov=client -v
📚 Learn More
- OSI Model Details: See
docs/OSI_MAPPING.md - Architecture: See
docs/ARCHITECTURE.md - MCP Documentation: https://modelcontextprotocol.io
- MCP Python SDK: https://github.com/modelcontextprotocol/python-sdk
🎓 Educational Value
This demo teaches:
- MCP Architecture - Host → Client → Server → Tools
- Transport Mechanisms - Stdio vs SSE differences
- JSON-RPC Protocol - Message structure and flow
- OSI Model - Practical application to modern protocols
- Network Programming - Local IPC vs network communication
- Distributed Systems - Client-server patterns
- Debugging - Packet inspection and flow tracing
🚀 Next Steps
- Add authentication to SSE transport
- Implement WebSocket transport
- Create web-based visualization UI
- Add more tools (database queries, API calls, etc.)
- Implement tool chaining and workflows
- Add performance benchmarking
📝 License
MIT License - Feel free to use for learning and projects!
🤝 Contributing
Contributions welcome! This is an educational project to help people understand MCP.
🙏 Acknowledgments
- Built with FastMCP
- Uses the Model Context Protocol
- Inspired by the need for better MCP visualization tools
Enjoy exploring MCP! 🎉