Skip to main content
Glama
golam74

MCP Server

by golam74
README.md
<div align="center">

# ๐Ÿš€ MCP Server

### Production-Ready Model Context Protocol Server Built with Python & FastMCP

<p align="center">

A clean, modular, scalable, and Docker-ready implementation of the Model Context Protocol (MCP), designed for AI applications and developer productivity.

</p>

<p align="center">

<img src="https://img.shields.io/badge/Python-3.11+-3776AB?style=for-the-badge&logo=python&logoColor=white"/>

<img src="https://img.shields.io/badge/FastMCP-Latest-009688?style=for-the-badge"/>

<img src="https://img.shields.io/badge/Docker-Ready-2496ED?style=for-the-badge&logo=docker&logoColor=white"/>

<img src="https://img.shields.io/badge/License-MIT-yellow?style=for-the-badge"/>

<img src="https://img.shields.io/badge/Status-Production%20Ready-success?style=for-the-badge"/>

</p>

<p align="center">

<img src="https://img.shields.io/github/stars/golam74/MCP_SERVER?style=social"/>

<img src="https://img.shields.io/github/forks/golam74/MCP_SERVER?style=social"/>

<img src="https://img.shields.io/github/watchers/golam74/MCP_SERVER?style=social"/>

</p>

</div>

---

# ๐Ÿ“‘ Table of Contents

- ๐Ÿ“– Overview
- โœจ Features
- ๐Ÿ— Architecture
- ๐Ÿ“‚ Project Structure
- ๐Ÿ›  Tech Stack
- ๐Ÿš€ Getting Started
- ๐Ÿณ Docker
- โš™ Configuration
- ๐Ÿงฉ Available Tools
- ๐Ÿ“œ Logging
- ๐Ÿ“Š Roadmap
- ๐Ÿค Contributing
- ๐Ÿ“„ License

---

# ๐Ÿ“– Overview

The **MCP Server** is a production-ready implementation of the **Model Context Protocol (MCP)** using **Python** and **FastMCP**.

This project demonstrates how to build scalable, modular, and maintainable MCP servers that can expose reusable tools for AI assistants and MCP-compatible clients.

Unlike simple examples, this repository follows a production-oriented architecture with centralized tool registration, structured logging, Docker support, and a clean project layout.

It serves as both:

- ๐Ÿ“š A learning resource for developers exploring MCP.
- ๐Ÿ— A solid foundation for building real-world AI tool servers.

---

# โœจ Features

| Feature | Status |
|----------|--------|
| FastMCP Server | โœ… |
| Modular Architecture | โœ… |
| Central Tool Registry | โœ… |
| Professional Logging | โœ… |
| Tool Execution Logs | โœ… |
| Docker Support | โœ… |
| Docker Compose | โœ… |
| Environment Configuration | โœ… |
| Easy Tool Registration | โœ… |
| Production Ready Structure | โœ… |
| Extensible Design | โœ… |

---

# ๐ŸŽฏ Why This Project?

Most MCP examples available online are intentionally minimal.

This project goes beyond the basics by demonstrating:

- Clean architecture
- Separation of concerns
- Modular tool development
- Production-grade logging
- Dockerized deployment
- Reusable project structure
- Scalable code organization

It is intended to be a strong starting point for developers building AI-powered applications with MCP.

---

# ๐Ÿ— Architecture

The project follows a modular architecture to keep the codebase clean, maintainable, and easy to extend.

```mermaid
flowchart TD

    Client["MCP Client"]
    Server["FastMCP Server"]
    Registry["Tool Registry"]
    Calculator["Calculator Tools"]
    Time["Time Tools"]
    File["File Tools"]
    System["System Tools"]
    Math["Math Tools"]
    Text["Text Tools"]
    Utility["Utility Tools"]
    Logger["Logging System"]
    Logs["Log Files"]

    Client --> Server
    Server --> Registry

    Registry --> Calculator
    Registry --> Time
    Registry --> File
    Registry --> System
    Registry --> Math
    Registry --> Text
    Registry --> Utility

    Calculator --> Logger
    Time --> Logger
    File --> Logger
    System --> Logger
    Math --> Logger
    Text --> Logger
    Utility --> Logger

    Logger --> Logs
```

---

# ๐Ÿ“‚ Project Structure

