Skip to main content

Rostaing's Model Content Protocol (rostaing-mcp)

PyPI version Python versions License Downloads

A universal Model Content Protocol (MCP) for Pandas and Polars DataFrames, designed to be used as a powerful tool by Large Language Models (LLMs) like GPT-4, Claude, and Mistral.

This package allows LLMs to interact securely with data, performing advanced tasks ranging from simple filtering to statistical hypothesis testing and data visualization (returning viewable images).

Key Features

  • Library Agnostic: Seamlessly handles pandas and polars DataFrames.
  • Visual Intelligence: Generates Plotly charts returning Base64 PNG images, allowing LLMs to "see" and generate charts.
  • Statistical Suite: Built-in support for T-tests, ANOVA, Chi-Squared, Normality tests (Shapiro), and Survival Analysis (Logrank).
  • Smart NLU (Fuzzy Matching): Automatically corrects typos in column names (e.g., understands that "salary" refers to "Salary_USD").
  • Stateful Analysis: Filters and modifications persist within the agent's session context.

Installation

pip install rostaing-mcp

Note: This will also install necessary dependencies like plotly, kaleido (for image generation), pingouin, and scipy.

Quick Start

import pandas as pd
from rostaing_mcp import DataFrameAgent, DataFrameToolHandler

# 1. Create a sample DataFrame
data = {
    'employee_name': ['Rostaing', 'Lucrèce', 'Isnard', 'Charline', 'Dacier', 'Nora'],
    'salary': [100000, 70000, 85000, 60000, 95000, 62000],
    'experience_level': ['Expert', 'Senior', 'Manager', 'Junior', 'Principal', 'Mid-Level'],
    'department': ['AI', 'Sales', 'AI', 'Sales', 'AI', 'Sales']
}
df = pd.DataFrame(data)

# 2. Initialize the core agent (Works with Polars too!)
data_agent = DataFrameAgent(df, source_description="Employee salary data")

# 3. Wrap it in the tool handler
df_tool = DataFrameToolHandler(data_agent)

# --- EXAMPLES OF DIRECT USAGE ---

# A. Inspect Data
print(df_tool.get_schema())

# B. Statistical Test (e.g., T-test between groups)
# Note: Handles fuzzy matching if you type 'Department' instead of 'department'
print(df_tool.perform_t_test(a='salary', group='department')) 

# C. Visualization (Returns Base64 Image string)
# The LLM can call this to generate a chart
image_data = df_tool.plot_bar_chart(x='employee_name', y='salary', color='department')
print("Chart generated successfully (Base64 data ready).")

Integration with LLM Agents (e.g., Upsonic, LangChain)

To let an LLM use all available tools, you can pass the methods dynamically or wrap them in a proxy class.

from upsonic import Agent, Task

# Get the list of all callable tools for the LLM
tools_list = df_tool.get_all_tools() 

task = Task(
    description="Analyze the salary distribution and plot a bar chart by department.",
    tools=tools_list
)

agent = Agent(model="openai/gpt-4o", name="Data Analyst")
result = agent.do(task)
print(result)

Available Tools

📊 Visualization

  • plot_histogram, plot_bar_chart, plot_line_chart
  • plot_scatter_plot, plot_box_plot, plot_violin_plot
  • plot_heatmap, plot_pie_chart, plot_3d_scatter, and more.

🧮 Statistics

  • get_summary_statistics, get_correlation_matrix
  • perform_normality_test (Shapiro-Wilk)
  • perform_t_test (Student's t-test)
  • perform_anova (One-way ANOVA)
  • perform_chi2_test (Independence)
  • perform_logrank_test (Survival analysis)

🛠 Manipulation

  • filter_rows (Complex conditions supported)
  • sort_values
  • select_columns

Useful Links

Metadata

Release files for rostaing-mcp 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rostaing-mcp 0.1.1
File Size Uploaded
rostaing_mcp-0.1.1.tar.gz 14.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rostaing-mcp 0.1.1
File Interpreter ABI Platform
rostaing_mcp-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 27.1 kB

Release files / rostaing_mcp-0.1.1.tar.gz

Download URL rostaing_mcp-0.1.1.tar.gz
Size 14.6 kB
Tags Source
SHA-256 checksum
How to use checksums
cbad9a596607501d755323a7db9dcc84591b3b083f8d80c26a3aa131abc37cf2
BLAKE2b-256 checksum
How to use checksums
2958447a0c124ed2489d1ff549ea45dbc6824e22d272fbf7e8e474962672dc80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release files / rostaing_mcp-0.1.1-py3-none-any.whl

Download URL rostaing_mcp-0.1.1-py3-none-any.whl
Size 12.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5920ab4e5409b503b1dbb11ed334494d90817ab30691999c4d646df0793e8b12
BLAKE2b-256 checksum
How to use checksums
cf6f12d28bedfc594aee65ae6ece00926ee64af4b881b69fe56e830b6bcf80cd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.9

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page