134 Commits

Author SHA1 Message Date
Nitzan Pomerantz fd79ea88bf Fix test_parse_deal_dates_basic temporal assertion
Adjusted sample_deals fixture to ensure 5 deals across 5 distinct months.
Previous dates collapsed into 3 months due to naive 30-day calculations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-15 00:08:42 +02:00
Nitzan Pomerantz 865aae1b73 Fix autocomplete non-determinism causing 0 deals
Autocomplete returns different coordinates for vague queries (e.g. "תל אביב דיזנגוף"),
sometimes landing on points with no nearby polygon_ids within 30m radius.

- Try top 3 autocomplete results until one has polygons
- Fallback radius expansion (30m→200m) if no polygons found
- Fix limit validation bug (min 1 for deal queries)

Fixes: compare_addresses, get_valuation_comparables, get_deal_statistics

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-14 23:48:12 +02:00
Nitzan Pomerantz 58c55f14a7 Merge pull request #8 from nitzpo/phase-6
Examples and code quality
2025-10-31 19:13:42 +02:00
Nitzan Pomerantz 5dd776ce40 Update CONTRIBUTING.md
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-31 19:12:52 +02:00
Nitzan Pomerantz 02e69b6d3b Ran ruff format etc. 2025-10-31 19:02:33 +02:00
Nitzan Pomerantz 6d2b1ab4ab Update code quality for vscode 2025-10-31 19:02:21 +02:00
Nitzan Pomerantz 280b0c9b1c Continue phase 6 2025-10-31 18:41:48 +02:00
Nitzan Pomerantz 739d4f8578 Examples and code quality 2025-10-31 00:31:14 +02:00
Nitzan Pomerantz e4aa6487ff Ruff fixes 2025-10-30 22:24:40 +02:00
Nitzan Pomerantz a80b38047c Phase 7 - Get ready with pre commit stuff 2025-10-30 22:21:08 +02:00
Nitzan Pomerantz 6632ac1669 Fix failing tests again 2025-10-30 20:54:18 +02:00
Nitzan Pomerantz 9dbfca459b Organize and cleaup 2025-10-30 20:47:02 +02:00
Nitzan Pomerantz c5ea39ef00 Fix failing test 2025-10-30 20:33:21 +02:00
Nitzan Pomerantz 85f48e1545 Merge pull request #7 from nitzpo/phase-5
Phase 5
2025-10-30 20:27:02 +02:00
Nitzan Pomerantz 67a17b022d Remove irrelevant code as per gemini cr 2025-10-30 20:25:14 +02:00
Nitzan Pomerantz bdfc5e3d3e Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-30 20:18:09 +02:00
Nitzan Pomerantz 04a1e68604 Phase 5 2025-10-30 18:26:48 +02:00
Nitzan Pomerantz ae7f7f51c5 Finalize phase 4.1 2025-10-28 00:58:43 +02:00
Nitzan Pomerantz 3478426006 Fix too many polygons issue 2025-10-27 23:58:57 +02:00
Nitzan Pomerantz a234e809bf Testing update 2025-10-27 23:33:09 +02:00
Nitzan Pomerantz 247ddad8cd CRITICAL FIX: get_deals_by_radius returns polygon metadata, not deals
## Root Cause
After Pydantic migration, get_deals_by_radius() was attempting to validate
API responses as Deal objects. However, this endpoint returns POLYGON METADATA
(with fields: dealscount, polygon_id, settlementNameHeb), NOT individual deals.

All responses failed Pydantic validation (missing dealAmount, dealDate),
resulting in empty lists and 0 deals returned from ALL queries.

## Fixes Applied

### 1. client.py - get_deals_by_radius()
- Return type: `List[Deal]` → `List[Dict[str, Any]]`
- Remove Pydantic validation - return raw metadata dicts
- Update docstring to clarify this returns polygon metadata
- Add note to use find_recent_deals_for_address() for actual deals

### 2. client.py - find_recent_deals_for_address()
- Update to handle polygon metadata dicts (not Deal objects)
- Use dict.get('polygon_id') instead of model attribute access
- Rename variable: `nearby_deals` → `nearby_polygons` for clarity

### 3. fastmcp_server.py - get_deals_by_radius() tool
- Update to handle dict responses (not Deal objects)
- Remove strip_bloat_fields() call (not needed for metadata)
- Update docstring with WARNING about polygon metadata
- Change response keys: "deals" → "polygons", "total_deals" → "total_polygons"