```text
MCP_SERVER/
โ”‚
โ”œโ”€โ”€ .github/
โ”‚   โ””โ”€โ”€ workflows/
โ”‚       โ””โ”€โ”€ ci.yml
โ”‚
โ”œโ”€โ”€ app/
โ”‚   โ”œโ”€โ”€ tools/
โ”‚   โ”‚   โ”œโ”€โ”€ math_tool.py
โ”‚   โ”‚   โ”œโ”€โ”€ text_tools.py
โ”‚   โ”‚   โ””โ”€โ”€ utility_tools.py
โ”‚   โ”‚
โ”‚   โ”œโ”€โ”€ calculator.py
โ”‚   โ”œโ”€โ”€ datetime_tool.py
โ”‚   โ”œโ”€โ”€ file_reader.py
โ”‚   โ”œโ”€โ”€ logger.py
โ”‚   โ”œโ”€โ”€ log_decorator.py
โ”‚   โ”œโ”€โ”€ registry.py
โ”‚   โ”œโ”€โ”€ system_info.py
โ”‚   โ””โ”€โ”€ time_tool.py
โ”‚
โ”œโ”€โ”€ logs/
โ”‚   โ”œโ”€โ”€ error.log
โ”‚   โ””โ”€โ”€ mcp.log
โ”‚
โ”œโ”€โ”€ .dockerignore
โ”œโ”€โ”€ .env
โ”œโ”€โ”€ .gitignore
โ”œโ”€โ”€ CHANGELOG.md
โ”œโ”€โ”€ config.py
โ”œโ”€โ”€ CONTRIBUTING.md
โ”œโ”€โ”€ docker-compose.yml
โ”œโ”€โ”€ Dockerfile
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ pyproject.toml
โ”œโ”€โ”€ pytest.ini
โ”œโ”€โ”€ README.md
โ”œโ”€โ”€ requirements.txt
โ””โ”€โ”€ server.py
```

---

# โš™ Project Workflow

```text
Start Server
      โ”‚
      โ–ผ
Create FastMCP Instance
      โ”‚
      โ–ผ
Register All Tools
      โ”‚
      โ–ผ
Wait For MCP Client
      โ”‚
      โ–ผ
Receive Tool Request
      โ”‚
      โ–ผ
Execute Tool
      โ”‚
      โ–ผ
Write Logs
      โ”‚
      โ–ผ
Return Response
```

---

# ๐Ÿ›  Tech Stack

| Technology | Purpose |
|------------|---------|
| ๐Ÿ Python 3.11+ | Programming Language |
| โšก FastMCP | MCP Framework |
| ๐Ÿค– Model Context Protocol | AI Tool Communication |
| ๐Ÿณ Docker | Containerization |
| ๐Ÿ“ฆ Docker Compose | Local Deployment |
| ๐Ÿ“ Logging | Monitoring & Debugging |
| โš™ python-dotenv | Environment Variables |
| ๐Ÿงช Pytest | Future Testing |
| ๐Ÿ”„ GitHub Actions | Future CI/CD |

---

# ๐ŸŽฏ Design Principles

The project is built around a few core engineering principles:

- Modular architecture
- Single Responsibility Principle (SRP)
- Separation of Concerns
- Easy extensibility
- Centralized tool registration
- Consistent logging
- Docker-first deployment
- Clean project organization

---

# ๐Ÿ“ Core Modules

| Module | Responsibility |
|---------|----------------|
| `server.py` | Starts the MCP server |
| `registry.py` | Registers all available tools |
| `logger.py` | Configures application logging |
| `log_decorator.py` | Logs tool execution automatically |
| `config.py` | Central application configuration |
| `calculator.py` | Calculator-related tools |
| `time_tool.py` | Time and date utilities |
| `file_reader.py` | File reading tools |
| `system_info.py` | System information tools |
| `app/tools/` | Additional utility modules |

---

# ๐Ÿš€ Request Lifecycle

```text
MCP Client
     โ”‚
     โ–ผ
FastMCP Server
     โ”‚
     โ–ผ
Registry
     โ”‚
     โ–ผ
Requested Tool
     โ”‚
     โ–ผ
Execute Function
     โ”‚
     โ–ผ
Log Request
     โ”‚
     โ–ผ
Return Result
```

---

# ๐Ÿ“Œ Key Advantages

- Clean folder structure
- Easy to maintain
- Easy to test
- Easy to extend
- Production-ready layout
- Reusable architecture
- Docker support
- Consistent logging
- Beginner friendly
- Open-source friendly

---

# ๐Ÿš€ Getting Started

