0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Claude Code から有価証券報告書の「事業等のリスク」を原文で取得する:get_filing_text のレスポンスとページング

0
Posted at

EDINET の有価証券報告書から、記述情報を要約せずに取り出したいときの話です。MCP サーバー(Kabuken)の get_filing_text を Claude Code から呼び、レスポンスの形とページングの扱いを整理します。背景と実例の読み物はブログにあります:https://intellics.ai/ja-JP/blog/post/22?utm_source=qiita&utm_medium=article&utm_campaign=filing_text

接続(Claude Code)

claude mcp add --transport http kabuken https://kabuken.intellics.ai/mcp

追加後、Claude Code 内で /mcp を開き kabuken を選んでサインインします(手順の正本:https://kabuken.intellics.ai/docs/ja/?utm_source=qiita&utm_medium=article&utm_campaign=filing_text )。エンドポイント URL は設定値なので、そのまま使います。

Kabuken プラグイン 2.1.9 には、このツール専用のスキル filing-text が入っています(GitHub:https://github.com/Intellics-ai/kabuken-mcp-plugin 、および ChatGPT のプラグインディレクトリで利用可能)。Claude Code では上のコマンドで MCP サーバーを直接つなぐ形です。

ツールの使い方を画面操作で追うガイド:https://kabuken.intellics.ai/docs/ja/guide/filing-text/?utm_source=qiita&utm_medium=article&utm_campaign=filing_text

入力

引数 内容
entity_code EDINET コード。XBRL データのある最新の有価証券報告書を使う
doc_id 書類管理番号。特定の書類を指定
sections business_risks、md_and_a。既定は ["business_risks"]
max_chars 1ページの文字数。1〜30,000、既定 12,000
cursor 前回の next_cursor。同じ entity_code または doc_id と sections で送る

entity_code と doc_id はどちらか一方を渡します(仕様ページの記載)。

レスポンスの形

ニレコ(E02411)の business_risks で返ったレスポンスのトップレベルのキーです。

doc_id, entity_code, period_end, lang,
sections[], missing_sections[], next_cursor, attribution

sections[] の各要素は次のフィールドを持ちます。

section, source_element, context_ref, label_ja, label_en,
text, char_offset, total_chars, truncated

実際の値は、doc_id が S100YFWS、period_end が 2026-03-31、lang が ja、source_element が jpcrp_cor:BusinessRisksTextBlock、total_chars が 2488、truncated が false、next_cursor が null でした。text は原文のままで、先頭は「3【事業等のリスク】」です。

試すなら、たとえば次のように聞いてみてください。

ソニーグループの最新の有価証券報告書の事業等のリスクを原文で見せてください。

ページングの扱い

truncated が true で next_cursor が返った場合は、同じ引数に cursor を加えて再度呼びます。char_offset が各ページの開始位置、total_chars が節の全体の長さです。カーソルを引数と違う組み合わせで送ると invalid_input になります。

cursor = None
chunks = []
while True:
    res = call_tool("get_filing_text",
                    entity_code="E02411",
                    sections=["business_risks"],
                    max_chars=12000,
                    cursor=cursor)
    chunks.append(res)
    cursor = res["next_cursor"]
    if cursor is None:
        break

call_tool は MCP クライアントのツール呼び出しを表す仮の関数です(実際の呼び方は使うクライアントやライブラリに依存します)。このループ自体は私が実行して確認したものではなく、仕様ページの記述に沿った擬似コードです。

後続処理で気をつけること

  • 保存されていない節は missing_sections に入ります。空文字を前提にしないでください。
  • 引数と制約の正本は仕様ページです:https://kabuken.intellics.ai/docs/ja/api/tools/?utm_source=qiita&utm_medium=article&utm_campaign=filing_text
  • attribution オブジェクト(出典、ライセンス、「Kabuken が加工」の注記、提出会社の文章に関する注記)は、結果を再掲するときも残してください。文章の権利は提出会社にあります。
  • 返るのは日本語の原文です。要約や翻訳をするのは、呼び出し側のモデルまたはあなたのコードです。

本記事は MCP の使い方の解説であり、投資助言ではありません。Kabuken は株価を扱いません。

Kabuken:https://kabuken.intellics.ai/?utm_source=qiita&utm_medium=article&utm_campaign=filing_text

出典:EDINET(金融庁)、公共データ利用規約(第1.0版)。データは Kabuken が加工しています。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?