### 4. Tests
- test_govmap_client.py: Update to expect dicts, not Deal objects
- test_fastmcp_tools.py: Update 3 tests to mock dict responses

## Impact
-  find_recent_deals_for_address() NOW WORKS (was returning 0 deals)
-  All 174 tests passing
-  E2E API test confirmed working with real data

## API Behavior Documented
get_deals_by_radius endpoint design:
1. Returns polygon/area metadata (not individual deals)
2. Extract polygon_ids from metadata
3. Call get_street_deals(polygon_id) to get actual deals
4. This workflow is automated in find_recent_deals_for_address()

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-27 09:38:21 +02:00
Nitzan Pomerantz d8259ae2cf Merge pull request #5 from nitzpo/phase-4-1
Implementation of phase 4.1
2025-10-27 00:00:25 +02:00
Nitzan Pomerantz 0a6f1490be Update memory 2025-10-26 23:58:41 +02:00
Nitzan Pomerantz 28f64da754 Update TASKS.md - mark Phase 4.1 as complete
Phase 4.1 (Pydantic Data Models) is now 100% complete:
- 9 Pydantic v2 models created
- All functions updated to use/return models
- 174/174 tests passing
- Breaking change: v2.0.0 released

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 23:56:29 +02:00
Nitzan Pomerantz ff8c7e6509 Complete Phase 4.1 test suite updates - all 174 tests passing
Fixed all remaining test failures after Pydantic v2 migration:

Core fixes:
- Date handling: Convert date objects to ISO strings across 4 files
- Model serialization: Use model_dump(mode='json') for JSON compatibility
- Optional fields: Made time_period_months Optional[int] in models
- Dict access: Replace .get() with getattr() for dynamic attributes

Test updates:
- Updated 50+ test fixtures from dicts to Deal models
- Fixed date-based tests to use recent dates for time filtering
- Added missing imports (CoordinatePoint, MarketActivityScore, DealStatistics)
- Updated assertions from dict keys to model attributes (snake_case)

Files modified:
- nadlan_mcp/govmap/market_analysis.py
- nadlan_mcp/govmap/statistics.py
- nadlan_mcp/govmap/models.py
- nadlan_mcp/fastmcp_server.py
- tests/test_govmap_client.py
- tests/test_fastmcp_tools.py
- .cursor/plans/TEST-UPDATE-STATUS.md (comprehensive documentation)

Result: 174/174 tests passing (100%) 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-26 23:55:42 +02:00
Nitzan Pomerantz 34af8362b9 CR fixes 2025-10-26 23:26:31 +02:00
Nitzan Pomerantz bad0810053 Merge branch 'main' into phase-4-1 2025-10-26 23:21:54 +02:00
Nitzan Pomerantz bcb61a96ff Merge pull request #6 from nitzpo/add-claude-github-actions-1761513447533
Add Claude Code GitHub Workflow
2025-10-26 23:18:27 +02:00
Nitzan Pomerantz c77b4a1b86 "Claude Code Review workflow" 2025-10-26 23:17:30 +02:00
Nitzan Pomerantz 9c7cf9df19 "Claude PR Assistant workflow" 2025-10-26 23:17:28 +02:00
Nitzan Pomerantz 144eb552aa Cr fix - error catching
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-26 23:07:04 +02:00
Nitzan Pomerantz 0ac9d136cd Implementation of phase 4.1 2025-10-26 10:58:46 +02:00
Nitzan Pomerantz 4cb70c547b Updated status in TASKS.md 2025-10-26 09:54:13 +02:00
Nitzan Pomerantz 8a0ede678c Merge pull request #4 from nitzpo/phase-3
Phase 3: Refactor govmap.py into modular package
2025-10-25 14:11:19 +03:00
Nitzan Pomerantz 48bfb00628 CR fix 2025-10-25 14:01:53 +03:00
Nitzan Pomerantz c87750f57f Fix median calculation
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-25 13:57:25 +03:00
Nitzan Pomerantz 39266ea6e4 Add comprehensive unit tests for Phase 3 refactoring
Test Coverage Expansion:
- Increased from 34 to 138 tests (+304% improvement)
- All tests passing in 0.50s

New Test Files:
1. tests/govmap/test_validators.py (32 tests)
   - Complete coverage for address validation
   - Coordinate validation with ITM bounds checking
   - Positive integer validation with edge cases
   - Deal type validation

