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?

JAXAのMCPサーバーをstreamable-httpで立ち上げてwebアプリ・コードベースのAIエージェントに使わせたい!

0
Last updated at Posted at 2026-02-01

最近、MCP(Model Context Protocol)を使って、生成AIに外部ツールを持たせる構成が増えてきました。

先週、JAXAも、Earth API向けのMCPサーバー実装用のコードを公開しました。

ただ、こちらの実装用コードですが、現段階、トランスポート方式がstdioだったため、

  • Claude Desktop前提
  • Gemini CLI前提
  • stdio通信前提

のもののようですが、

「最終的にWebアプリや自作エージェントに組み込みたい」

と考えると、この構成は少し微妙です。

そこで今回は、コードベースのAIエージェントに組み込みWebアプリ組み込むことが簡単にできる構成として

JAXAのMCPサーバーを streamable-http 化してgemini cliの中で使う

ところまでをやっていきます。


なぜ stdio ではダメなのか?

JAXA公式のMCPサンプルは、基本的に次のようになっています。

mcp.run(transport="stdio")

これは、

LLM ↔ 標準入出力 ↔ MCP

という構成です。

Claude Desktopなどでは便利ですが、世の中、stdioで通信できないツールがあるのも事実...


最短で実用構成にする方法

結論はシンプルです。

transport を streamable-http にするだけ。

これで、

AI Agent / Web App
        ↓ HTTP
    MCP Server

という、普通のMCPサーバー構成になります。


今回やること

今回は以下を行います。

  1. JAXA公式MCPコードをベースに
  2. streamable-http対応させて
  3. Gemini CLIから疎通確認する

ここまでできれば、Webアプリ統合はすぐです。


① 開発環境(pip + venv)

今回は uv は使いません。

mkdir jaxa-earth-mcp
cd jaxa-earth-mcp
python -m venv .venv

仮想環境を有効化します。

Windows

.venv\Scripts\activate

Mac / Linux

source .venv/bin/activate

② ライブラリをインストール

JAXA API

pip install \
  --index-url https://data.earth.jaxa.jp/api/python/repository/ \
  --extra-index-url https://pypi.org/simple \
  jaxa-earth

MCP

pip install mcp

③ MCPサーバーを修正する

以下のリンクからmcp_server.pyをダウンロードしてください。

JAXA公開コードをベースに、最後だけ変更します。

変更前(公式)

mcp.run(transport="stdio")

変更後(今回)

mcp.run(transport="streamable-http")

これだけです。(ポートなどを設定したい場合は、ライブラリのドキュメントを参照ください。)


④ 起動して確認する

python -m mcp_server

成功すると、次のように表示されます。

Running on http://127.0.0.1:8000

エンドポイントは以下です。

http://127.0.0.1:8000/mcp

⑤ Gemini CLIから疎通確認

Gemini CLI 側の設定例です。(.gemini/setting.json内に設定が書き込めます。)

{
  "mcpServers": {
    "jaxa_api_tools": {
      "type": "streamable_http",
      "url": "http://127.0.0.1:8000/mcp"
    }
  }
}

この状態で、「この地域の標高データを取得して」などと聞けば、JAXA APIがMCP経由で呼ばれます。

実際に、問い合わせを行った結果、

> jaxa_api_tools このツールを使うとどんな事ができそうですか?

✦ jaxa_api_tools は、JAXA(宇宙航空研究開発機構)が提供する衛星データへアクセスし、利用するためのツール群です。

  このツールを使うことで、主に以下のようなことができます。

   1. 利用可能なデータセットの検索:
      どのような衛星データ(例: 標高、降水量、地表面温度など)が利用可能か、その詳細(期間、範囲など)を検索できます。


   2. 衛星画像の表示:
      指定した地域、期間、データの種類(バンド)に基づいて、衛星画像を地図上に表示できます。例えば、「特定の日の富士山周辺の標高データ」を画像として見ることができます。


   3. 空間統計の計算と可視化:
      指定した範囲の衛星データについて、平均値、最大値、最小値などの統計情報を計算し、その結果を画像として表示できます。これにより、例えば「ある地域の森林被覆率の変化」などを分析するのに役立
  ちます。


  簡単に言うと、「日本の様々な衛星データを検索し、地図上に表示したり、分析したりすることができるツール」です。

