Connects to MySQL databases to extract experimental data, execute statistical queries, and generate comprehensive analysis tables with t-tests, effect sizes, and p-values. Supports multiple database configurations dynamically.
Generates thesis-quality research reports using GPT-4o-mini to create AI-powered insights, statistical interpretations, and comprehensive analysis sections from experimental data.
Processes and analyzes experimental data for statistical computations, data transformations, and generation of analysis tables for research reports.
StatFlow
šÆ About This Project
StatFlow is a personal learning project built to understand and explore the Model Context Protocol (MCP). This project demonstrates how to build an MCP server that provides AI assistants with tools to interact with databases and generate reports.
Project Purpose: Learn MCP architecture, implement MCP servers, and understand how to expose functionality to AI assistants through standardized protocols.
š What is MCP?
Model Context Protocol (MCP) is an open protocol that enables AI assistants to securely access external tools and data sources. It provides a standardized way for AI applications to:
Call Tools: Execute functions or operations (like database queries, file operations)
Access Resources: Read-only access to data (like database tables, file contents)
Interact Securely: Controlled access to external systems without exposing credentials
Why MCP?
Standardized interface for AI-tool integration
Secure and controlled access to resources
Works with Claude Desktop, Cursor, and other MCP-compatible clients
Enables AI assistants to perform complex workflows autonomously
š Project Overview
StatFlow - MCP Server for Statistical Analysis & Report Generation
This MCP server demonstrates how to expose database analysis capabilities through MCP tools. It provides AI assistants with the ability to:
Extract data from multiple MySQL databases
Generate statistical analysis tables (t-tests, effect sizes, p-values)
Create formatted Excel reports with visual organization
Generate thesis-quality Word documents with AI-powered insights
Support unlimited databases through dynamic configuration
⨠MCP Server Features
MCP Tools (3 Tools)
StatFlow exposes three MCP tools that AI assistants can call:
run_complete_analysisšÆComplete workflow (DB ā Excel ā Report)
Handles entire analysis pipeline
Returns success status and file paths
generate_analysis_excelšDatabase ā Excel only
Fetches data and creates analysis tables
Returns Excel file path
generate_thesis_reportšExcel ā Thesis-quality report
Generates AI-powered Word document
Uses OpenAI for content generation
MCP Resources (1 Resource)
experimental_dataš¦Read-only access to database participant data
Returns JSON data without modifying database
Demonstrates MCP resource pattern
Key MCP Concepts Demonstrated
Tool Implementation: How to create MCP tools with parameters and return values
Resource Pattern: Read-only data access without side effects
Server Setup: Standard I/O communication with MCP clients
Error Handling: Proper error responses in MCP format
Dynamic Configuration: Loading database configs at runtime
Additional Features
AI-Powered Report Generation: Customizable writing style and terminology
Comprehensive Analysis: Statistical tables with t-tests, p-values, effect sizes
Flexible Architecture: Support for unlimited databases without code changes
Modular Design: Reusable query and analysis modules
š Quick Start
Installation
MCP Server Setup
To use StatFlow as an MCP server with Cursor or Claude Desktop:
Configure MCP Client (e.g.,
~/.cursor/mcp.json):
Restart your MCP client (Cursor/Claude Desktop)
Use with AI: Ask your AI assistant to use StatFlow tools, e.g., "Run complete analysis using StatFlow"
Configuration
Edit config.json (this file is not tracked in git - create your own):
Note: You can add unlimited databases (mysql_dump_3, mysql_dump_4, etc.) - StatFlow will automatically detect and use them.
š Usage
Option 1: Via MCP Server (Recommended)
Once configured, use StatFlow through your MCP-compatible AI assistant:
The AI assistant will call the appropriate MCP tools automatically.
Option 2: Direct Script Execution
Generate Excel file directly:
Output:
ā Excel file with comprehensive analysis tables
ā Statistical analysis tables (t-tests, averages, summaries)
ā Color-coded sections for easy navigation
Option 3: Programmatic Usage
š§ MCP Server Architecture
MCP Server Implementation
The server (src/statflow/server.py) implements:
MCP Server Class: Uses
mcp.server.Serverfrom the MCP Python SDKTool Handlers: Async functions that implement MCP tool logic
Resource Handlers: Read-only data access patterns
Standard I/O: Communication via stdio with MCP clients
MCP Tool Structure
Each tool follows the MCP pattern:
Key MCP Patterns Used
Tool Discovery:
@server.list_tools()decoratorTool Execution:
@server.call_tool()decoratorResource Access:
@server.list_resources()and@server.read_resource()Error Handling: Proper error responses in MCP format
Type Safety: Using MCP type definitions (
Tool,Resource,TextContent)
š Report Structure
The generated thesis report includes customizable sections. By default, it generates comprehensive analysis sections:
Time Analysis (~600-900 words)
Calculation methodology
Comparison across experimental conditions
Statistical significance testing
Overall patterns
Accuracy Analysis (~600-900 words)
Accuracy computation method
Performance comparisons
T-test results and interpretations
Key findings
Satisfaction Analysis (~600-900 words)
Satisfaction scoring methodology
Preference patterns
Statistical analysis
User experience insights
Group Comparison Analysis (~900-1200 words)
Performance by participant groups
Statistical differences
Comparative insights
Recommendations by group type
Overall Summary and Key Findings (~600-900 words)
Research question results
Key findings synthesized
Practical recommendations
Future directions
Total: ~3,000-5,500 words
Note: Section names and content are fully customizable via the prompts configuration file.
š§ Customization
Main Configuration File
Edit: src/statflow/analysis/thesis_quality_prompts.py
This file contains all AI instructions in plain English. You can:
Adjust word counts
Change writing style
Add custom instructions
Modify section structure
Update statistical reporting format
Example Customization
To change word count, edit line 32:
š Project Structure
š Output Files
Files are generated in the path specified in config.json (default: ./results)
File | Description |
| Comprehensive analysis tables with statistics |
| 3,000-5,500 word thesis-quality report |
š Excel File Contents
The Excel file includes:
Main Data Sheet
Participant/experimental unit data
Color-coded sections: User characteristics, Performance metrics, Satisfaction scores
AVERAGE row with summary statistics
Organized by experimental conditions/groups
Statistical Analysis Tables
T-Test tables: Comparative analysis across conditions
Average metrics: Performance comparisons by groups/categories
Overall summaries: Statistical comparisons
P-values and significance levels
AI Insights Sheet
Automated insights from AI analysis
Pattern identification
Data-driven recommendations
š ļø Requirements
Python: 3.8+
MySQL: Database server
OpenAI API: For thesis report generation (gpt-4o-mini)
Dependencies: Listed in
requirements.txt
Key Dependencies
š Documentation
Query Modules: See
src/statflow/queries/README.mdfor details on creating custom analysis modulesCustomization: Edit
src/statflow/analysis/thesis_quality_prompts.pyto customize report style and terminologyMCP Server: Use the StatFlow MCP server tools for programmatic access
š¬ Example Use Cases
StatFlow can be used for various experimental data analysis scenarios:
User Studies: Compare performance across different interfaces, conditions, or user groups
A/B Testing: Analyze results from experimental and control groups
Longitudinal Studies: Track changes over time across multiple measurement points
Comparative Analysis: Evaluate differences between multiple experimental conditions
Customization for Your Study
You can fully customize StatFlow for your specific research:
Update query modules in
src/statflow/queries/to match your data structureModify analysis prompts in
src/statflow/analysis/thesis_quality_prompts.pyto use your terminologyAdjust statistical analysis parameters to match your research design
š Key Benefits
Automation: Complete workflow from database to publication-ready reports
Flexibility: Customizable analysis modules and report structure
Scalability: Support for unlimited databases without code changes
Efficiency: Automated generation in minutes instead of hours
Quality: Thesis-level academic writing with AI-powered insights
Reproducibility: Consistent analysis pipeline for all your studies
š Support
For questions or issues:
Review
src/statflow/queries/README.mdfor query module documentationCheck
src/statflow/analysis/thesis_quality_prompts.pyfor report customizationExamine
config.jsonfor configuration options
š License
See LICENSE file for details.
š Learning Resources
MCP Documentation
MCP Specification: Model Context Protocol
MCP Python SDK: mcp Python Package
MCP Examples: Check the MCP repository for more examples
Key Learnings from This Project
This project demonstrates:
ā How to structure an MCP server
ā Implementing MCP tools with complex workflows
ā Using MCP resources for read-only data access
ā Error handling and validation in MCP servers
ā Dynamic tool/resource discovery
ā Integrating MCP servers with existing Python codebases
Example Use Case: CSU SSD Study
The codebase includes an example implementation customized for a research study (the "Improving the CSU Student Success Dashboard and Its Analysis" study). This demonstrates how StatFlow can be adapted for domain-specific needs while maintaining a flexible MCP architecture.
Note: This is a personal learning project, not affiliated with any institution.
š Project Status
Project Type: Personal Learning Project
Purpose: Learning and exploring Model Context Protocol (MCP)
Status: ā
Active and fully functional
Last Updated: November 12, 2025
Version: 2.0 (Renamed to StatFlow)
Created by: Rucha D. Nandgirikar
Note: This is a personal project for learning MCP, not affiliated with any institution or organization.
š¤ Author & Resources
Author: Rucha D. Nandgirikar
š Related Articles
š Medium Article - Coming Soon - Learn about building MCP servers with StatFlow
More articles and resources coming soon...
This server cannot be installed
hybrid server
The server is able to function both locally and remotely, depending on the configuration or use case.
Enables AI assistants to perform statistical analysis on MySQL databases, generating formatted Excel reports with t-tests and effect sizes, and creating thesis-quality Word documents with AI-powered insights.
- šÆ About This Project
- š What is MCP?
- š Project Overview
- ⨠MCP Server Features
- š Quick Start
- š Usage
- š§ MCP Server Architecture
- š Report Structure
- š§ Customization
- š Project Structure
- š Output Files
- š Excel File Contents
- š ļø Requirements
- š Documentation
- š¬ Example Use Cases
- š Key Benefits
- š Support
- š License
- š Learning Resources
- š Project Status
- š¤ Author & Resources