Advanced MCP HTTP Server

Advanced MCP HTTP Server

An HTTP-based MCP server that provides filesystem tools and code analysis, enabling LLMs to read, write, list files, and analyze code securely.

Category
Visit Server

README

MCP HTTP Advanced Host-Client-Server Application

CI/CD Python 3.9+ License: MIT Coverage: 90%+

A production-ready implementation of the Model Context Protocol (MCP) over HTTP with LLM tool integration, featuring OpenAI GPT models, comprehensive security, resilience patterns, and enterprise testing.

๐ŸŽฏ Key Features

Core Capabilities

  • โœ… HTTP-based MCP - Distributed tool protocol over HTTP
  • โœ… LLM Integration - OpenAI GPT model with function calling
  • โœ… Filesystem Tools - Read/write files with security
  • โœ… Web UI - Gradio interface for exploration and testing
  • โœ… AI Agent - Autonomous tool execution based on user intent

Production Ready

  • โœ… Configuration Management - JSON config with env var substitution
  • โœ… Security - Path traversal prevention, input validation, UTF-8 enforcement
  • โœ… Resilience - Connection retry, heartbeat verification, error recovery
  • โœ… Logging - Structured logging with configurable levels
  • โœ… Testing - 75+ tests with 90%+ coverage, CI/CD pipeline
  • โœ… Documentation - Comprehensive guides for configuration and testing

๐Ÿ“ฆ What's Included

๐ŸŽฏ mcp_http_server.py          HTTP MCP Server (FastMCP)
๐ŸŽจ mcp_http_client_app.py      Web UI (Gradio) for exploration
๐Ÿค– mcp_http_host_app.py        AI Agent with OpenAI integration
๐Ÿ“‹ mcp_config.py               Configuration management with priority resolution
โš™๏ธ  mcp_config.json            Production configuration
๐Ÿงช tests/                      75+ test cases with pytest
๐Ÿ”„ .github/workflows/ci_cd.yml  GitHub Actions CI/CD pipeline
๐Ÿ“š Documentation               Guides for quick start, config, testing, and review

๐Ÿš€ Quick Start (5 minutes)

Prerequisites

python 3.9+          # For async/await and type hints
pip package manager  # For dependency installation
OpenAI API key       # For GPT model access

Installation

  1. Clone and setup

    git clone <repo>
    cd advanced-mcp-host-client-server-app
    pip install -r requirements.txt
    
  2. Set API key

    export OPENAI_API_KEY=sk-your-key-here
    
  3. Start server

    python mcp_http_server.py
    # Server running on http://127.0.0.1:8000
    
  4. Start AI Host (new terminal)

    python mcp_http_host_app.py http://127.0.0.1:8000 ./workspace
    # Access at http://127.0.0.1:7862
    
  5. Chat with AI

    • Go to http://127.0.0.1:7862
    • Type: "List the files in workspace"
    • AI calls list_files tool automatically!

See QUICKSTART.md for detailed setup instructions.

๐Ÿ“– Documentation

Document Purpose
QUICKSTART.md 5-minute setup and common tasks
CONFIG.md Configuration reference with examples
TESTING.md Testing guide with 75+ test cases
PROJECT_REVIEW.md Complete technical review and architecture

๐Ÿ—๏ธ Architecture

Component Diagram

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚              MCP Application Suite                    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

    GUI Client                AI Host App            API Clients
   (Gradio UI)         (GPT + Tool Calling)       (Custom clients)
        โ”‚                     โ”‚                        โ”‚
        โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                         HTTP/Streamable
                              โ”‚
                    โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
                    โ”‚  HTTP MCP Server   โ”‚
                    โ”‚   (FastMCP)        โ”‚
                    โ”‚                    โ”‚
                    โ”‚ โ€ข File Tools       โ”‚
                    โ”‚ โ€ข Resources        โ”‚
                    โ”‚ โ€ข Prompts          โ”‚
                    โ”‚ โ€ข Analysis         โ”‚
                    โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                              โ”‚
                         Workspace
                    (./workspace files)

Component Responsibilities

  • mcp_http_server.py: Exposes filesystem and analysis tools via HTTP MCP
  • mcp_http_client_app.py: Web UI for exploring tools, resources, and prompts
  • mcp_http_host_app.py: LLM agent that calls tools autonomously
  • mcp_config.py: Centralized configuration with priority resolution
  • tests/: Comprehensive test suite for reliability

๐Ÿ”’ Security Features

Feature Purpose Example
Roots Validation Prevent directory traversal Blocks ../../etc/passwd
Path Checking Block absolute paths Rejects /etc/passwd
Input Validation Sanitize parameters Checks for special chars
UTF-8 Encoding Prevent encoding attacks Enforces UTF-8 on files
Error Safety No path disclosure Returns safe error messages

โš™๏ธ Configuration

Three Tiers (Priority)

1. Command-line arguments  (Highest priority)
   โ””โ”€ python app.py --model gpt-4o

2. Configuration file
   โ””โ”€ mcp_config.json with "model": "gpt-4o-mini"

3. Environment variables
   โ””โ”€ export OPENAI_MODEL=gpt-4o-mini

4. Hardcoded defaults      (Lowest priority)
   โ””โ”€ DEFAULT_MODEL = "gpt-4o-mini"

Example mcp_config.json

