agentleFS
tae0ytae0y/real-estate-mcp/CLAUDE.md

real-estate-mcp

CLAUDE.md378 starsChanged 9 months agoMITView on GitHub

MCP server exposing Korea's MOLIT (국토교통부) real estate transaction API to Claude Desktop. The server wraps XML endpoints from apis.data.go.kr and api.odcloud.kr, providing tools for querying apartment, officetel, villa, single-house, commercial trade/rent data, and APT subscription info. Requires DATA_GO_KR_API_KEY from 공공데이터포털 in a .env file at the project root. MCP tools are spread across modules under src/real_estate/mcp_server/: Request flow for any trade/rent tool: 1. _check_api_key() — guard: fails fast if env var is missing 2. _build_url() — constructs URL with…

  • Reads credentials

The file

We split this CLAUDE.md into the rules it gives an agent

3 rules. About 0 are common, 1 is distinctive, and 2 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 2

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    All URL constants (_ODCLOUD_*, etc.) are defined in _helpers.py.

    line 67
  2. Distinctive:

    Call this when the user asks about recent transactions without specifying a period

    line 84
  3. Very specific:

    Test classes follow the pattern: unit tests for parsers and helpers (no mock needed) + integration tests using @respx.mock + …

    line 95

≈ “Common” is an estimate: at least 1 in 5 of the 12,729 CLAUDE.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
CLAUDE.md

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

MCP server exposing Korea's MOLIT (국토교통부) real estate transaction API to Claude Desktop. The server wraps XML endpoints from apis.data.go.kr and api.odcloud.kr, providing tools for querying apartment, officetel, villa, single-house, commercial trade/rent data, and APT subscription info.

Requires DATA_GO_KR_API_KEY from 공공데이터포털 in a .env file at the project root.

Commands

# Run all tests (requires .env with valid key, or monkeypatched key)
uv run pytest

# Run a single test file
uv run pytest tests/mcp_server/test_apartment_trades.py

# Run a single test by name
uv run pytest tests/mcp_server/test_apartment_trades.py::TestParseAptTrades::test_normal_response_returns_items

# Lint + format (auto-fix)
uv run ruff check --fix && uv run ruff format

# Type check
uv run pyright

# Security scan
uv run bandit -c pyproject.toml -r src/

# Start MCP Inspector for interactive testing
uv run mcp dev src/real_estate/mcp_server/server.py

Architecture

MCP tools are spread across modules under src/real_estate/mcp_server/:

  • server.py — entry point; imports tool modules to register @mcp.tool() decorators
  • __init__.py — creates the shared mcp = FastMCP("real-estate") instance and loads .env
  • _helpers.py — all URL constants, shared runners, HTTP fetch, XML parse, and summary helpers
  • _region.py — region code search logic
  • tools/ — one file per domain: trade.py, rent.py, subscription.py, finance.py (calculate_loan_payment, calculate_compound_growth, calculate_monthly_cashflow)
  • parsers/ — XML parsers: trade.py, rent.py

Request flow for any trade/rent tool:

  1. _check_api_key() — guard: fails fast if env var is missing
  2. _build_url() — constructs URL with serviceKey embedded directly (not via httpx params, to avoid double URL-encoding)
  3. _fetch_xml() — async HTTP GET via httpx with 15s timeout
  4. Parser function in parsers/ — parses defusedxml, filters cancelled deals (cdealType == "O"), returns (items, error_code)
  5. _build_trade_summary() / _build_rent_summary() — computes median/min/max statistics
  6. Returns standardised dict: {total_count, items, summary} or {error, message}

Shared helpers for both trade and rent flows (in _helpers.py):

  • _run_trade_tool(base_url, parser, ...) — wires steps 1–5 for sale tools
  • _run_rent_tool(base_url, parser, ...) — same for lease/rent tools

Region code resolution (src/real_estate/mcp_server/_region.py):

  • Loads src/real_estate/resources/region_codes.txt (tab-separated: 10-digit code, name, status)
  • get_region_code tool must be called first; returns the 5-digit LAWD_CD used by all trade/rent tools
  • Gu/gun-level rows (last 5 digits 00000) are preferred as the canonical match

Additional tool groups (beyond trade/rent):

  • get_apt_subscription_info / get_apt_subscription_results — APT 청약 from api.odcloud.kr

All URL constants (_ODCLOUD_*, etc.) are defined in _helpers.py.

Key design constraints:

  • Prices are in 만원 (10,000 KRW) units, field suffix _10k
  • jeonse_ratio_pct is always null from rent tools; callers compute it from trade and rent medians
  • Villa/row-house rent is available via get_villa_rent (RTMSDataSvcRHRent)
  • Commercial trade parser uses different field names (building_type, building_use, building_ar) vs residential tools (unit_name, area_sqm)

API key env vars (all fall back to DATA_GO_KR_API_KEY if not set):

  • ODCLOUD_API_KEY / ODCLOUD_SERVICE_KEY — Applyhome (청약홈) Authorization header and query param

Utility modules (src/real_estate/common_utils/) — standalone CLI tools, not part of MCP:

  • docx_parser.py / hwp_parser.py — extract text from .docx/.hwp files
  • opendata_bulk_collector.py — CLI to collect monthly apartment rent snapshots into JSON

get_current_year_month tool (in server.py, not in tools/):

  • Returns {"year_month": "YYYYMM"} for the current UTC date
  • Call this when the user asks about recent transactions without specifying a period

HTTP mode and Docker deployment:

  • real-estate-mcp --transport http [--host 127.0.0.1] [--port 8000] — starts streamable-HTTP server for remote clients
  • docker/docker-compose.yml — runs the MCP server behind a Cloudflare Tunnel (--profile cloudflare) for TLS termination and remote exposure; the mcp service is not port-exposed directly
  • The server entry point is the real-estate-mcp CLI script registered in pyproject.toml

Testing Conventions

Tests use respx to mock httpx calls — the real API is never called in unit tests. Each tool has its own test file under tests/mcp_server/. Coverage threshold is 80% (enforced by pytest-cov). asyncio_mode = "auto" is set so async tests require no extra decorator.

Test classes follow the pattern: unit tests for parsers and helpers (no mock needed) + integration tests using @respx.mock + monkeypatch.setenv("DATA_GO_KR_API_KEY", "test-key") fixture.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.