実際にどんなデータセットが検索できるか聞いてみたところ...
(少し長いので織り込みます。)

問い合わせ結果を表示
> 海面温度に関するデータセットとかって検索できますか?

✦ はい、できます。JAXA Earth APIで利用可能なデータセットを検索してみます。海面水温に関連するデータセットがあるか確認しますね。
 ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
 │ ✔  search_collections_id (jaxa_api_tools MCP Server) {}                                                                                                                           │
 │                                                                                                                                                                                   │
 │    ... first 912 lines hidden ...                                                                                                                                                 │
 │    * endDate: 2021-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Daytime/Monthly)                                                                                                                                  │* title: Land Surface Temperature (Daytime/Monthly)                                                                                                                            │
 │    * id: NASA.EOSDIS_Terra.MODIS_MOD11C3-LST.daytime.v061_global_monthly                                                                                                          │
 │    * description: Wan, Z., Hook, S., Hulley, G. (2021). MODIS/Terra Land Surface Temperature/Emissivity Monthly L3 Global 0.05Deg CMG V061 [Data set]. NASA EOSDIS Land           │
 │    Processes DAAC. Accessed 2021-12-21 from https://doi.org/10.5067/MODIS/MOD11C3.061                                                                                             │
 │    * bands: LST                                                                                                                                                                   │
 │    * keywords: LST, MODIS, EOSDIS, NASA                                                                                                                                           │
 │    * startDate: 2000-02-27T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Nighttime/Monthly)                                                                                                                                │* title: Land Surface Temperature (Nighttime/Monthly)                                                                                                                          │
 │    * id: NASA.EOSDIS_Terra.MODIS_MOD11C3-LST.nighttime.v061_global_monthly                                                                                                        │
 │    * description: Wan, Z., Hook, S., Hulley, G. (2021). MODIS/Terra Land Surface Temperature/Emissivity Monthly L3 Global 0.05Deg CMG V061 [Data set]. NASA EOSDIS Land           │
 │    Processes DAAC. Accessed 2021-12-21 from https://doi.org/10.5067/MODIS/MOD11C3.061                                                                                             │
 │    * bands: LST                                                                                                                                                                   │
 │    * keywords: LST, MODIS, EOSDIS, NASA                                                                                                                                           │
 │    * startDate: 2000-02-27T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## SPI - Standardized Precipitation Index (Monthly Averaged)                                                                                                                   │* title: SPI - Standardized Precipitation Index (Monthly Averaged)                                                                                                             │
 │    * id: JAXA.EORC_GSMaP_SPI.climate.gnrt6_monthly                                                                                                                                │
 │    * description: GSMaP has multi-satellite global precipitation map under the Global Precipitation Measurement (GPM) Mission, by using Dual-frequency Precipitation Radar (DPR)  │
 │    onboard GPM core satellites, other GPM constellation satellites, and Geostationary satellites.                                                                                 │
 │    * bands: SPI                                                                                                                                                                   │
 │    * keywords: SPI, DPR, GPM, GSMaP, JAXA                                                                                                                                         │
 │    * startDate: 2019-06-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Sea Surface Temperature (Daytime/Daily)                                                                                                                                     │* title: Sea Surface Temperature (Daytime/Daily)                                                                                                                               │
 │    * id: JAXA.G-Portal_GCOM-W.AMSR2_standard.L3-SST.daytime.v4_global_daily                                                                                                       │
 │    * description: Sea Surface Temperature (Daytime/Daily)                                                                                                                         │
 │    * bands: SST                                                                                                                                                                   │
 │    * keywords: SST, AMSR2, GCOM-W, JAXA                                                                                                                                           │
 │    * startDate: 2000-03-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Sea Surface Temperature (Nighttime/Daily)                                                                                                                                   │* title: Sea Surface Temperature (Nighttime/Daily)                                                                                                                             │
 │    * id: JAXA.G-Portal_GCOM-W.AMSR2_standard.L3-SST.nighttime.v4_global_daily                                                                                                     │
 │    * description: Sea Surface Temperature (Nighttime/Daily)                                                                                                                       │
 │    * bands: SST                                                                                                                                                                   │
 │    * keywords: SST, AMSR2, GCOM-W, JAXA                                                                                                                                           │
 │    * startDate: 2000-03-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Daytime/8day-normal/Japan)                                                                                                                        │* title: Land Surface Temperature (Daytime/8day-normal/Japan)                                                                                                                  │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.daytime.v3_japan_8-day-normal                                                                                                    │
 │    * description: Daily average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                            │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land surface temperature (Daytime/8-day/Japan)                                                                                                                              │* title: Land surface temperature (Daytime/8-day/Japan)                                                                                                                        │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.daytime.v3_japan_8-day                                                                                                           │
 │    * description: Land surface temperature product in GCOM-C SGLI Level-2 Standard product                                                                                        │
 │    * bands: LST_AVE                                                                                                                                                               │
 │    * keywords: LST, SGLI, GCOM-C, GCOM, JAXA                                                                                                                                      │
 │    * startDate: 2020-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Daytime/monthly-normal/Japan)                                                                                                                     │* title: Land Surface Temperature (Daytime/monthly-normal/Japan)                                                                                                               │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.daytime.v3_japan_monthly-normal                                                                                                  │
 │    * description: Average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                                  │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Nighttime/8day-normal/Japan)                                                                                                                      │* title: Land Surface Temperature (Nighttime/8day-normal/Japan)                                                                                                                │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.nighttime.v3_japan_8-day-normal                                                                                                  │
 │    * description: Daily average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                            │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land surface temperature (Nighttime/8-day/Japan)                                                                                                                            │* title: Land surface temperature (Nighttime/8-day/Japan)                                                                                                                      │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.nighttime.v3_japan_8-day                                                                                                         │
 │    * description: Land surface temperature product in GCOM-C SGLI Level-2 Standard product                                                                                        │
 │    * bands: LST_AVE                                                                                                                                                               │
 │    * keywords: LST, SGLI, GCOM-C, GCOM, JAXA                                                                                                                                      │
 │    * startDate: 2020-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Nighttime/monthly-normal/Japan)                                                                                                                   │* title: Land Surface Temperature (Nighttime/monthly-normal/Japan)                                                                                                             │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L2-LST.nighttime.v3_japan_monthly-normal                                                                                                │
 │    * description: Average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                                  │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [123,24,150,50]                                                                                                                                                        │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Daytime/8day-normal/Global)                                                                                                                       │* title: Land Surface Temperature (Daytime/8day-normal/Global)                                                                                                                 │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.daytime.v3_global_8-day-normal                                                                                                   │
 │    * description: Daily average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                            │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land surface temperature (Daytime/8-day/Global)                                                                                                                             │* title: Land surface temperature (Daytime/8-day/Global)                                                                                                                       │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.daytime.v3_global_8-day                                                                                                          │
 │    * description: Land surface temperature product in GCOM-C SGLI Level-3 Standard product                                                                                        │
 │    * bands: LST_AVE                                                                                                                                                               │
 │    * keywords: LST, SGLI, GCOM-C, GCOM, JAXA                                                                                                                                      │
 │    * startDate: 2020-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Daytime/monthly-normal/Global)                                                                                                                    │* title: Land Surface Temperature (Daytime/monthly-normal/Global)                                                                                                              │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.daytime.v3_global_monthly-normal                                                                                                 │
 │    * description: Average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                                  │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Nighttime/8day-normal/Global)                                                                                                                     │* title: Land Surface Temperature (Nighttime/8day-normal/Global)                                                                                                               │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.nighttime.v3_global_8-day-normal                                                                                                 │
 │    * description: Daily average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                            │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land surface temperature  (Nighttime/8-day/Global)                                                                                                                          │* title: Land surface temperature  (Nighttime/8-day/Global)                                                                                                                    │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.nighttime.v3_global_8-day                                                                                                        │
 │    * description: Land surface temperature product in GCOM-C SGLI Level-3 Standard product                                                                                        │
 │    * bands: LST_AVE                                                                                                                                                               │
 │    * keywords: LST, SGLI, GCOM-C, GCOM, JAXA                                                                                                                                      │
 │    * startDate: 2020-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: present                                                                                                                                                             │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 │    ## Land Surface Temperature (Nighttime/monthly-normal/Global)                                                                                                                  │* title: Land Surface Temperature (Nighttime/monthly-normal/Global)                                                                                                            │
 │    * id: JAXA.JASMES_GCOM-C.SGLI_standard.L3-LST.nighttime.v3_global_monthly-normal                                                                                               │
 │    * description: Average land surface temperature was generated by Terra MODIS LST and SGLI LST                                                                                  │
 │    * bands: LST_2000_2022                                                                                                                                                         │
 │    * keywords: LST, SGLI, GCOM-C, JAXA                                                                                                                                            │
 │    * startDate: 2000-01-01T00:00:00Z                                                                                                                                              │
 │    * endDate: 2022-12-31T23:59:09Z                                                                                                                                                │
 │    * bbox: [-180,-90,180,90]                                                                                                                                                      │
 │    * epsg: 4326                                                                                                                                                                   │
 │                                                                                                                                                                                   │
 ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
