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
- Very specific: line 67
All URL constants (_ODCLOUD_*, etc.) are defined in _helpers.py.
- Distinctive: line 84
Call this when the user asks about recent transactions without specifying a period
- Very specific: line 95
Test classes follow the pattern: unit tests for parsers and helpers (no mock needed) + integration tests using @respx.mock + …
≈ “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.
Files
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.pyArchitecture
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:
_check_api_key()— guard: fails fast if env var is missing_build_url()— constructs URL withserviceKeyembedded directly (not via httpx params, to avoid double URL-encoding)_fetch_xml()— async HTTP GET via httpx with 15s timeout- Parser function in
parsers/— parses defusedxml, filters cancelled deals (cdealType == "O"), returns(items, error_code) _build_trade_summary()/_build_rent_summary()— computes median/min/max statistics- 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_codetool must be called first; returns the 5-digitLAWD_CDused 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 청약 fromapi.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_pctis alwaysnullfrom 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 filesopendata_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 clientsdocker/docker-compose.yml— runs the MCP server behind a Cloudflare Tunnel (--profile cloudflare) for TLS termination and remote exposure; themcpservice is not port-exposed directly- The server entry point is the
real-estate-mcpCLI script registered inpyproject.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.
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
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.