Follow the steps below to set up the project on your local machine.

---

# ๐Ÿ“‹ Prerequisites

Before running the project, ensure the following software is installed:

| Software | Version |
|----------|---------|
| Python | 3.11+ |
| Git | Latest |
| Docker *(Optional)* | Latest |
| Docker Compose *(Optional)* | Latest |

Verify your installation:

```bash
python --version
git --version
docker --version
```

---

# ๐Ÿ“ฅ Clone the Repository

```bash
git clone https://github.com/golam74/MCP_SERVER.git
```

Navigate to the project directory:

```bash
cd MCP_SERVER
```

---

# ๐Ÿ Create a Virtual Environment

### Windows

```bash
python -m venv venv
```

Activate it:

```bash
venv\Scripts\activate
```

### Linux / macOS

```bash
python3 -m venv venv
```

Activate it:

```bash
source venv/bin/activate
```

---

# ๐Ÿ“ฆ Install Dependencies

Upgrade pip:

```bash
python -m pip install --upgrade pip
```

Install project dependencies:

```bash
pip install -r requirements.txt
```

---

# โš™ Environment Variables

Create a `.env` file in the project root.

Example:

```env
APP_NAME=MCP Server
LOG_LEVEL=INFO
```

You can add additional configuration values as your project grows.

---

# โ–ถ Run the Server

Start the MCP server:

```bash
python server.py
```

Expected output:

```text
============================================================
MCP Server started successfully.
============================================================
```

---

# ๐Ÿณ Docker Support

Build the Docker image:

```bash
docker build -t mcp-server .
```

Run the container:

```bash
docker run --rm mcp-server
```

---

# ๐Ÿณ Docker Compose

Start the project:

```bash
docker compose up --build
```

Stop the project:

```bash
docker compose down
```

---

# โœ… Verify Installation

Everything is configured correctly if:

- โœ… Virtual environment is activated
- โœ… Dependencies install successfully
- โœ… Server starts without errors
- โœ… Log files are created
- โœ… Docker image builds successfully
- โœ… Docker Compose starts correctly

---

# ๐Ÿ“„ Configuration Files

| File | Description |
|------|-------------|
| `server.py` | Application entry point |
| `config.py` | Application configuration |
| `.env` | Environment variables |
| `requirements.txt` | Python dependencies |
| `Dockerfile` | Docker image |
| `docker-compose.yml` | Docker Compose configuration |
| `README.md` | Project documentation |

---

# ๐Ÿ“ Logging

The server automatically creates log files inside the `logs/` directory.

```text
logs/
โ”œโ”€โ”€ mcp.log
โ””โ”€โ”€ error.log
```

Each tool execution is logged with:

- Timestamp
- Tool Name
- Arguments
- Result
- Exceptions (if any)

Example:

```text
2026-07-18 05:38:43 | INFO | Tool Started : add_numbers
2026-07-18 05:38:43 | INFO | Arguments : (10, 20)
2026-07-18 05:38:43 | INFO | Result : 30
2026-07-18 05:38:43 | INFO | Tool Finished : add_numbers
```

---

# ๐Ÿงฉ Available MCP Tools

The server is organized into independent tool modules, making it easy to maintain and extend.

| Category | Description |
|----------|-------------|
| โž• Calculator Tools | Basic arithmetic operations |
| ๐Ÿ•’ Time Tools | Current date and time utilities |
| ๐Ÿ“„ File Reader | Read text files safely |
| ๐Ÿ’ป System Information | Operating system and hardware details |
| ๐Ÿ”ข Math Tools | Advanced mathematical utilities |
| ๐Ÿ“ Text Tools | String manipulation and formatting |
| โš™ Utility Tools | General-purpose helper utilities |

---

# ๐Ÿš€ Adding a New Tool

Adding a new tool to the server requires only three simple steps.

## Step 1

Create your tool inside the appropriate module.

Example:

```python
@mcp.tool
def square(number: int) -> int:
    return number * number
```

---

## Step 2

Register the tool inside the module.

```python
def register_math_tools(mcp):
    ...
```

---

## Step 3

Import the registration function into:

```text
app/registry.py
```

and register it:

```python
register_math_tools(mcp)
```

That's it!

No changes are required in `server.py`.

---

# ๐Ÿ’ป Example Usage

## Calculator

```python
add_numbers(10, 20)

# Output
30
```

---

## Time Tool

```python
get_current_time()
```

