Linear Regression MCP is a tool that demonstrates an end-to-end machine learning workflow using Claude and the Model Context Protocol (MCP). With this server, Claude can train a Linear Regression model by itself by simply uploading a CSV file. The system handles the entire ML model training lifecycle including data preprocessing, training, and evaluation.
First, clone the repository to your local machine:
git clone https://github.com/HeetVekariya/Linear-Regression-MCP
cd Linear-Regression-MCP
The project requires uv
, a fast Python package and project manager written in Rust:
uv
from https://docs.astral.sh/uv/#installationOnce uv is installed, run the following command to install all necessary dependencies:
uv sync
To integrate the server with Claude Desktop, modify the Claude configuration file:
For macOS or Linux:
code ~/Library/Application\ Support/Claude/claude_desktop_config.json
For Windows:
code $env:AppData\Claude\claude_desktop_config.json
In the configuration file, update the mcpServers
section with absolute paths to your uv
installation and the Linear Regression project directory:
{
"mcpServers":
{
"linear-regression":
{
"command": "ABSOLUTE/PATH/TO/.local/bin/uv",
"args":
[
"--directory",
"ABSOLUTE/PATH/TO/YOUR-LINEAR-REGRESSION-REPO",
"run",
"server.py"
]
}
}
}
After saving the file, restart Claude Desktop to connect with the MCP server.
The following tools are available to work with datasets and train models:
Tool | Description | Arguments |
---|---|---|
upload_file(path) |
Uploads a CSV file for processing | path : Absolute path to the CSV file |
get_columns_info() |
Retrieves column names in the uploaded dataset | None |
check_category_columns() |
Identifies categorical columns in the dataset | None |
label_encode_categorical_columns() |
Converts categorical columns to numerical values | None |
train_linear_regression_model(output_column) |
Trains a linear regression model and calculates RMSE | output_column : Name of the target column |
To add this MCP server to Claude Code, run this command in your terminal:
claude mcp add-json "linear-regression" '{"command":"ABSOLUTE/PATH/TO/.local/bin/uv","args":["--directory","ABSOLUTE/PATH/TO/YOUR-LINEAR-REGRESSION-REPO","run","server.py"]}'
See the official Claude Code MCP documentation for more details.
There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json
file so that it is available in all of your projects.
If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json
file.
To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".
When you click that button the ~/.cursor/mcp.json
file will be opened and you can add your server like this:
{
"mcpServers": {
"linear-regression": {
"command": "ABSOLUTE/PATH/TO/.local/bin/uv",
"args": [
"--directory",
"ABSOLUTE/PATH/TO/YOUR-LINEAR-REGRESSION-REPO",
"run",
"server.py"
]
}
}
}
To add an MCP server to a project you can create a new .cursor/mcp.json
file or add it to the existing one. This will look exactly the same as the global MCP server example above.
Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.
The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.
You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.
To add this MCP server to Claude Desktop:
1. Find your configuration file:
~/Library/Application Support/Claude/claude_desktop_config.json
%APPDATA%\Claude\claude_desktop_config.json
~/.config/Claude/claude_desktop_config.json
2. Add this to your configuration file:
{
"mcpServers": {
"linear-regression": {
"command": "ABSOLUTE/PATH/TO/.local/bin/uv",
"args": [
"--directory",
"ABSOLUTE/PATH/TO/YOUR-LINEAR-REGRESSION-REPO",
"run",
"server.py"
]
}
}
}
3. Restart Claude Desktop for the changes to take effect