✦ はい、海面水温(Sea Surface Temperature)に関するデータセットが複数見つかりました。


  主に、観測衛星(GCOM-C, GCOM-W)、観測時間(昼間/夜間)、集計期間(日次/半月/月次)によっていくつかの種類に分かれています。

  以下が関連するデータセットのIDの例です。


   * GCOM-C衛星 (SGLIセンサー)
       * JAXA.G-Portal_GCOM-C.SGLI_standard.L3-SST.daytime.v3_global_daily (日次/昼間)
       * JAXA.G-Portal_GCOM-C.SGLI_standard.L3-SST.nighttime.v3_global_daily (日次/夜間)
       * JAXA.G-Portal_GCOM-C.SGLI_standard.L3-SST.daytime.v3_global_monthly (月次/昼間)


   * GCOM-W衛星 (AMSR2センサー)
       * JAXA.G-Portal_GCOM-W.AMSR2_standard.L3-SST.daytime.v4_global_daily (日次/昼間)
       * JAXA.G-Portal_GCOM-W.AMSR2_standard.L3-SST.nighttime.v4_global_daily (日次/夜間)


  これらのデータセットを使って、特定の場所や日時の海面水温を画像で表示したり、統計情報を計算したりできます。


  ご希望のデータセットはありますか? もしくは、試しにどこかの海域の画像を表示してみますか?

これで何ができるようになったか?

ここまでで、

  • HTTP MCP完成
  • 常駐OK
  • Webアプリ連携OK
  • Agent組み込みOK

になりました。

つまり、

自分のAIサービスにJAXAデータを組み込める状態

です。


Webアプリ組み込みイメージ

構成例です。

Agent → MCP → JAXA API → 結果 → フロント

webサービスのバックエンドの中にも簡単に統合できます。


なぜ Gemini CLI を使うのか?

今回は Gemini CLI を「確認用」に使っています。

理由は:

  • 設定が簡単
  • MCP対応が早い

からです。


まとめ

今回は、

  • JAXA公式MCPを
  • streamable-http化して
  • コードベースAIで使える形にした

ところまでやりました。

これが第一歩です。


おわりに

Claude Desktop向けの記事は多いですが、
「自作AIサービス向け」の情報はまだ少ないです。

この記事が、そういう人の参考になれば嬉しいです。

参考

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?