client-library

client-library is a cursor rule for Cursor from koizumikento/reinfolib-mcp. It costs 0 tokens per session (2,610 once invoked), scanned A, original, MIT.

A design guide for a Python client that connects to Japan’s Real Estate Information Library API, a service providing real-estate data. It covers API-key setup, request settings, and typed data models.

In plain words
What is it for?
Use it when building Python software that retrieves data from the Real Estate Information Library API. It helps set up asynchronous HTTP requests, timeouts, and API authentication.
Why use it?
It gives a consistent way to configure the API client and keeps the access key out of the source code by allowing it to come from an environment variable.

Cursor rule for Cursor

Written for Cursor: installed under .cursor/.

Good fit Use it when building Python software that retrieves data from the Real Estate Information Library API. It helps set up asynchronous HTTP requests, timeouts, and API authentication.

Compare 6 cursor rules from other repositories ↓
Install with agentmods
npx agentmods add rules/koizumikento/reinfolib-mcp/client-library
Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

Clone the repo
git clone --depth 1 https://github.com/koizumikento/reinfolib-mcp

Made for: Cursor.

Wrote this? Show the measurements

A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.

agentmods badge for client-library

README.md
[![agentmods](https://agentmods.dev/badge/rules/koizumikento/reinfolib-mcp/client-library/github.svg)](https://agentmods.dev/rules/koizumikento/reinfolib-mcp/client-library)
Your own site
<a href="https://agentmods.dev/rules/koizumikento/reinfolib-mcp/client-library"><img src="https://agentmods.dev/badge/rules/koizumikento/reinfolib-mcp/client-library/github.svg" alt="Measured on agentmods" height="20"></a>

Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.

agentmods 80×15 button for client-library

Your own site · 80×15
<a href="https://agentmods.dev/rules/koizumikento/reinfolib-mcp/client-library"><img src="https://agentmods.dev/badge/rules/koizumikento/reinfolib-mcp/client-library.svg" alt="Reviewed on agentmods" width="80" height="20"></a>
Per session 0 Nothing until a file matches its globs; then the whole rule loads.
When invoked 2,610 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. A grade says what 26 rules found in the file — not that it is safe.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5.1 $0.00000 $0.02610
Opus 5 $0.00000 $0.01305
Sonnet 5 $0.00000 $0.00522
Haiku 4.5 $0.00000 $0.00261

Measured 8d ago against content hash 0f3ddde8f6e4, method: parsed. Prices are Anthropic first-party input rates as of 2026-09-08, from the pricing page.

Security

Grade A, and why

client-library scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 8d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/client-library.mdc · 376 lines

How it starts

The opening of the file, as written. The whole thing — 376 lines — stays where its author put it; the contents beside it link to each section on GitHub.

不動産情報ライブラリAPIクライアント設計ガイド

APIキー管理パターン

1. 基本的なクライアント設計

import os
from typing import Optional, Dict, Any, Union
import httpx
from pydantic import BaseModel

class ReinfiolibClient:
    """不動産情報ライブラリAPIクライアント"""
    
    def __init__(
        self, 
        api_key: Optional[str] = None,
        base_url: str = "https://www.reinfolib.mlit.go.jp/ex-api/external",
        timeout: int = 30
    ):
        """
        クライアントを初期化します。
        
        Args:
            api_key: APIキー(Noneの場合は環境変数REINFOLIB_API_KEYを使用)
            base_url: APIベースURL
            timeout: リクエストタイムアウト(秒)
        """
        self.api_key = api_key or os.getenv("REINFOLIB_API_KEY")
        if not self.api_key:
            raise ValueError("APIキーが設定されていません。引数で指定するか、環境変数REINFOLIB_API_KEYを設定してください。")
        
        self.base_url = base_url
        self.timeout = timeout
        self._client = httpx.AsyncClient(
            headers={"Ocp-Apim-Subscription-Key": self.api_key},
            timeout=timeout
        )

2. 環境変数による設定

# .env ファイル例
REINFOLIB_API_KEY=your_api_key_here

# 使用例
from dotenv import load_dotenv
load_dotenv()

# 環境変数から自動取得
client = ReinfiolibClient()

# 直接指定
client = ReinfiolibClient(api_key="your_api_key")

レスポンスモデル定義

基本レスポンスモデル

from pydantic import BaseModel, Field
from typing import List, Optional, Any
from datetime import datetime

class RealEstateTransaction(BaseModel):
    """不動産取引情報モデル"""
    prefecture: str = Field(description="都道府県名")
    city: str = Field(description="市区町村名")
    district: Optional[str] = Field(None, description="地区名")
    price: Optional[int] = Field(None, description="取引価格(円)")
    area: Optional[float] = Field(None, description="面積(㎡)")
    unit_price: Optional[int] = Field(None, description="㎡単価(円)")
    transaction_period: Optional[str] = Field(None, description="取引時期")
    building_year: Optional[str] = Field(None, description="建築年")
    structure: Optional[str] = Field(None, description="構造")
    usage: Optional[str] = Field(None, description="用途")

class RealEstateSearchResult(BaseModel):
    """不動産検索結果モデル"""
    data: List[RealEstateTransaction]
    total_count: int
    page: int
    per_page: int

class LandPricePoint(BaseModel):
    """地価公示・調査ポイントモデル"""
    point_name: str = Field(description="地点名")
    address: str = Field(description="住所")
    price_per_sqm: int = Field(description="㎡単価(円)")
    year: int = Field(description="調査年")
    longitude: float = Field(description="経度")
    latitude: float = Field(description="緯度")

Read the full file on GitHub · 376 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 8d ago First seen · 376 lines · 2,610 tokens per session scan A 0f3ddde8f6e4

Subscribe to this mod's changes

client-library is a cursor rule published in the GitHub repository koizumikento/reinfolib-mcp (2 stars, last pushed 12d ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 2,610 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-31.