MCP Server for interacting with Kaggle API
Project description
Kaggle MCP (Model Context Protocol) Server
This repository contains an MCP (Model Context Protocol) server (server.py) built using the fastmcp library. It interacts with the Kaggle API to provide tools for searching and downloading datasets, and a prompt for generating EDA notebooks.
Project Structure
server.py: The FastMCP server application. It defines resources, tools, and prompts for interacting with Kaggle..env.example: An example file for environment variables (Kaggle API credentials). Rename to.envand fill in your details.requirements.txt: Lists the necessary Python packages.pyproject.toml&uv.lock: Project metadata and locked dependencies foruvpackage manager.datasets/: Default directory where downloaded Kaggle datasets will be stored.
Setup
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Create a virtual environment (recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate` # Or use uv: uv venv
-
Install dependencies: Using pip:
pip install -r requirements.txt
Or using uv:
uv sync -
Set up Kaggle API credentials:
- Method 1 (Recommended): Environment Variables
- Create
.envfile - Open the
.envfile and add your Kaggle username and API key:KAGGLE_USERNAME=your_kaggle_username KAGGLE_KEY=your_kaggle_api_key
- You can obtain your API key from your Kaggle account page (
Account>API>Create New API Token). This will download akaggle.jsonfile containing your username and key.
- Create
- Method 2:
kaggle.jsonfile- Download your
kaggle.jsonfile from your Kaggle account. - Place the
kaggle.jsonfile in the expected location (usually~/.kaggle/kaggle.jsonon Linux/macOS orC:\Users\<Your User Name>\.kaggle\kaggle.jsonon Windows). Thekagglelibrary will automatically detect this file if the environment variables are not set.
- Download your
- Method 1 (Recommended): Environment Variables
Running the Server
- Ensure your virtual environment is active.
- Run the MCP server:
uv run kaggle-mcp
The server will start and register its resources, tools, and prompts. You can interact with it using an MCP client or compatible tools.
Running the Docker Container
1. Set up Kaggle API credentials
This project requires Kaggle API credentials to access Kaggle datasets.
- Go to https://www.kaggle.com/settings and click "Create New API Token" to download your
kaggle.jsonfile. - Open the
kaggle.jsonfile and copy your username and key into a new.envfile in the project root:
KAGGLE_USERNAME=your_username
KAGGLE_KEY=your_key
2. Build the Docker image
docker build -t kaggle-mcp-test .
3. Run the Docker container using your .env file
docker run --rm -it --env-file .env kaggle-mcp-test
This will automatically load your Kaggle credentials as environment variables inside the container.
Server Features
The server exposes the following capabilities through the Model Context Protocol:
Tools
search_kaggle_datasets(query: str):- Searches for datasets on Kaggle matching the provided query string.
- Returns a JSON list of the top 10 matching datasets with details like reference, title, download count, and last updated date.
download_kaggle_dataset(dataset_ref: str, download_path: str | None = None):- Downloads and unzips files for a specific Kaggle dataset.
dataset_ref: The dataset identifier in the formatusername/dataset-slug(e.g.,kaggle/titanic).download_path(Optional): Specifies where to download the dataset. If omitted, it defaults to./datasets/<dataset_slug>/relative to the server script's location.
Prompts
generate_eda_notebook(dataset_ref: str):- Generates a prompt message suitable for an AI model (like Gemini) to create a basic Exploratory Data Analysis (EDA) notebook for the specified Kaggle dataset reference.
- The prompt asks for Python code covering data loading, missing value checks, visualizations, and basic statistics.
Connecting to Claude Desktop
Go to Claude > Settings > Developer > Edit Config > claude_desktop_config.json to include the following:
{
"mcpServers": {
"kaggle-mcp": {
"command": "kaggle-mcp",
"cwd": "<path-to-their-cloned-repo>/kaggle-mcp"
}
}
}
Usage Example
An AI agent or MCP client could interact with this server like this:
- Agent: "Search Kaggle for datasets about 'heart disease'"
- Server executes
search_kaggle_datasets(query='heart disease')
- Server executes
- Agent: "Download the dataset 'user/heart-disease-dataset'"
- Server executes
download_kaggle_dataset(dataset_ref='user/heart-disease-dataset')
- Server executes
- Agent: "Generate an EDA notebook prompt for 'user/heart-disease-dataset'"
- Server executes
generate_eda_notebook(dataset_ref='user/heart-disease-dataset') - Server returns a structured prompt message.
- Server executes
- Agent: (Sends the prompt to a code-generating model) -> Receives EDA Python code.
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 iflow_mcp_arrismo_kaggle_mcp-0.1.0.tar.gz.
File metadata
- Download URL: iflow_mcp_arrismo_kaggle_mcp-0.1.0.tar.gz
- Upload date:
- Size: 6.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a567bb6bdae797348b2276f0bf91a7eba7238e5c818752eb902f4e549b4abdd7
|
|
| MD5 |
73893acdb267d4666f58795991fbf9df
|
|
| BLAKE2b-256 |
5abaef7f35f1e6452907ec5582ae367aeeeaaa3a537977e7d2e78f1b4049b576
|
File details
Details for the file iflow_mcp_arrismo_kaggle_mcp-0.1.0-py3-none-any.whl.
File metadata
- Download URL: iflow_mcp_arrismo_kaggle_mcp-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.30 {"installer":{"name":"uv","version":"0.9.30","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
53766b33b0678e6f96464711d48fb7f57cf60e8c2d1c3355c6e1747a7561ee60
|
|
| MD5 |
cc5e94e259ed320817bef231df9f1014
|
|
| BLAKE2b-256 |
a62cb53ef078581ecf874ff0f559aa5438ec9c160aaf7dae2b8758219706a587
|