Output

```text
10:45:23
```

---

## File Reader

```python
read_file("example.txt")
```

Output

```text
Hello World
```

---

## System Information

```python
get_system_info()
```

Example Output

```text
Operating System : Windows
Python Version   : 3.11
Machine          : AMD64
```

---

# ๐Ÿ“œ Logging

Every tool execution is automatically logged.

Logged information includes:

- Tool Name
- Arguments
- Return Value
- Exceptions
- Timestamp

Example

```text
2026-07-18 05:38:43 | INFO | Tool Started : add_numbers
2026-07-18 05:38:43 | INFO | Arguments : (10, 20)
2026-07-18 05:38:43 | INFO | Result : 30
2026-07-18 05:38:43 | INFO | Tool Finished : add_numbers
```

---

# ๐Ÿ“Š Project Status

| Feature | Status |
|---------|--------|
| FastMCP Server | โœ… |
| Tool Registry | โœ… |
| Professional Logging | โœ… |
| Docker Support | โœ… |
| Docker Compose | โœ… |
| Environment Configuration | โœ… |
| Modular Architecture | โœ… |
| GitHub Repository | โœ… |
| Unit Tests | ๐Ÿšง |
| GitHub Actions | ๐Ÿšง |

---

# ๐Ÿ—บ Roadmap

## Version 1.0

- [x] FastMCP Server
- [x] Tool Registration System
- [x] Modular Architecture
- [x] Logging System
- [x] Docker Support
- [x] Docker Compose

---

## Version 1.1

- [ ] Unit Testing
- [ ] GitHub Actions
- [ ] Code Coverage
- [ ] Better Error Handling

---

## Version 1.2

- [ ] Async Tools
- [ ] More Utility Tools
- [ ] Performance Optimization

---

## Version 2.0

- [ ] Authentication
- [ ] Database Support
- [ ] Monitoring Dashboard
- [ ] Plugin Architecture

---

# ๐Ÿค Contributing

Contributions are always welcome!

If you'd like to improve this project, please follow these steps:

1. Fork the repository.
2. Create a new feature branch.

```bash
git checkout -b feature/awesome-feature
```

3. Commit your changes.

```bash
git commit -m "Add awesome feature"
```

4. Push your branch.

```bash
git push origin feature/awesome-feature
```

5. Open a Pull Request.

Please make sure your code follows the existing project structure and coding style.

---

# ๐Ÿงช Future Improvements

The following features are planned for future releases:

- Async MCP Tools
- Unit & Integration Tests
- GitHub Actions (CI/CD)
- Code Coverage Reports
- Performance Benchmarking
- Authentication & Authorization
- Database Integration
- Plugin Architecture
- Monitoring Dashboard
- API Documentation

---

# ๐Ÿ“ˆ Project Goals

This repository is designed to serve as:

- ๐Ÿ“š A learning resource for developers exploring MCP.
- ๐Ÿ— A production-ready starter template.
- ๐Ÿค– A foundation for AI tool development.
- ๐Ÿš€ A portfolio-quality open-source project.

---

# ๐Ÿค Support

If you find this project useful:

- โญ Star the repository
- ๐Ÿด Fork the project
- ๐Ÿ› Report bugs
- ๐Ÿ’ก Suggest new features
- ๐Ÿ”ฅ Contribute improvements

Your support helps make the project better for everyone.

---

# ๐Ÿ“„ License

This project is licensed under the **MIT License**.

See the [LICENSE](LICENSE) file for more details.

---

# ๐Ÿ‘จโ€๐Ÿ’ป Author

## Golam Israil

**AI Engineer | Python Developer | AI Automation Enthusiast**

### Connect with Me

- GitHub: https://github.com/golam74
- LinkedIn: *(Add your LinkedIn profile here)*

---

# ๐Ÿ™ Acknowledgements

Special thanks to the amazing open-source community and the technologies that made this project possible.

- Python
- FastMCP
- Model Context Protocol (MCP)
- Docker
- GitHub
- Open Source Community

---

# ๐ŸŒŸ If You Like This Project

If this repository helped you learn something new or saved you time:

โญ Give it a Star

๐Ÿด Fork it

๐Ÿ“ข Share it with others

Every contribution and every star motivates further development.

---

<div align="center">

# ๐Ÿš€ Happy Coding!

### Build โ€ข Learn โ€ข Share โ€ข Grow

Made with โค๏ธ by **Golam Israil**

</div>