mnarushevich/mcp-support-chat-server
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.
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
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
- Clone the repository:
git clone <repository-url>
cd mcp-support-chat-server
- Install dependencies:
composer install
OR if using Laravel Herd
herd composer install
- Copy the environment file and configure your database:
cp .env.example .env
- 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 IDsearch_users
: Search users by name or emailget_chat_history
: Get chat history for a userget_support_tickets
: Get support tickets with filteringcreate_support_ticket
: Create a new support ticket
Resource Tools
user://{userId}/profile
: User profile datachat://{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 informationchat_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 nameDB_USERNAME
: Database usernameDB_PASSWORD
: Database passwordMCP_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
- Create a new class in
src/Mcp/Tools/
- Use the
#[McpTool]
attribute to define the tool - 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.