MCP Chat Insight Server
Project description
MCP Chat Insight Server
Introduction
MCP WX Insight Server is an MCP server for data analytics. It provides data interaction and business intelligence features via MySQL. The server supports running SQL queries, analyzing business data, and automatically generating business insight memos. It supports both single-database and cross-database analysis modes, which is especially useful when analyzing multiple tables with identical DDLs (e.g., sharded group chat message tables). The server only requires read access for analysis; write and delete operations are not within scope. Please ensure your data is prepared in MySQL before use.
Main features include:
- Support for single-database and cross-database analysis (cross-database requires identical table structures; ensure the DB account can execute
SHOW CREATE TABLE) - Supports STDIO and SSE transport protocols (can be debugged with Postman for MCP protocol)
- Complete data validation and error handling
- Debug logging support
Components
Resources
The server provides a dynamic resource:
memo://business_insights: A continuously updated business insight memo, summarizing insights discovered during analysis- Automatically updated when new insights are found via the append-insight tool
Prompts
-
chatinsight: Interactive demo prompt guiding users through database query operations- Required parameters:
topic,role– the business domain and user role for analysis - Guides users through analysis and business insight discovery
- Required parameters:
-
chatinsight_ordinary: Built-in fallback system prompt- Used when a system prompt is needed (different from demo prompts)
Tools
Query Tools
-
query- Executes SELECT queries to read data from the database
- Input:
query(string): The SELECT SQL query to execute
- Returns: Query results as an array of objects
-
list_tables- Retrieves the list of active data tables
- No input required
- Returns: Query results as an array of objects
Analysis Tools
append_insight(deprecated)- Adds new business insights to the memo resource
- Input:
insight(string): Business insight discovered from data analysis
- Returns: Confirmation of insight addition
- Triggers update of the memo://business_insights resource
report- Generates a summary report for a custom time range
- No input required
- Returns: Guidance prompt for generating the report
Using with Desktop
SSE
# Startup command
$env:MYSQL_HOST="localhost"; $env:MYSQL_PORT="3306"; $env:MYSQL_USER="root"; $env:MYSQL_PASSWORD="123456"; uv run mcp-chat-insight --table "test1.wx_record,test2.wx_record" --desc "Group chat messages" --mapping "chat_data.group_messages" --transport "sse" --port 8000 --sse_path "/mcp-chat-insight/sse" --debug
# Desktop configuration
{
"mcp-chat-insight":
{
"type": "sse",
"command": "http://localhost:8000/mcp-chat-insight/sse"
}
}
STDIO
{
"mcp-chat-insight":
{
"command": "uv",
"args":
[
"--directory",
"parent_of_servers_repo/.../mcp_chat_insight",
"run",
"mcp-chat-insight",
"--table",
"test1.wx_record,test2.wx_record", # Table names to analyze (e.g., test.wx_record; use comma to separate multiple tables)
"--mapping", # Virtual table name for simplifying multi-table SQL generation
"chat_data.group_messages",
"--debug" # Run in debug mode
],
"env":
{
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "123456"
}
}
}
# Claude
{
"mcp-chat-insight": {
"command": "npx",
"args": [
"-y",
"supergateway",
"--sse",
"http://localhost:8000/mcp-chat-insight/sse"
]
}
# Cursor
# First: pip install mcp-chat-insight
{
"mcpServers":
{
"mcp-chat-insight":
{
"command": "uv",
"args":
[
"run",
"mcp-chat-insight",
"--table",
"test1.wx_record,test2.wx_record",
"--mapping",
"chat_data.group_messages",
"--debug"
],
"env":
{
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "123456"
}
}
}
}
# Cursor Remote
{
"mcp-chat-insight": {
"url": "http://localhost:8000/mcp-chat-insight/sse"
}
}
Docker
# Add the server to your claude_desktop_config.json
"mcpServers": {
"mcp-chat-insight": {
"command": "docker",
"args": [
"run",
"--rm",
"-i",
"-v",
"mcp-test:/mcp",
"mcp/mcp-chat-insight",
"--table",
"..."
]
}
}
Build
Install Packages
# Create virtual environment
uv venv --python "D:\software\python3.11\python.exe" .venv
# Activate virtual environment
.\.venv\Scripts\activate
# Install package
uv add fastmcp # uv remove fastmcp
Run
# Install project dependencies
uv pip install -e .
# Run the service
uv run mcp-chat-insight
Test
$env:MYSQL_HOST="localhost"; $env:MYSQL_PORT="3306"; $env:MYSQL_USER="root"; $env:MYSQL_PASSWORD="123456"; uv run mcp-chat-insight --table 'test1.wx_record,test2.wx_record' --desc "Group chat messages" --mapping "chat_data.group_messages" --debug
$env:MYSQL_HOST="localhost"; $env:MYSQL_PORT="3306"; $env:MYSQL_USER="root"; $env:MYSQL_PASSWORD="123456"; uv run mcp-chat-insight --table 'test1.wx_record,test2.wx_record' --desc "Group chat messages" --mapping "chat_data.group_messages" --transport "sse" --port 8000 --sse_path "/mcp-chat-insight/sse" --debug # http://localhost:8000/mcp-chat-insight/sse
Packaging & Release
del /f /q dist\*.*
uv pip install build
python -m build
twine upload -r nexus dist\*
Database Setup
Before running the project, you need to set up the database. A sample schema file is provided at examples/sample_schema.sql. This file contains the basic table structure, which you can modify as needed.
To use the sample schema:
- Install MySQL database
- Import the sample data into your database tables
Sample schema includes the following tables:
- test1.wx_record: Group chat message table
- test2.wx_record: Group chat message table
Test MCP Server with MCP Inspector
uv add "mcp[cli]"
mcp dev src/mcp_chat_insight/server.py:ChatInsightServer
License
This MCP server is licensed under the Apache License 2.0. You are free to use, modify, and distribute this software, provided you comply with the terms and conditions of the Apache License. For more details, see the LICENSE file in the project repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_chat_insight-0.2.0.tar.gz.
File metadata
- Download URL: mcp_chat_insight-0.2.0.tar.gz
- Upload date:
- Size: 33.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f4ded3e2a4ff7247be8bd61b0b64c1eb2327b47895df90e326188d91fbc702c0
|
|
| MD5 |
b42a9b1eac68b4dc9d9ad3f752025023
|
|
| BLAKE2b-256 |
4ddcacdc14d95e17e2c2b58bcee5964c3bed1afb3e705ac980284245c06b6265
|
File details
Details for the file mcp_chat_insight-0.2.0-py3-none-any.whl.
File metadata
- Download URL: mcp_chat_insight-0.2.0-py3-none-any.whl
- Upload date:
- Size: 21.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d371e3d0b827604670f114aaaf54b1add508be6429fea0ef0fa2986070a4690e
|
|
| MD5 |
42a48943735a0b26a94c0becc0e9d9d7
|
|
| BLAKE2b-256 |
0a6838d5dccc40f0013cb27e5d7508360351bd8f2666acd9b1da5217070897cf
|