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 routineで GASにアクセスできなかった時の対処法

0
Posted at

まえがき

Claude Code の routine(Scheduled Agent)を使うと、レポート集計や外部 API からのデータ取得を定期的に自動化できます。その routine を構築する際、Google Apps Script の URL に WebFetch でアクセスしようとしたら、以下のエラー

Host not in allowlist

が出て手間取ったので、解決方法を備忘録として残しておきます。

routine は Anthropic のクラウド上で実行されるため、デフォルトでアクセスできるドメインが制限されています。script.google.com はその制限に含まれていないようです。


動作環境

  • Claude Code Web(claude.ai/code)
  • routine 機能(Scheduled Agent)

解決方法

カスタムネットワーク環境を作成して、routine に割り当てます。

  1. claude.ai/code を開く
  2. 左メニューの「Routines」をクリック
  3. 対象の routine を開く
  4. 右上の**編集アイコン(鉛筆)**をクリック
  5. 右下の「☁ Default」をクリック
  6. + 環境を追加」をクリック
  7. 以下を設定して「環境を作成」をクリック
項目
名前 任意(例: analytics
ネットワークアクセス カスタム
許可されたドメイン アクセスしたいドメインを1行ずつ
一般的なパッケージマネージャーのデフォルトリストも含める ✅ チェックを入れる
  1. 作成後、routine の編集画面で「☁ Default」→ 新しい環境名 に変更して保存

Google Apps Script にアクセスする場合は以下の2ドメインを追加すればよいと思います。

script.google.com
script.googleusercontent.com

注意点

  • 「一般的なパッケージマネージャーのデフォルトリストも含める」のチェックを入れ忘れると、npm / PyPI 等へのアクセスも遮断されます
  • デフォルト(Trusted)環境には GitHub や *.googleapis.com などはすでに含まれています。script.google.comgoogleapis.com とは別ドメインなので、含まれていないようです
  • カスタム環境はアカウント全体で共有されるため、複数の routine で使い回せます

まとめ

routine のネットワーク制限に関しての情報は、調べるまで気づきませんでした。公式ドキュメントを読むのは大事。
外部 API、特にClaude で GAS にアクセスする routine を作るときは、最初にカスタム環境を設定しておくのがおすすめです。

参考サイト

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?