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>This server cannot be deployed
Maintenance
ActivityStale
ResponsivenessNo issues