Skip to main content
Glama
AtharvaPatil31

MCP Helpdesk Server

README.md
# MCP Helpdesk Server

A Model Context Protocol (MCP) server implementation for managing a Tier-1 helpdesk ticketing system using MySQL database.

## Overview

This MCP server provides a simple yet powerful interface for managing helpdesk tickets through the Model Context Protocol. It allows AI assistants and other MCP clients to query open tickets and resolve them with resolution notes.

## Features

- šŸŽ« **View Open Tickets**: Access all open helpdesk tickets through MCP resources
- āœ… **Resolve Tickets**: Mark tickets as closed with resolution notes
- šŸ”Œ **MCP Integration**: Seamlessly integrates with any MCP-compatible client
- šŸ—„ļø **MySQL Backend**: Robust database storage for ticket management

## Prerequisites

- Python 3.8 or higher
- MySQL Server 5.7 or higher
- pip (Python package manager)

## Installation

1. **Clone the repository**
   ```bash
   git clone https://github.com/AtharvaPatil31/MCP-Server-Local.git
   cd MCP-Server-Local
   ```

2. **Create a virtual environment** (recommended)
   ```bash
   python -m venv venv
   
   # On Windows
   venv\Scripts\activate
   
   # On macOS/Linux
   source venv/bin/activate
   ```

3. **Install dependencies**
   ```bash
   pip install -r requirements.txt
   ```

4. **Set up MySQL database**
   
   Create a database named `helpdesk` and a `tickets` table:
   
   ```sql
   CREATE DATABASE helpdesk;
   USE helpdesk;
   
   CREATE TABLE tickets (
       id INT AUTO_INCREMENT PRIMARY KEY,
       issue TEXT NOT NULL,
       status ENUM('OPEN', 'CLOSED') DEFAULT 'OPEN',
       resolution TEXT,
       created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
       updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
   );
   
   -- Sample data (optional)
   INSERT INTO tickets (issue, status) VALUES 
   ('User cannot login to email account', 'OPEN'),
   ('Printer not responding on floor 3', 'OPEN'),
   ('Software installation request for Adobe Photoshop', 'OPEN');
   ```

5. **Configure database connection**
   
   Edit `helpdesk_server.py` and update the database credentials:
   
   ```python
   def get_connection():
       return mysql.connector.connect(
           host="localhost",
           user="your_mysql_username",
           password="your_mysql_password",
           database="helpdesk"
       )
   ```

## Usage

### Running the Server

Start the MCP server:

```bash
python helpdesk_server.py
```

The server will run in STDIO transport mode, making it compatible with MCP clients.

### Testing MySQL Connection

Before running the main server, you can test your MySQL connection:

```bash
python test_mysql.py
```

### Available MCP Resources

#### Get Open Tickets
- **Resource URI**: `helpdesk://tickets/open`
- **Description**: Retrieves all tickets with 'OPEN' status
- **Returns**: Formatted list of open tickets with IDs and issue descriptions

### Available MCP Tools

#### resolve_ticket
- **Description**: Resolves an open ticket by marking it as closed
- **Parameters**:
  - `ticket_id` (int): The ID of the ticket to resolve
  - `resolution_notes` (str): Notes describing how the ticket was resolved
- **Returns**: Success message or error if ticket not found/already closed

## Integration with MCP Clients

### Claude Desktop Configuration

To use this server with Claude Desktop, add the following to your `claude_desktop_config.json`:

```json
{
  "mcpServers": {
    "helpdesk": {
      "command": "python",
      "args": ["c:\\path\\to\\helpdesk_server.py"],
      "env": {}
    }
  }
}
```

### Generic MCP Client

Any MCP-compatible client can connect to this server using STDIO transport:

```python
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client

server_params = StdioServerParameters(
    command="python",
    args=["helpdesk_server.py"]
)

async with stdio_client(server_params) as (read, write):
    async with ClientSession(read, write) as session:
        # Initialize and use the session
        await session.initialize()
        # Your code here
```

## Project Structure

```
MCP_Helpdesk/
ā”œā”€ā”€ helpdesk_server.py    # Main MCP server implementation
ā”œā”€ā”€ test_mysql.py         # MySQL connection test script
ā”œā”€ā”€ requirements.txt      # Python dependencies
ā”œā”€ā”€ README.md            # This file
└── venv/                # Virtual environment (not committed)
```

## Dependencies

- `mysql-connector-python`: MySQL database connector
- `mcp`: Model Context Protocol server framework

See `requirements.txt` for specific versions.

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

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

## License

This project is open source and available under the MIT License.

## Author

**Atharva Patil**
- GitHub: [@AtharvaPatil31](https://github.com/AtharvaPatil31)

## Acknowledgments

- Built with [Model Context Protocol (MCP)](https://modelcontextprotocol.io/)
- Uses [FastMCP](https://github.com/jlowin/fastmcp) for simplified server implementation

---