### Install edinet-mcp using pip, uv, or Docker Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This snippet shows how to install the edinet-mcp library using different package managers. It covers installation via pip, uv, and provides a Docker command for running the MCP server with an EDINET API key. ```bash pip install edinet-mcp # or uv add edinet-mcp # or with Docker docker run -e EDINET_API_KEY=your_key ghcr.io/ajtgjmdjp/edinet-mcp serve ``` -------------------------------- ### Clone Repository and Install Dependencies (Bash) Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This bash script outlines the steps for cloning the edinet-mcp project from GitHub, navigating into the project directory, and installing development dependencies using `uv sync --extra dev`. It also shows commands for running tests and code checks with `pytest` and `ruff`. ```bash git clone https://github.com/ajtgjmdjp/edinet-mcp cd edinet-mcp uv sync --extra dev uv run pytest -v # 213 tests uv run ruff check src/ ``` -------------------------------- ### Basic EDINET Client Usage in Python Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This Python example demonstrates the basic usage of the EdinetClient. It shows how to initialize the client, search for companies by name, retrieve normalized financial statements for a specific period, access income statement data, list available labels, and export data to a Polars DataFrame. ```python import asyncio from edinet_mcp import EdinetClient async def main(): async with EdinetClient() as client: # Search for Toyota companies = await client.search_companies("トヨタ") print(companies[0].name, companies[0].edinet_code) # トヨタ自動車株式会社 E02144 # Get normalized financial statements stmt = await client.get_financial_statements("E02144", period="2025") # Dict-like access — works for J-GAAP, IFRS, and US-GAAP revenue = stmt.income_statement["売上高"] print(revenue) # {"当期": 45095325000000, "前期": 37154298000000} # See all available line items print(stmt.income_statement.labels) # ["売上高", "売上原価", "売上総利益", "営業利益", ...] # Export as DataFrame print(stmt.income_statement.to_polars()) asyncio.run(main()) ``` -------------------------------- ### EDINET MCP Tools and AI Prompts Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Lists the available tools provided by the EDINET MCP, such as searching companies, retrieving filings, and accessing financial statements. Includes example AI prompts in Japanese for interacting with these tools. ```python # Available MCP tools: # - search_companies: Search by company name, ticker, or EDINET code # - get_filings: List filings within a date range # - get_financial_statements: Get normalized BS/PL/CF data # - get_financial_metrics: Calculate ROE, ROA, margins # - compare_financial_periods: Get year-over-year changes # - screen_companies: Compare metrics across multiple companies # - list_available_labels: Show available financial line item labels # - get_company_info: Get detailed company information # - diff_financial_statements: Compare two periods for same company # Example AI prompts: # - "トヨタの最新の営業利益を教えて" # - "ソニーとキーエンスのROEを比較して" # - "E02144の2024年と2025年の売上高の変化を教えて" ``` -------------------------------- ### Multi-Company Financial Screening with edinet-mcp Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This Python example demonstrates how to perform multi-company screening using the `screen_companies` function. It allows comparing financial metrics across multiple companies for a specified period and sorting the results by a chosen metric, such as operating margin. ```python import asyncio from edinet_mcp import EdinetClient, screen_companies async def main(): async with EdinetClient() as client: result = await screen_companies( client, ["E02144", "E01777", "E01967"], # Toyota, Sony, Keyence period="2025", sort_by="営業利益率", # Sort by operating margin ) for r in result["results"]: print(f"{r['company_name']}: {r['profitability']['営業利益率']}") # 株式会社キーエンス: 51.91% # ソニーグループ株式会社: 11.69% # トヨタ自動車株式会社: 9.98% asyncio.run(main()) ``` -------------------------------- ### Discover XBRL Taxonomy Labels (Python) Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This Python code snippet demonstrates how to discover available XBRL taxonomy labels using the `get_taxonomy_labels` function from the `edinet_mcp` library. It shows an example of fetching labels for the 'income_statement' and the expected output format. ```python from edinet_mcp import get_taxonomy_labels # Discover available labels labels = get_taxonomy_labels("income_statement") # Expected output format: # [{"id": "revenue", "label": "売上高", "label_en": "Revenue"}, ...] ``` -------------------------------- ### Get Taxonomy Labels for Statements (Python) Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Retrieves available taxonomy labels for specific financial statement types (income statement, balance sheet, cash flow). This is useful for discovering which financial line items can be accessed. No client initialization is required. ```python from edinet_mcp import get_taxonomy_labels # Get all available income statement labels pl_labels = get_taxonomy_labels("income_statement") print("Income Statement Labels:") for label in pl_labels[:10]: print(f" {label['label']} ({label['label_en']})") # Get balance sheet labels bs_labels = get_taxonomy_labels("balance_sheet") print("\nBalance Sheet Labels:") for label in bs_labels[:10]: print(f" {label['label']} ({label['label_en']})") # Get cash flow labels cf_labels = get_taxonomy_labels("cash_flow") print("\nCash Flow Labels:") for label in cf_labels[:10]: print(f" {label['label']} ({label['label_en']})") ``` -------------------------------- ### Initialize and Use EdinetClient for Company Search and Financial Data Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Demonstrates how to initialize the EdinetClient, search for companies by name, retrieve company details, fetch financial statements with normalized Japanese labels, and export them to a Polars DataFrame. Includes configuration options for API key, cache directory, and rate limiting. ```python import asyncio from edinet_mcp import EdinetClient async def main(): # Initialize client with optional configuration async with EdinetClient( api_key="your_api_key", # or set EDINET_API_KEY env var cache_dir="~/.cache/edinet-mcp", rate_limit=0.5, # requests per second ) as client: # Search for companies by name, ticker, or EDINET code companies = await client.search_companies("トヨタ") print(f"Found: {companies[0].name} ({companies[0].edinet_code})") # Output: Found: トヨタ自動車株式会社 (E02144) # Get company details by EDINET code company = await client.get_company("E02144") print(f"Ticker: {company.ticker}, Industry: {company.industry}") # Get financial statements with normalized Japanese labels stmt = await client.get_financial_statements( edinet_code="E02144", period="2025", # Filing year (not fiscal year) doc_type="annual_report", ) # Access line items by Japanese label (works across accounting standards) revenue = stmt.income_statement["売上高"] print(f"Revenue: 当期={revenue['当期']:,}, 前期={revenue['前期']:,}") # Output: Revenue: 当期=45,095,325,000,000, 前期=37,154,298,000,000 # Export to Polars DataFrame df = stmt.income_statement.to_polars() print(df) asyncio.run(main()) ``` -------------------------------- ### Retrieve EDINET Filings by Date Range and Company Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Shows how to use the EdinetClient to retrieve a list of financial filings from EDINET. It allows filtering by date range, company EDINET code, and document type, returning detailed metadata for each filing, including XBRL and PDF availability. ```python import asyncio from edinet_mcp import EdinetClient async def main(): async with EdinetClient() as client: # Get filings for a specific company within a date range filings = await client.get_filings( start_date="2024-01-01", end_date="2024-12-31", edinet_code="E02144", doc_type="annual_report", ) for filing in filings: print(f"Doc ID: {filing.doc_id}") print(f"Company: {filing.company_name}") print(f"Filing Date: {filing.filing_date}") print(f"Period: {filing.period_start} to {filing.period_end}") print(f"Description: {filing.description}") print(f"Has XBRL: {filing.has_xbrl}, Has PDF: {filing.has_pdf}") print("---") asyncio.run(main()) ``` -------------------------------- ### Screen Companies by Financial Metrics (Python) Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Fetches and compares financial metrics for multiple companies (up to 20). Supports sorting results by any metric for ranking. Requires an initialized EdinetClient. ```python import asyncio from edinet_mcp import EdinetClient, screen_companies async def main(): async with EdinetClient() as client: # Screen automotive companies result = await screen_companies( client, edinet_codes=["E02144", "E01777", "E01967"], # Toyota, Sony, Keyence period="2025", sort_by="営業利益率", # Sort by operating margin sort_desc=True, ) print(f"Successfully screened {result['count']} companies") print("=" * 60) for company in result["results"]: print(f"\n{company['company_name']} ({company['edinet_code']})") print(f"Accounting Standard: {company['accounting_standard']}") prof = company.get("profitability", {}) print(f" 営業利益率: {prof.get('営業利益率')}") print(f" ROE: {prof.get('ROE')}") print(f" ROA: {prof.get('ROA')}") stab = company.get("stability", {}) print(f" 自己資本比率: {stab.get('自己資本比率')}") # Handle any errors for error in result["errors"]: print(f"Error for {error['edinet_code']}: {error['error']}") asyncio.run(main()) ``` -------------------------------- ### Access Financial Statements with EdinetClient Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Demonstrates how to use the asynchronous EdinetClient to fetch financial statements for a given company and period. It shows dict-like access to financial data using Japanese labels and various export options. ```python import asyncio from edinet_mcp import EdinetClient async def main(): async with EdinetClient() as client: stmt = await client.get_financial_statements("E02144", period="2025") data = stmt.income_statement # Dict-like access by Japanese label revenue = data["売上高"] print(f"Revenue data: {revenue}") # {"当期": 45095325..., "前期": 37154298...} # Safe access with default depreciation = data.get("減価償却費", None) # Get all available labels print(f"Available labels: {data.labels}") # Check number of items print(f"Number of line items: {len(data)}") # Boolean check for data presence if data: print("Statement has data") # Export options polars_df = data.to_polars() # Polars DataFrame pandas_df = data.to_pandas() # pandas DataFrame (requires pandas) dict_list = data.to_dicts() # list[dict] for JSON serialization # Access raw (pre-normalized) data if needed raw_items = data.raw_items asyncio.run(main()) ``` -------------------------------- ### EDINET MCP CLI Commands Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Provides a command-line interface for various EDINET data operations. Includes searching companies, fetching statements, screening multiple companies, comparing statements, testing API connectivity, and serving data. ```bash # Search for companies edinet-mcp search トヨタ edinet-mcp search 7203 --json-output # Fetch financial statements edinet-mcp statements -c E02144 -p 2025 edinet-mcp statements -c E02144 -s balance_sheet --format json edinet-mcp statements -c E02144 -s cash_flow_statement --format csv # Screen multiple companies and sort by metrics edinet-mcp screen E02144 E01777 E02529 --sort-by ROE edinet-mcp screen E02144 E01777 --sort-by 営業利益率 --format json # Compare statements across two periods (xbrl-diff) edinet-mcp diff -c E02144 -p1 2024 -p2 2025 edinet-mcp diff -c E02144 -p1 2024 -p2 2025 --format json # Test API connectivity edinet-mcp test # Start MCP server edinet-mcp serve edinet-mcp serve --transport sse ``` -------------------------------- ### Compare Financial Statements Across Periods (Python) Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Compares financial statements for a single company between two different periods. Calculates detailed changes and growth rates for each line item. Requires an initialized EdinetClient. ```python import asyncio from edinet_mcp import EdinetClient, diff_statements async def main(): async with EdinetClient() as client: # Compare Toyota's 2024 vs 2025 filings result = await diff_statements( client, edinet_code="E02144", period1="2024", period2="2025", doc_type="annual_report", ) print(f"Company: {result['company_name']}") print(f"Comparison: {result['period1']} → {result['period2']}") print(f"Accounting Standard: {result['accounting_standard']}") # Show top changes by magnitude print("\n=== Top Changes ===") for diff in result["diffs"][:10]: print(f"{diff['statement']}: {diff['科目']}") print(f" {result['period1']}: {diff['period1_value']:,.0f}" if diff['period1_value'] else " N/A") print(f" {result['period2']}: {diff['period2_value']:,.0f}" if diff['period2_value'] else " N/A") print(f" 増減額: {diff['増減額']:+,.0f}" if diff['増減額'] else " N/A") print(f" 増減率: {diff['増減率']}" if diff['増減率'] else " N/A") print() # Summary statistics summary = result["summary"] print(f"\nSummary: {summary['total_items']} items analyzed") print(f" Increased: {summary['increased']}") print(f" Decreased: {summary['decreased']}") print(f" Unchanged: {summary['unchanged']}") asyncio.run(main()) ``` -------------------------------- ### Configure MCP Server for EDINET Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Configuration for the MCP server to enable natural language access to Japanese financial data via EDINET. This involves setting up the server command, arguments, and environment variables, including the EDINET API key. ```json { "mcpServers": { "edinet": { "command": "uvx", "args": ["edinet-mcp", "serve"], "env": { "EDINET_API_KEY": "your_api_key_here" } } } } ``` -------------------------------- ### Set EDINET API Key Environment Variable Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This code snippet demonstrates how to set the EDINET API key as an environment variable. This key is required for accessing the EDINET system and should be obtained by registering on the EDINET website. ```bash export EDINET_API_KEY=your_key_here ``` -------------------------------- ### Compare Financial Periods Year-over-Year Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Generates year-over-year comparison for all normalized financial items, calculating change amounts and growth rates between current and previous periods. This function requires a FinancialStatement object. Requires the 'edinet_mcp' library. ```python import asyncio from edinet_mcp import EdinetClient, compare_periods async def main(): async with EdinetClient() as client: stmt = await client.get_financial_statements("E02144", period="2025") changes = compare_periods(stmt) print("Year-over-Year Changes:") print("-" * 80) for item in changes[:10]: # Show top 10 items print(f"Statement: {item['statement']}") print(f"科目: {item['科目']}") print(f"当期: {item['当期']:,.0f}") print(f"前期: {item['前期']:,.0f}") print(f"増減額: {item['増減額']:+,.0f}") print(f"増減率: {item.get('増減率', 'N/A')}") print("---") asyncio.run(main()) ``` -------------------------------- ### Calculate Financial Metrics using edinet-mcp Source: https://github.com/ajtgjmdjp/edinet-mcp/blob/main/README.md This Python snippet shows how to calculate various financial metrics from the retrieved financial statements using the `calculate_metrics` function. It takes a statement object and returns a dictionary containing profitability ratios and other key metrics. ```python import asyncio from edinet_mcp import EdinetClient, calculate_metrics async def main(): async with EdinetClient() as client: stmt = await client.get_financial_statements("E02144", period="2025") metrics = calculate_metrics(stmt) print(metrics["profitability"]) # {"売上総利益率": "25.30%", "営業利益率": "11.87%", "ROE": "12.50%", ...} asyncio.run(main()) ``` -------------------------------- ### Fetch Financial Statements with EDINET Client Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Fetches, downloads, and parses financial statements for a company using the EdinetClient. It returns a FinancialStatement object containing normalized balance sheet, income statement, and cash flow statement data. Requires the 'edinet_mcp' library. ```python import asyncio from edinet_mcp import EdinetClient async def main(): async with EdinetClient() as client: # Get financial statements (period is filing year, not fiscal year) # March fiscal year-end companies file in June: FY2024 -> period="2025" stmt = await client.get_financial_statements( edinet_code="E02144", period="2025", doc_type="annual_report", ) print(f"Accounting Standard: {stmt.accounting_standard.value}") print(f"Filing: {stmt.filing.description}") # Access individual statements print("\n=== Income Statement ===") print(f"Available labels: {stmt.income_statement.labels[:5]}") print(stmt.income_statement["営業利益"]) # {"当期": ..., "前期": ...} print("\n=== Balance Sheet ===") total_assets = stmt.balance_sheet["資産合計"] print(f"Total Assets: {total_assets}") print("\n=== Cash Flow Statement ===") operating_cf = stmt.cash_flow_statement["営業活動によるキャッシュ・フロー"] print(f"Operating CF: {operating_cf}") # Export to DataFrames pl_df = stmt.income_statement.to_polars() bs_df = stmt.balance_sheet.to_pandas() # requires pandas extra # Get list of dicts for JSON serialization cf_data = stmt.cash_flow_statement.to_dicts() asyncio.run(main()) ``` -------------------------------- ### Calculate Financial Metrics from Statements Source: https://context7.com/ajtgjmdjp/edinet-mcp/llms.txt Calculates key financial metrics from normalized financial statements, including profitability, stability, efficiency, and growth rates. This function requires a FinancialStatement object obtained from `get_financial_statements`. Requires the 'edinet_mcp' library. ```python import asyncio from edinet_mcp import EdinetClient, calculate_metrics async def main(): async with EdinetClient() as client: stmt = await client.get_financial_statements("E02144", period="2025") metrics = calculate_metrics(stmt) # Profitability metrics print("=== Profitability ===") prof = metrics.get("profitability", {}) print(f"売上総利益率: {prof.get('売上総利益率')}") print(f"営業利益率: {prof.get('営業利益率')}") print(f"ROE: {prof.get('ROE')}") print(f"ROA: {prof.get('ROA')}") # Stability metrics print("\n=== Stability ===") stab = metrics.get("stability", {}) print(f"自己資本比率: {stab.get('自己資本比率')}") print(f"流動比率: {stab.get('流動比率')}") # Efficiency metrics (turnover ratios) print("\n=== Efficiency ===") eff = metrics.get("efficiency", {}) print(f"総資産回転率: {eff.get('総資産回転率')}回") # Growth metrics print("\n=== Growth ===") growth = metrics.get("growth", {}) print(f"売上高成長率: {growth.get('売上高成長率')}") print(f"営業利益成長率: {growth.get('営業利益成長率')}") # Cash flow metrics print("\n=== Cash Flow ===") cf = metrics.get("cash_flow", {}) print(f"営業CF: {cf.get('営業CF'):,.0f}") print(f"フリーCF: {cf.get('フリーCF'):,.0f}") print(f"営業CFマージン: {cf.get('営業CFマージン')}") asyncio.run(main()) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.