2. tests/govmap/test_utils.py (36 tests)
   - Distance calculation tests (Euclidean, diagonal, symmetric)
   - Address matching tests (case sensitivity, substring matching)
   - Comprehensive Hebrew floor parsing (all 12 Hebrew floor names)
   - Edge cases for floor extraction

3. tests/test_fastmcp_tools.py (36 tests)
   - E2E tests for all 10 MCP tools
   - Tests correct JSON formatting
   - Tests bloat field stripping
   - Tests error handling
   - Tests edge cases (no results, invalid input)

Test Quality:
- All edge cases covered
- Hebrew floor names: קרקע, מרתף, ראשונה-עשירית
- Mock-based for fast execution
- Clear test names and documentation

Updated Documentation:
- Updated TEST_COVERAGE_REPORT.md with new test statistics
- Documented all test categories and coverage

Result: Comprehensive test coverage across all refactored modules

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:55:37 +03:00
Nitzan Pomerantz 4d9febf527 Fix autocomplete_address bug and add test coverage report
Bug Fix:
- Fixed autocomplete_address tool to use correct API response fields
- Changed from non-existent fields (addressLabel, settlementNameHeb, coordinates)
  to actual API fields (text, id, type, score, shape)
- Added coordinate parsing from WKT POINT format
- Impact: HIGH - tool was returning empty data for all fields

Test Coverage Report:
- Added comprehensive test coverage analysis
- Documented 34 passing tests
- Identified e2e test results for MCP tools
- Listed missing test cases and recommendations
- Overall assessment: Good coverage, one bug found and fixed

E2E Test Results:
-  find_recent_deals_for_address - WORKING
-  analyze_market_trends - WORKING
-  get_valuation_comparables - WORKING
-  autocomplete_address - FIXED (needs MCP server restart to take effect)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:45:52 +03:00
Nitzan Pomerantz 5ad5994dfc Add local config files to .gitignore
- .claude/ - Claude Code workspace directory
- .mcp.json - User-specific MCP configuration
- PHASE3-PLAN-SUMMARY.md - Temporary planning document

These files contain local paths and should not be tracked in version control.
2025-10-25 13:33:40 +03:00
Nitzan Pomerantz b7383950fd Update documentation to reflect Phase 3 refactoring completion
Updated ARCHITECTURE.md:
- Changed govmap.py section to govmap/ package section
- Updated architecture diagram to show modular package structure
- Marked Phase 3 as completed ()
- Listed all package modules and their responsibilities

Updated CLAUDE.md:
- Updated Business Logic Layer description with package structure
- Updated Key Files section with new modular package details
- Updated development roadmap to show Phase 3 as complete
- Updated "Adding New API Endpoint Support" instructions
- Updated "Important Notes for AI Agents" with package info
- Changed test count from 27 to 34 tests (all passing)

All documentation now reflects the completed modular refactoring
while emphasizing backward compatibility.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:24:13 +03:00
Nitzan Pomerantz ab19d86b63 Phase 3: Remove old monolithic govmap.py file (step 3/3)
All functionality has been extracted to the govmap package:
- validators.py - Input validation functions
- utils.py - Utility functions
- filters.py - Deal filtering logic
- statistics.py - Statistical calculations
- market_analysis.py - Market analysis functions
- client.py - GovmapClient class with API methods
- __init__.py - Package exports

Backward compatibility maintained through package __init__.py exports.
Existing imports like `from nadlan_mcp.govmap import GovmapClient` now
use the govmap package instead of the old monolithic file.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:21:17 +03:00
Nitzan Pomerantz 7757694077 Phase 3: Complete govmap package extraction (step 2/3)
- Created market_analysis.py with market analysis functions:
  - parse_deal_dates() - Date parsing and filtering helper
  - calculate_market_activity_score() - Activity metrics
  - analyze_investment_potential() - Investment analysis
  - get_market_liquidity() - Liquidity metrics

- Created client.py with GovmapClient class:
  - Core API methods (autocomplete, get deals, etc.)
  - Validation methods delegating to validators module
  - Utility methods delegating to utils module
  - Filtering, statistics, and analysis methods delegating to respective modules

- Updated govmap/__init__.py to export GovmapClient

All modules maintain backward compatibility through delegation pattern.
Next: Delete old govmap.py and update imports.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:18:19 +03:00
Nitzan Pomerantz b565c7fb08 Phase 3: Create govmap package structure (step 1/3)
Created modular package structure:
- validators.py: Input validation functions (3 functions, ~100 lines)
- utils.py: Helper utilities (3 functions, ~140 lines)
- filters.py: Deal filtering logic (1 main function, ~140 lines)
- statistics.py: Statistical calculations (2 functions, ~130 lines)

