@mseep/csv-editor 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/ISSUE_TEMPLATE/bug_report.md +53 -0
- package/.github/ISSUE_TEMPLATE/feature_request.md +38 -0
- package/.github/workflows/deploy-docs.yml +62 -0
- package/.github/workflows/publish-github.yml +52 -0
- package/.github/workflows/publish.yml +44 -0
- package/.github/workflows/test.yml +32 -0
- package/.pre-commit-config.yaml +157 -0
- package/ALTERNATIVE_PUBLISHING.md +175 -0
- package/ARCHITECTURE.md +1011 -0
- package/CHANGELOG.md +99 -0
- package/CODE_OF_CONDUCT.md +41 -0
- package/CONTRIBUTING.md +427 -0
- package/Dockerfile +22 -0
- package/LICENSE +21 -0
- package/MCP_CONFIG.md +505 -0
- package/PUBLISHING.md +210 -0
- package/README.md +400 -0
- package/SECURITY.md +61 -0
- package/docs/README.md +41 -0
- package/docs/blog/2019-05-28-first-blog-post.md +12 -0
- package/docs/blog/2019-05-29-long-blog-post.md +44 -0
- package/docs/blog/2021-08-01-mdx-blog-post.mdx +24 -0
- package/docs/blog/2021-08-26-welcome/docusaurus-plushie-banner.jpeg +0 -0
- package/docs/blog/2021-08-26-welcome/index.md +29 -0
- package/docs/blog/authors.yml +25 -0
- package/docs/blog/tags.yml +19 -0
- package/docs/docs/api/overview.md +183 -0
- package/docs/docs/installation.md +252 -0
- package/docs/docs/intro.md +87 -0
- package/docs/docs/tutorial-basics/_category_.json +8 -0
- package/docs/docs/tutorial-basics/congratulations.md +23 -0
- package/docs/docs/tutorial-basics/create-a-blog-post.md +34 -0
- package/docs/docs/tutorial-basics/create-a-document.md +57 -0
- package/docs/docs/tutorial-basics/create-a-page.md +43 -0
- package/docs/docs/tutorial-basics/deploy-your-site.md +31 -0
- package/docs/docs/tutorial-basics/markdown-features.mdx +152 -0
- package/docs/docs/tutorial-extras/_category_.json +7 -0
- package/docs/docs/tutorial-extras/img/docsVersionDropdown.png +0 -0
- package/docs/docs/tutorial-extras/img/localeDropdown.png +0 -0
- package/docs/docs/tutorial-extras/manage-docs-versions.md +55 -0
- package/docs/docs/tutorial-extras/translate-your-site.md +88 -0
- package/docs/docs/tutorials/quickstart.md +365 -0
- package/docs/docusaurus.config.ts +163 -0
- package/docs/package-lock.json +17493 -0
- package/docs/package.json +48 -0
- package/docs/sidebars.ts +33 -0
- package/docs/src/components/HomepageFeatures/index.tsx +71 -0
- package/docs/src/components/HomepageFeatures/styles.module.css +11 -0
- package/docs/src/css/custom.css +30 -0
- package/docs/src/pages/index.module.css +23 -0
- package/docs/src/pages/index.tsx +44 -0
- package/docs/src/pages/markdown-page.md +7 -0
- package/docs/static/.nojekyll +0 -0
- package/docs/static/img/docusaurus-social-card.jpg +0 -0
- package/docs/static/img/docusaurus.png +0 -0
- package/docs/static/img/favicon.ico +0 -0
- package/docs/static/img/logo.svg +1 -0
- package/docs/static/img/undraw_docusaurus_mountain.svg +171 -0
- package/docs/static/img/undraw_docusaurus_react.svg +170 -0
- package/docs/static/img/undraw_docusaurus_tree.svg +40 -0
- package/docs/tsconfig.json +8 -0
- package/examples/README.md +48 -0
- package/examples/auto_save_demo.py +206 -0
- package/examples/auto_save_overwrite.py +201 -0
- package/examples/basic_usage.py +135 -0
- package/examples/demo.py +139 -0
- package/examples/history_demo.py +317 -0
- package/examples/test_default_autosave.py +124 -0
- package/examples/update_consignee_example.py +179 -0
- package/package.json +51 -0
- package/plans/2026-04-19-fastmcp3-migration-plan.md +1045 -0
- package/pyproject.toml +331 -0
- package/requirements-dev.txt +30 -0
- package/requirements.txt +22 -0
- package/scripts/publish.py +67 -0
- package/smithery.yaml +15 -0
- package/specs/2026-04-19-fastmcp3-migration-design.md +243 -0
- package/src/csv_editor/__init__.py +8 -0
- package/src/csv_editor/models/__init__.py +39 -0
- package/src/csv_editor/models/auto_save.py +246 -0
- package/src/csv_editor/models/csv_session.py +468 -0
- package/src/csv_editor/models/data_models.py +244 -0
- package/src/csv_editor/models/history_manager.py +456 -0
- package/src/csv_editor/prompts/__init__.py +0 -0
- package/src/csv_editor/prompts/data_prompts.py +13 -0
- package/src/csv_editor/resources/__init__.py +0 -0
- package/src/csv_editor/resources/csv_resources.py +22 -0
- package/src/csv_editor/server.py +640 -0
- package/src/csv_editor/tools/__init__.py +5 -0
- package/src/csv_editor/tools/analytics.py +700 -0
- package/src/csv_editor/tools/auto_save_operations.py +235 -0
- package/src/csv_editor/tools/data_operations.py +3 -0
- package/src/csv_editor/tools/history_operations.py +315 -0
- package/src/csv_editor/tools/io_operations.py +431 -0
- package/src/csv_editor/tools/transformations.py +663 -0
- package/src/csv_editor/tools/validation.py +822 -0
- package/src/csv_editor/utils/__init__.py +0 -0
- package/src/csv_editor/utils/validators.py +205 -0
- package/tests/README.md +65 -0
- package/tests/__init__.py +7 -0
- package/tests/conftest.py +50 -0
- package/tests/test_auto_save.py +378 -0
- package/tests/test_basic.py +103 -0
- package/tests/test_integration.py +356 -0
- package/tests/test_server_boot.py +50 -0
- package/tests/test_settings.py +184 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [2.0.0] - 2026-04-20
|
|
9
|
+
|
|
10
|
+
### BREAKING CHANGES
|
|
11
|
+
- **Python floor raised to 3.11.** Users on Python 3.8, 3.9, or 3.10 must upgrade. Users who pinned `csv-editor>=1,<2` are unaffected.
|
|
12
|
+
- **`--transport sse` CLI option removed.** Use `--transport http` (Streamable HTTP) for remote deployments. This aligns with the MCP 2025-11-25 spec and FastMCP 3 guidance that SSE is "backward compatibility only, shouldn't be used in new projects."
|
|
13
|
+
- **FastMCP dependency bumped to `>=3.2,<4`.** Any code importing FastMCP APIs transitively may require updates per the [FastMCP 3 upgrade guide](https://gofastmcp.com/getting-started/upgrading/from-fastmcp-2).
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- GitHub Actions `test.yml` workflow: pytest matrix on Python 3.11–3.14.
|
|
17
|
+
- `tests/test_server_boot.py` regression tests for server import, tool registry size, and CLI argument handling.
|
|
18
|
+
- Python 3.14 classifier and test coverage.
|
|
19
|
+
- Contributing guide: local virtualenv rebuild instructions.
|
|
20
|
+
- Design spec and implementation plan for the v2.0.0 migration under `specs/` and `plans/`.
|
|
21
|
+
|
|
22
|
+
### Changed
|
|
23
|
+
- Python floor: `>=3.10` → `>=3.11`.
|
|
24
|
+
- `fastmcp`: `>=2.11.3` → `>=3.2,<4` (resolved to 3.2.4).
|
|
25
|
+
- `pydantic`: `>=2.10.4` → `>=2.13`.
|
|
26
|
+
- `pydantic-settings`: `>=2.10.1` → `>=2.13`.
|
|
27
|
+
- `pyarrow`: `>=17.0.0` → `>=23`.
|
|
28
|
+
- `httpx`: `>=0.27.0` → `>=0.28`.
|
|
29
|
+
- `aiofiles`: `>=24.1.0` → `>=25`.
|
|
30
|
+
- `tabulate`: `>=0.9.0` → `>=0.10`.
|
|
31
|
+
- `black` target-version: `["py38", "py39", "py310", "py311", "py312", "py313"]` → `["py311", "py312", "py313"]` (black stable does not yet support `py314` as a target).
|
|
32
|
+
- `ruff` target-version: `py38` → `py311`.
|
|
33
|
+
- `mypy` python_version: `3.8` → `3.11`.
|
|
34
|
+
- Applied ruff `--fix` and `black` formatting across `src/` and `tests/` now that Python 3.11+ is the floor (large diff, no behavior change).
|
|
35
|
+
- Dockerfile base image pinned to `python:3.11-slim-bookworm`.
|
|
36
|
+
- `main()` signature: now accepts optional `argv: list[str] | None` for testability.
|
|
37
|
+
- README Python badge updated from `3.8+` to `3.11+`.
|
|
38
|
+
|
|
39
|
+
### Removed
|
|
40
|
+
- `--transport sse` CLI option.
|
|
41
|
+
- Python 3.8, 3.9, 3.10 classifier entries.
|
|
42
|
+
|
|
43
|
+
### Unchanged (deferred to follow-up release)
|
|
44
|
+
- `pandas>=2.2.3` and `numpy>=2.1.3`. Upgrading to pandas 3.0 (Copy-on-Write mandatory, Arrow-backed default string dtype) is deferred to a focused sub-project because the behavioral changes deserve dedicated test coverage.
|
|
45
|
+
|
|
46
|
+
## [1.0.1] - 2025-08-13
|
|
47
|
+
|
|
48
|
+
### Changed
|
|
49
|
+
- **Publishing strategy**: Switched to GitHub-based distribution due to PyPI naming conflicts
|
|
50
|
+
- **Installation method**: Primary installation now via `pip install git+https://github.com/santoshray02/csv-editor.git`
|
|
51
|
+
- **Package name**: Kept original `csv-editor` name
|
|
52
|
+
|
|
53
|
+
### Added
|
|
54
|
+
- Alternative publishing guide (ALTERNATIVE_PUBLISHING.md)
|
|
55
|
+
- GitHub Packages publishing workflow
|
|
56
|
+
- GitHub Releases automation
|
|
57
|
+
- Multiple installation methods for users
|
|
58
|
+
|
|
59
|
+
## [1.0.0] - 2025-08-13
|
|
60
|
+
|
|
61
|
+
### Added
|
|
62
|
+
- Initial release of CSV Editor MCP Server
|
|
63
|
+
- Core CSV operations: read, write, filter, transform
|
|
64
|
+
- Data validation and quality checks
|
|
65
|
+
- Statistical analysis and profiling capabilities
|
|
66
|
+
- Outlier detection and handling
|
|
67
|
+
- Support for multiple file formats (CSV, Excel, Parquet)
|
|
68
|
+
- Async operations for high performance
|
|
69
|
+
- Comprehensive error handling and logging
|
|
70
|
+
- FastMCP integration for seamless AI assistant integration
|
|
71
|
+
- Pandas-powered data manipulation
|
|
72
|
+
- Full test coverage with pytest
|
|
73
|
+
- Documentation with examples
|
|
74
|
+
- Type hints and mypy compatibility
|
|
75
|
+
|
|
76
|
+
### Features
|
|
77
|
+
- **File Operations**: Read/write CSV, Excel, Parquet files
|
|
78
|
+
- **Data Filtering**: Advanced filtering with multiple conditions
|
|
79
|
+
- **Data Transformation**: Column operations, data type conversions
|
|
80
|
+
- **Data Validation**: Schema validation, data quality checks
|
|
81
|
+
- **Statistical Analysis**: Descriptive statistics, correlation analysis
|
|
82
|
+
- **Outlier Detection**: Multiple algorithms (IQR, Z-score, Isolation Forest)
|
|
83
|
+
- **Data Profiling**: Comprehensive data profiling reports
|
|
84
|
+
- **Performance**: Optimized for large datasets with chunking support
|
|
85
|
+
- **AI Integration**: Seamless integration with Claude, ChatGPT, and other AI assistants
|
|
86
|
+
|
|
87
|
+
### Technical Details
|
|
88
|
+
- Python 3.10+ support
|
|
89
|
+
- Built with FastMCP framework
|
|
90
|
+
- Pandas and NumPy for data operations
|
|
91
|
+
- Pydantic for data validation
|
|
92
|
+
- Async/await support for non-blocking operations
|
|
93
|
+
- Comprehensive error handling
|
|
94
|
+
- Type-safe with mypy
|
|
95
|
+
- 100% test coverage
|
|
96
|
+
|
|
97
|
+
[2.0.0]: https://github.com/santoshray02/csv-editor/releases/tag/v2.0.0
|
|
98
|
+
[1.0.1]: https://github.com/santoshray02/csv-editor/releases/tag/v1.0.1
|
|
99
|
+
[1.0.0]: https://github.com/santoshray02/csv-editor/releases/tag/v1.0.0
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, color, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behavior that contributes to a positive environment:
|
|
10
|
+
|
|
11
|
+
* Demonstrating empathy and kindness toward other people
|
|
12
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
|
13
|
+
* Giving and gracefully accepting constructive feedback
|
|
14
|
+
* Accepting responsibility and apologizing to those affected by our mistakes
|
|
15
|
+
* Focusing on what is best for the overall community
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behavior include:
|
|
18
|
+
|
|
19
|
+
* The use of sexualized language or imagery, and sexual attention or advances
|
|
20
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
|
21
|
+
* Public or private harassment
|
|
22
|
+
* Publishing others' private information without explicit permission
|
|
23
|
+
* Other conduct which could reasonably be considered inappropriate
|
|
24
|
+
|
|
25
|
+
## Enforcement
|
|
26
|
+
|
|
27
|
+
Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.
|
|
32
|
+
|
|
33
|
+
## Enforcement
|
|
34
|
+
|
|
35
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at rayskumar02@gmail.com.
|
|
36
|
+
|
|
37
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
|
38
|
+
|
|
39
|
+
## Attribution
|
|
40
|
+
|
|
41
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1.
|
package/CONTRIBUTING.md
ADDED
|
@@ -0,0 +1,427 @@
|
|
|
1
|
+
# Contributing to CSV Editor
|
|
2
|
+
|
|
3
|
+
Thank you for your interest in contributing to CSV Editor! This guide will help you get started with contributing to the project.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
|
|
7
|
+
- [Code of Conduct](#code-of-conduct)
|
|
8
|
+
- [Getting Started](#getting-started)
|
|
9
|
+
- [Development Setup](#development-setup)
|
|
10
|
+
- [Development Workflow](#development-workflow)
|
|
11
|
+
- [Code Standards](#code-standards)
|
|
12
|
+
- [Testing](#testing)
|
|
13
|
+
- [Documentation](#documentation)
|
|
14
|
+
- [Submitting Changes](#submitting-changes)
|
|
15
|
+
- [Release Process](#release-process)
|
|
16
|
+
|
|
17
|
+
## Code of Conduct
|
|
18
|
+
|
|
19
|
+
By participating in this project, you agree to abide by our Code of Conduct:
|
|
20
|
+
|
|
21
|
+
- Be respectful and inclusive
|
|
22
|
+
- Welcome newcomers and help them get started
|
|
23
|
+
- Focus on constructive criticism
|
|
24
|
+
- Accept feedback gracefully
|
|
25
|
+
- Put the project's best interests first
|
|
26
|
+
|
|
27
|
+
## Getting Started
|
|
28
|
+
|
|
29
|
+
1. **Fork the repository** on GitHub
|
|
30
|
+
2. **Clone your fork** locally:
|
|
31
|
+
```bash
|
|
32
|
+
git clone https://github.com/santoshray02/csv-editor.git
|
|
33
|
+
cd csv-editor
|
|
34
|
+
```
|
|
35
|
+
3. **Add upstream remote**:
|
|
36
|
+
```bash
|
|
37
|
+
git remote add upstream https://github.com/santoshray02/csv-editor.git
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Development Setup
|
|
41
|
+
|
|
42
|
+
### Prerequisites
|
|
43
|
+
|
|
44
|
+
- Python 3.11 or higher (3.14 recommended)
|
|
45
|
+
- Git
|
|
46
|
+
- [uv](https://github.com/astral-sh/uv) - Ultra-fast package manager (required)
|
|
47
|
+
|
|
48
|
+
### Installation
|
|
49
|
+
|
|
50
|
+
#### Using uv (Required - 10-100x faster than pip)
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
# Install uv (if not already installed)
|
|
54
|
+
curl -LsSf https://astral.sh/uv/install.sh | sh
|
|
55
|
+
# Or on macOS: brew install uv
|
|
56
|
+
# Or with pip: pip install uv
|
|
57
|
+
|
|
58
|
+
# Clone and setup in one command!
|
|
59
|
+
uv sync --all-extras
|
|
60
|
+
|
|
61
|
+
# Install pre-commit hooks
|
|
62
|
+
uv run pre-commit install
|
|
63
|
+
|
|
64
|
+
# That's it! You're ready to go in seconds!
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
#### Alternative: Using pip (slower, not recommended)
|
|
68
|
+
|
|
69
|
+
```bash
|
|
70
|
+
# Create virtual environment
|
|
71
|
+
python -m venv .venv
|
|
72
|
+
source .venv/bin/activate # On Windows: .venv\Scripts\activate
|
|
73
|
+
|
|
74
|
+
# Install in development mode
|
|
75
|
+
pip install -e ".[dev,test,docs]"
|
|
76
|
+
|
|
77
|
+
# Install pre-commit hooks
|
|
78
|
+
pre-commit install
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Note**: We standardize on `uv` for all development. It's significantly faster and handles everything pip does plus more.
|
|
82
|
+
|
|
83
|
+
### Verify Installation
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
# All commands use uv
|
|
87
|
+
uv run server --help
|
|
88
|
+
uv run test
|
|
89
|
+
uv run lint
|
|
90
|
+
|
|
91
|
+
# Or use the shortcuts defined in uv.toml
|
|
92
|
+
uv run all-checks # Runs all quality checks
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Rebuilding the local virtualenv
|
|
96
|
+
|
|
97
|
+
If your `.venv/` points at a missing Python interpreter (common after upgrading Python or removing a conda env), rebuild it:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
rm -rf .venv
|
|
101
|
+
uv sync --all-extras
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
This requires Python 3.11+ available on your PATH (3.14 recommended).
|
|
105
|
+
|
|
106
|
+
## Development Workflow
|
|
107
|
+
|
|
108
|
+
### 1. Create a Feature Branch
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Update main branch
|
|
112
|
+
git checkout main
|
|
113
|
+
git pull upstream main
|
|
114
|
+
|
|
115
|
+
# Create feature branch
|
|
116
|
+
git checkout -b feature/your-feature-name
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### 2. Make Your Changes
|
|
120
|
+
|
|
121
|
+
Follow these guidelines:
|
|
122
|
+
|
|
123
|
+
- **One feature per PR** - Keep pull requests focused
|
|
124
|
+
- **Write tests** - All new features must have tests
|
|
125
|
+
- **Update docs** - Update README and docstrings as needed
|
|
126
|
+
- **Follow style guide** - Use Black, Ruff, and MyPy
|
|
127
|
+
|
|
128
|
+
### 3. Run Quality Checks
|
|
129
|
+
|
|
130
|
+
```bash
|
|
131
|
+
# All commands use uv for speed and consistency
|
|
132
|
+
uv run fmt # Format code with Black
|
|
133
|
+
uv run lint # Lint with Ruff
|
|
134
|
+
uv run type-check # Type check with MyPy
|
|
135
|
+
uv run all-checks # Run everything at once
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### 4. Test Your Changes
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
# Testing with uv
|
|
142
|
+
uv run test # Run all tests
|
|
143
|
+
uv run test-cov # Run with coverage report
|
|
144
|
+
uv run pytest tests/test_transformations.py # Run specific file
|
|
145
|
+
uv run pytest -k "test_filter" # Run tests matching pattern
|
|
146
|
+
uv run pytest -x # Stop on first failure
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## Code Standards
|
|
150
|
+
|
|
151
|
+
### Python Style
|
|
152
|
+
|
|
153
|
+
We use modern Python tooling for code quality:
|
|
154
|
+
|
|
155
|
+
- **Black** for code formatting (line length: 100)
|
|
156
|
+
- **Ruff** for linting (replaces flake8, isort, and more)
|
|
157
|
+
- **MyPy** for type checking
|
|
158
|
+
- **Pre-commit** for automated checks
|
|
159
|
+
|
|
160
|
+
### Code Guidelines
|
|
161
|
+
|
|
162
|
+
1. **Type Hints**: All functions must have type hints
|
|
163
|
+
```python
|
|
164
|
+
async def process_data(
|
|
165
|
+
session_id: str,
|
|
166
|
+
options: Dict[str, Any],
|
|
167
|
+
ctx: Optional[Context] = None
|
|
168
|
+
) -> Dict[str, Any]:
|
|
169
|
+
"""Process data with given options."""
|
|
170
|
+
...
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
2. **Docstrings**: Use Google-style docstrings
|
|
174
|
+
```python
|
|
175
|
+
def analyze_data(df: pd.DataFrame) -> Dict[str, Any]:
|
|
176
|
+
"""Analyze DataFrame and return statistics.
|
|
177
|
+
|
|
178
|
+
Args:
|
|
179
|
+
df: Input DataFrame to analyze
|
|
180
|
+
|
|
181
|
+
Returns:
|
|
182
|
+
Dictionary containing analysis results
|
|
183
|
+
|
|
184
|
+
Raises:
|
|
185
|
+
ValueError: If DataFrame is empty
|
|
186
|
+
"""
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
3. **Error Handling**: Use specific exceptions
|
|
190
|
+
```python
|
|
191
|
+
if not session:
|
|
192
|
+
raise ValueError(f"Session {session_id} not found")
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
4. **Async/Await**: Use async for all tool functions
|
|
196
|
+
```python
|
|
197
|
+
@mcp.tool
|
|
198
|
+
async def my_tool(param: str, ctx: Context) -> Dict[str, Any]:
|
|
199
|
+
result = await async_operation(param)
|
|
200
|
+
return {"success": True, "data": result}
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
5. **Logging**: Use appropriate log levels
|
|
204
|
+
```python
|
|
205
|
+
logger.debug("Processing row %d", row_num)
|
|
206
|
+
logger.info("Session %s created", session_id)
|
|
207
|
+
logger.warning("Large dataset: %d rows", row_count)
|
|
208
|
+
logger.error("Failed to load file: %s", error)
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### File Structure
|
|
212
|
+
|
|
213
|
+
```
|
|
214
|
+
src/csv_editor/
|
|
215
|
+
├── __init__.py # Package initialization
|
|
216
|
+
├── server.py # Main server entry point
|
|
217
|
+
├── models/ # Data models and schemas
|
|
218
|
+
│ ├── __init__.py
|
|
219
|
+
│ ├── csv_session.py # Session management
|
|
220
|
+
│ └── data_models.py # Pydantic models
|
|
221
|
+
├── tools/ # MCP tool implementations
|
|
222
|
+
│ ├── __init__.py
|
|
223
|
+
│ ├── io_operations.py
|
|
224
|
+
│ ├── transformations.py
|
|
225
|
+
│ ├── analytics.py
|
|
226
|
+
│ └── validation.py
|
|
227
|
+
├── resources/ # MCP resources
|
|
228
|
+
├── prompts/ # MCP prompts
|
|
229
|
+
└── utils/ # Utility functions
|
|
230
|
+
```
|
|
231
|
+
|
|
232
|
+
## Testing
|
|
233
|
+
|
|
234
|
+
### Test Structure
|
|
235
|
+
|
|
236
|
+
```
|
|
237
|
+
tests/
|
|
238
|
+
├── unit/ # Unit tests
|
|
239
|
+
│ ├── test_models.py
|
|
240
|
+
│ ├── test_transformations.py
|
|
241
|
+
│ └── test_analytics.py
|
|
242
|
+
├── integration/ # Integration tests
|
|
243
|
+
│ ├── test_server.py
|
|
244
|
+
│ └── test_workflows.py
|
|
245
|
+
├── benchmark/ # Performance tests
|
|
246
|
+
│ └── test_performance.py
|
|
247
|
+
└── fixtures/ # Test data
|
|
248
|
+
└── sample_data.csv
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
### Writing Tests
|
|
252
|
+
|
|
253
|
+
1. **Use pytest fixtures**:
|
|
254
|
+
```python
|
|
255
|
+
@pytest.fixture
|
|
256
|
+
async def session_with_data():
|
|
257
|
+
"""Create a session with sample data."""
|
|
258
|
+
manager = get_session_manager()
|
|
259
|
+
session_id = manager.create_session()
|
|
260
|
+
# ... setup
|
|
261
|
+
yield session_id
|
|
262
|
+
# ... cleanup
|
|
263
|
+
manager.remove_session(session_id)
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
2. **Test async functions**:
|
|
267
|
+
```python
|
|
268
|
+
@pytest.mark.asyncio
|
|
269
|
+
async def test_filter_rows(session_with_data):
|
|
270
|
+
result = await filter_rows(
|
|
271
|
+
session_id=session_with_data,
|
|
272
|
+
conditions=[{"column": "age", "operator": ">", "value": 18}]
|
|
273
|
+
)
|
|
274
|
+
assert result["success"]
|
|
275
|
+
assert result["rows_after"] < result["rows_before"]
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
3. **Use parametrize for multiple cases**:
|
|
279
|
+
```python
|
|
280
|
+
@pytest.mark.parametrize("dtype,expected", [
|
|
281
|
+
("int", True),
|
|
282
|
+
("float", True),
|
|
283
|
+
("str", False),
|
|
284
|
+
])
|
|
285
|
+
def test_is_numeric(dtype, expected):
|
|
286
|
+
assert is_numeric_dtype(dtype) == expected
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### Coverage Requirements
|
|
290
|
+
|
|
291
|
+
- Minimum coverage: 80%
|
|
292
|
+
- New features must have >90% coverage
|
|
293
|
+
- Run coverage: `hatch run test-cov`
|
|
294
|
+
|
|
295
|
+
## Documentation
|
|
296
|
+
|
|
297
|
+
### Docstring Standards
|
|
298
|
+
|
|
299
|
+
All public functions, classes, and modules must have docstrings:
|
|
300
|
+
|
|
301
|
+
```python
|
|
302
|
+
"""Module description.
|
|
303
|
+
|
|
304
|
+
This module provides functionality for X, Y, and Z.
|
|
305
|
+
"""
|
|
306
|
+
|
|
307
|
+
class DataProcessor:
|
|
308
|
+
"""Process CSV data with various transformations.
|
|
309
|
+
|
|
310
|
+
Attributes:
|
|
311
|
+
session_id: Unique session identifier
|
|
312
|
+
df: Pandas DataFrame containing the data
|
|
313
|
+
"""
|
|
314
|
+
|
|
315
|
+
def transform(
|
|
316
|
+
self,
|
|
317
|
+
operation: str,
|
|
318
|
+
**kwargs: Any
|
|
319
|
+
) -> pd.DataFrame:
|
|
320
|
+
"""Apply transformation to data.
|
|
321
|
+
|
|
322
|
+
Args:
|
|
323
|
+
operation: Name of the transformation
|
|
324
|
+
**kwargs: Additional parameters for the operation
|
|
325
|
+
|
|
326
|
+
Returns:
|
|
327
|
+
Transformed DataFrame
|
|
328
|
+
|
|
329
|
+
Raises:
|
|
330
|
+
ValueError: If operation is not supported
|
|
331
|
+
|
|
332
|
+
Examples:
|
|
333
|
+
>>> processor.transform("normalize", columns=["price"])
|
|
334
|
+
>>> processor.transform("fill_missing", strategy="mean")
|
|
335
|
+
"""
|
|
336
|
+
```
|
|
337
|
+
|
|
338
|
+
### Updating Documentation
|
|
339
|
+
|
|
340
|
+
1. **README.md**: Update for new features or breaking changes
|
|
341
|
+
2. **API Docs**: Ensure docstrings are complete
|
|
342
|
+
3. **Examples**: Add examples for new features
|
|
343
|
+
4. **Changelog**: Update CHANGELOG.md
|
|
344
|
+
|
|
345
|
+
## Submitting Changes
|
|
346
|
+
|
|
347
|
+
### Pull Request Process
|
|
348
|
+
|
|
349
|
+
1. **Update your branch**:
|
|
350
|
+
```bash
|
|
351
|
+
git fetch upstream
|
|
352
|
+
git rebase upstream/main
|
|
353
|
+
```
|
|
354
|
+
|
|
355
|
+
2. **Push to your fork**:
|
|
356
|
+
```bash
|
|
357
|
+
git push origin feature/your-feature-name
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
3. **Create Pull Request**:
|
|
361
|
+
- Go to GitHub and create a PR from your fork
|
|
362
|
+
- Use a clear, descriptive title
|
|
363
|
+
- Fill out the PR template
|
|
364
|
+
- Link related issues
|
|
365
|
+
|
|
366
|
+
### PR Template
|
|
367
|
+
|
|
368
|
+
```markdown
|
|
369
|
+
## Description
|
|
370
|
+
Brief description of changes
|
|
371
|
+
|
|
372
|
+
## Type of Change
|
|
373
|
+
- [ ] Bug fix
|
|
374
|
+
- [ ] New feature
|
|
375
|
+
- [ ] Breaking change
|
|
376
|
+
- [ ] Documentation update
|
|
377
|
+
|
|
378
|
+
## Testing
|
|
379
|
+
- [ ] Tests pass locally
|
|
380
|
+
- [ ] Added new tests
|
|
381
|
+
- [ ] Coverage maintained/improved
|
|
382
|
+
|
|
383
|
+
## Checklist
|
|
384
|
+
- [ ] Code follows style guidelines
|
|
385
|
+
- [ ] Self-review completed
|
|
386
|
+
- [ ] Documentation updated
|
|
387
|
+
- [ ] No new warnings
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Review Process
|
|
391
|
+
|
|
392
|
+
1. **Automated checks** must pass
|
|
393
|
+
2. **Code review** by at least one maintainer
|
|
394
|
+
3. **Address feedback** promptly
|
|
395
|
+
4. **Squash commits** if requested
|
|
396
|
+
|
|
397
|
+
## Release Process
|
|
398
|
+
|
|
399
|
+
### Version Numbering
|
|
400
|
+
|
|
401
|
+
We follow [Semantic Versioning](https://semver.org/):
|
|
402
|
+
- **MAJOR**: Breaking changes
|
|
403
|
+
- **MINOR**: New features (backward compatible)
|
|
404
|
+
- **PATCH**: Bug fixes
|
|
405
|
+
|
|
406
|
+
### Release Steps
|
|
407
|
+
|
|
408
|
+
1. **Update version** in `pyproject.toml`
|
|
409
|
+
2. **Update CHANGELOG.md**
|
|
410
|
+
3. **Create release PR**
|
|
411
|
+
4. **Tag release** after merge
|
|
412
|
+
5. **Publish to PyPI** (automated)
|
|
413
|
+
|
|
414
|
+
## Getting Help
|
|
415
|
+
|
|
416
|
+
- **Issues**: Use GitHub Issues for bugs and features
|
|
417
|
+
- **Discussions**: Use GitHub Discussions for questions
|
|
418
|
+
- **Discord**: Join our Discord server (link in README)
|
|
419
|
+
|
|
420
|
+
## Recognition
|
|
421
|
+
|
|
422
|
+
Contributors are recognized in:
|
|
423
|
+
- AUTHORS.md file
|
|
424
|
+
- Release notes
|
|
425
|
+
- Project README
|
|
426
|
+
|
|
427
|
+
Thank you for contributing to CSV Editor! 🎉
|
package/Dockerfile
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Generated by https://smithery.ai. See: https://smithery.ai/docs/build/project-config
|
|
2
|
+
FROM python:3.11-slim-bookworm
|
|
3
|
+
|
|
4
|
+
# Install system dependencies
|
|
5
|
+
RUN apt-get update && \
|
|
6
|
+
apt-get install -y --no-install-recommends gcc python3-dev && \
|
|
7
|
+
rm -rf /var/lib/apt/lists/*
|
|
8
|
+
|
|
9
|
+
# Set working directory
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
|
|
12
|
+
# Copy project files
|
|
13
|
+
COPY pyproject.toml requirements.txt README.md ./
|
|
14
|
+
COPY src/ src/
|
|
15
|
+
|
|
16
|
+
# Install Python dependencies and project
|
|
17
|
+
RUN pip install --no-cache-dir -r requirements.txt && \
|
|
18
|
+
pip install --no-cache-dir .
|
|
19
|
+
|
|
20
|
+
# Default command
|
|
21
|
+
ENV PYTHONUNBUFFERED=1
|
|
22
|
+
CMD ["csv-editor", "--transport", "stdio"]
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Santosh Ray
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|