mcp-support-chat-server

mnarushevich/mcp-support-chat-server

3.2

If you are the rightful owner of mcp-support-chat-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

A PHP MCP (Model Context Protocol) server that provides data from a MySQL database to chat support services.

Tools
  1. get_user_info

    Retrieve user information by ID

  2. search_users

    Search users by name or email

  3. get_chat_history

    Get chat history for a user

  4. get_support_tickets

    Get support tickets with filtering

  5. create_support_ticket

    Create a new support ticket

PHP MCP Chat Bot Server

A PHP MCP (Model Context Protocol) server that provides data from a MySQL database to chat support services.

Features

  • MCP Tools: Database query tools for chat support
  • MCP Resources: Access to user data, chat history, and support tickets
  • MCP Prompts: Pre-defined prompts for common support scenarios
  • MySQL Integration: Secure database access with PDO
  • Testing: Comprehensive PHPUnit test suite

Requirements

  • PHP >= 8.4
  • MySQL >= 8.0
  • Composer

Installation

  1. Clone the repository:
git clone <repository-url>
cd mcp-support-chat-server
  1. Install dependencies:
composer install

OR if using Laravel Herd

herd composer install
  1. Copy the environment file and configure your database:
cp .env.example .env
  1. Create the database and run migrations:
docker compose up -d
docker exec -i mcp_db_mysql sh -c 'mysql -uroot mcp_chat' < ./database/schema.sql

Usage

Running the MCP Server

STDIO Transport (Recommended for development)
php server.php

OR if using Laravel Herd

herd php server.php
HTTP Transport
php server.php --transport=http

OR if using Laravel Herd

herd php server.php --transport=http

MCP Tools

Database Tools

  • get_user_info: Retrieve user information by ID
  • search_users: Search users by name or email
  • get_chat_history: Get chat history for a user
  • get_support_tickets: Get support tickets with filtering
  • create_support_ticket: Create a new support ticket

Resource Tools

  • user://{userId}/profile: User profile data
  • chat://{userId}/history: Chat history for a user

Prompts

  • user_context: Provide user context for support

Database Schema

The server expects the following database tables:

  • users: User information
  • chat_messages: Chat message history

See database/schema.sql for the complete schema.

Configuration

The server can be configured through environment variables:

  • DB_HOST: Database host (default: localhost)
  • DB_PORT: Database port (default: 3306)
  • DB_DATABASE: Database name
  • DB_USERNAME: Database username
  • DB_PASSWORD: Database password
  • MCP_SERVER_NAME: MCP server name (default: "Chat Support MCP Server")
  • MCP_SERVER_VERSION: MCP server version (default: "1.0.0")

Development

Project Structure

ā”œā”€ā”€ src/
│   ā”œā”€ā”€ Config/
│   │   └── Environment.php
│   ā”œā”€ā”€ Core/
│   │   ā”œā”€ā”€ Container.php
│   │   └── ErrorHandler.php
│   ā”œā”€ā”€ Exceptions/
│   │   └── SystemExitException.php
│   ā”œā”€ā”€ Factories/
│   │   ā”œā”€ā”€ Builders/
│   │   │   ā”œā”€ā”€ ChatFactoryBuilder.php
│   │   │   └── UserFactoryBuilder.php
│   │   ā”œā”€ā”€ ChatFactory.php
│   │   └── UserFactory.php
│   ā”œā”€ā”€ Mcp/
│   │   ā”œā”€ā”€ McpConfig.php
│   │   ā”œā”€ā”€ McpServer.php
│   │   ā”œā”€ā”€ Prompts/
│   │   │   └── SupportPrompts.php
│   │   ā”œā”€ā”€ Resources/
│   │   │   ā”œā”€ā”€ ChatResources.php
│   │   │   └── UserResources.php
│   │   └── Tools/
│   │       ā”œā”€ā”€ ChatTools.php
│   │       └── UserTools.php
│   └── Models/
│       ā”œā”€ā”€ Chat.php
│       └── User.php
ā”œā”€ā”€ tests/
│   ā”œā”€ā”€ Integration/
│   │   ā”œā”€ā”€ Prompts/
│   │   │   └── SupportPromptsTest.php
│   │   ā”œā”€ā”€ Resources/
│   │   │   ā”œā”€ā”€ ChatResourcesTest.php
│   │   │   └── UserResourcesTest.php
│   │   └── Tools/
│   │       ā”œā”€ā”€ ChatToolsTest.php
│   │       └── UserToolsTest.php
│   ā”œā”€ā”€ Unit/
│   │   ā”œā”€ā”€ ErrorHandlerTest.php
│   │   └── McpServerTest.php
│   ā”œā”€ā”€ Pest.php
│   └── TestCase.php
ā”œā”€ā”€ database/
│   └── schema.sql
ā”œā”€ā”€ docker/
│   └── mysql/
│       └── create-testing-database.sh
ā”œā”€ā”€ bootstrap.php
ā”œā”€ā”€ composer.json
ā”œā”€ā”€ composer.lock
ā”œā”€ā”€ docker-compose.yml
ā”œā”€ā”€ phpunit.xml
ā”œā”€ā”€ rector.php
└── server.php

Adding New MCP Tools

  1. Create a new class in src/Mcp/Tools/
  2. Use the #[McpTool] attribute to define the tool
  3. Add the tool to the server registration in server.php

Example:

#[McpTool(name: 'custom_tool', description: 'A custom tool')]
public function customTool(string $parameter): array
{
    // Tool implementation
    return ['result' => 'success'];
}

License

MIT License - see LICENSE file for details.