All functions extracted from monolithic govmap.py as pure functions.
Next: Extract market analysis and create client.py with API methods.

Part of Phase 3 refactoring - no functionality changes yet.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 13:06:48 +03:00
Nitzan Pomerantz f5e0605393 Add GitHub Actions CI workflow for PR testing
- Runs unit tests with pytest on Python 3.12
- Only triggers on PRs to main branch
- Includes code coverage reporting (non-blocking)
- Lint checks for code quality (non-blocking)
- Integration tests are optional and non-blocking

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 00:53:48 +03:00
Nitzan Pomerantz 433642117d Merge pull request #3 from nitzpo/e2e-run
Fix: E2E bugs from real-world MCP testing
2025-10-25 00:44:35 +03:00
Nitzan Pomerantz fde0afa7a1 Apply suggestion from @gemini-code-assist[bot]
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-25 00:43:26 +03:00
Nitzan Pomerantz 8be71aec55 Update tests/test_govmap_client.py
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
2025-10-25 00:41:24 +03:00
Nitzan Pomerantz b62815ec08 Fix: Strip bloat fields to resolve MCP token limit issues
Problem:
- get_valuation_comparables failed with 61,565 tokens (exceeded 25K MCP limit)
- Large MULTIPOLYGON shape data consumed ~40-50% of response tokens
- Not useful for LLM analysis, only bloating responses

Solution:
1. Added strip_bloat_fields() helper to remove:
   - shape: Large coordinate data
   - sourceorder: Internal ordering field
   - source_polygon_id: Internal reference field

2. Applied to 5 MCP tools returning deal data:
   - get_deals_by_radius
   - get_street_deals
   - find_recent_deals_for_address
   - get_neighborhood_deals
   - get_valuation_comparables

3. Reduced get_valuation_comparables default max_comparables: 200 → 50

Results:
- Token usage reduced by ~87% (61K → ~7-8K tokens)
- All tools now work within MCP token limits
- Cleaner, more efficient responses
- No loss of useful data for LLM analysis

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 00:40:31 +03:00
Nitzan Pomerantz ee0b9466d4 Fix: Critical filtering bugs - missing data handling
Fixed two critical bugs in filter_deals_by_criteria():

Bug #1: CRASH on None property type
- Issue: Code called .lower() on None when propertyTypeDescription was null
- Impact: Would crash MCP tool in production with incomplete data
- Fix: Check if deal_type is None/empty before calling .lower()

Bug #2: Missing data passes through filters
- Issue: Deals with None/missing values passed filters when they shouldn't
- Example: Filtering by area=60-70 would include deals with assetArea=None
- Impact: get_valuation_comparables returned inflated results with bad data
- Fix: Explicitly check for None when filter is active and exclude those deals

Changes:
- Property type filter: Check for None/empty before normalization
- Area filter: Exclude deals with missing area when min/max_area specified
- Room filter: Exclude deals with missing rooms when min/max_rooms specified
- Price filter: Exclude deals with missing price when min/max_price specified
- Invalid data: Changed from 'pass' to 'continue' to exclude bad data

Added 6 comprehensive unit tests:
- test_filter_excludes_missing_property_type
- test_filter_excludes_missing_area
- test_filter_excludes_missing_rooms
- test_filter_excludes_missing_price
- test_filter_excludes_invalid_numeric_data
- test_filter_allows_missing_data_when_no_filter

This fixes the E2E issue where get_valuation_comparables was returning
incomplete results. Now filters properly exclude deals with missing data.

Test results: 34/34 passing (6 new tests added)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-25 00:08:05 +03:00
Nitzan Pomerantz c19af4cd4e Fix: Resolve 2 pre-existing test failures
Fixed both failing tests for 100% test coverage (28/28 passing):

Test 1: test_client_initialization_with_custom_url
- Issue: Test was passing string to GovmapClient constructor
- Fix: Import GovmapConfig and create proper config object
- Changes: Added import and wrapped custom_url in GovmapConfig

Test 2: test_find_recent_deals_for_address_integration
- Issue: Test expected date-first sorting, but function sorts by priority first
- Fix: Updated test expectations to match actual business logic
- Behavior: Results sorted by source priority (building > street > neighborhood), then date
- Changes: Added priority field to mock data and fixed assertions

All 28 tests now passing 

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-24 23:53:54 +03:00