{
  "openai": {
    "api_key": "${OPENAI_API_KEY}",
    "model": "gpt-4o-mini"
  },
  "server": {
    "host": "127.0.0.1",
    "port": 8000
  },
  "gui": {
    "host": "127.0.0.1",
    "port": 7862
  },
  "logging": {
    "level": "INFO"
  }
}

See CONFIG.md for complete configuration guide.

๐Ÿงช Testing

Run All Tests

pip install -r requirements-test.txt
pytest tests/ -v

Test Coverage

  • Overall: 90%+
  • Config module: 95%+
  • Server module: 90%+
  • Client module: 85%+

Test Types

  • Unit Tests (60%): Fast, isolated component tests
  • Security Tests (20%): Vulnerability and attack prevention
  • Integration Tests (20%): Real-world scenarios

See TESTING.md for comprehensive testing guide.

๐Ÿ”„ Resilience Features

Feature Impact Details
Connection Retry Automatic recovery 3 attempts, 1s delay
Heartbeat Detects dead connections 2s verification timeout
History Bounded Prevents token overflow Max 20 messages
Error Recovery Graceful degradation Logs errors, continues

๐Ÿ“Š Performance

Metric Value
Server Throughput ~100+ requests/second
Tool Call Latency <50ms (local network)
Connection Time <1 second (with retry)
Memory Baseline ~100MB
Max History 20 messages (bounded)

๐Ÿš€ Deployment

Local Development

# Terminal 1: Server
python mcp_http_server.py

# Terminal 2: GUI Client
python mcp_http_client_app.py http://localhost:8000 ./workspace

# Terminal 3: AI Host
python mcp_http_host_app.py http://localhost:8000 ./workspace

Docker

docker build -t mcp-app .
docker run -e OPENAI_API_KEY=$OPENAI_API_KEY -p 8000:8000 -p 7862:7862 mcp-app

GitHub Actions CI/CD

  • โœ… Automated testing on Python 3.9-3.11
  • โœ… Runs on Linux, macOS, Windows
  • โœ… Code quality checks (pylint, black, flake8, mypy)
  • โœ… Security checks (bandit, safety)
  • โœ… Coverage reporting

See PROJECT_REVIEW.md for deployment details.

๐Ÿ› ๏ธ Tools & Technologies

Core

  • FastMCP 2.12.5: MCP server framework
  • OpenAI SDK 2.6.1: GPT model integration
  • Gradio 5.49.1: Web UI framework
  • Uvicorn 0.38.0: ASGI server
  • HTTPx: HTTP client

Testing

  • Pytest 7.4.3: Test framework
  • Pytest-asyncio: Async test support
  • Pytest-cov: Coverage reporting
  • Black, Pylint, Flake8, MyPy: Code quality

๐Ÿ“ API Reference

Server Tools

read_file(filepath: str) -> str
  # Read file from workspace

write_file(filepath: str, content: str) -> str
  # Write file to workspace

list_files(directory: str) -> List[str]
  # List directory contents

analyze_code(code: str, focus: str = "") -> str
  # Analyze code with LLM

Client Methods

await client.connect()
await client.list_tools()
await client.call_tool(name, arguments)
await client.list_resources()
await client.read_resource(uri)
await client.list_prompts()
await client.get_prompt(name, arguments)

๐Ÿ” Security Considerations

โœ… Implemented

  • Path traversal prevention
  • Input validation on all parameters
  • UTF-8 encoding enforcement
  • Error message safety
  • Dependency security checks (CI/CD)

โš ๏ธ To Implement

  • API authentication
  • Authorization/RBAC
  • Rate limiting
  • Request signing
  • Data encryption at rest

See PROJECT_REVIEW.md for security details.

๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit changes (git commit -m 'Add amazing feature')
  4. Push to branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

All PRs must:

  • โœ… Pass all tests
  • โœ… Maintain 90%+ coverage
  • โœ… Pass code quality checks
  • โœ… Include documentation

๐Ÿ“‹ Project Status

โœ… Completed

  • HTTP MCP server with filesystem tools
  • Gradio web UI for tool exploration
  • OpenAI integration with function calling
  • Configuration management system
  • 75+ test cases with CI/CD pipeline
  • Comprehensive documentation
  • Security hardening
  • Resilience patterns

๐Ÿšง In Progress

  • Enhanced monitoring and metrics
  • Performance optimization
  • Extended logging

๐Ÿ“‹ Planned

  • Multi-instance load balancing
  • Persistent conversation storage
  • Database-backed file storage
  • Authentication/authorization
  • WebSocket support
  • Batch operations
  • Custom tool templates

๐Ÿ“„ License

This project is licensed under the MIT License - see LICENSE file for details.

๐Ÿ‘ฅ Author

Deepak Upadhyay - Engineering

๐Ÿ™ Acknowledgments

  • FastMCP team for MCP server framework
  • OpenAI for GPT model APIs
  • Gradio for web UI components
  • Python async/await ecosystem

๐Ÿ“ž Support

For issues, questions, or feature requests:

  1. Check Documentation

  2. Review Examples

  3. Debug Issues

    • Enable debug logging: LOG_LEVEL=DEBUG
    • Check PROJECT_REVIEW.md for architecture
    • Run tests: pytest -v to verify setup

๐ŸŽ“ Learning Resources


Version: 1.0.0
Last Updated: 2024
Status: Production Ready โœ…

Made with โค๏ธ for the agentic engineering community.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured