OpenAICloudflare Developer PlatformJul 13, 2026, 12:00 AM

Agents, Workers - Agents can respond to MCP elicitation requests

A condensed section focused on the key takeaways first.

Original Post

Quick Digest

Summary

A condensed section focused on the key takeaways first.

openaienmodel: gpt-5-mini-2025-08-07

Agents can respond to MCP elicitation requests

Key Points

  • Agents support MCP elicitation (form and url)
  • Register handlers with mcp.configureElicitationHandlers in onStart
  • Advertised modes persist through Durable Object hibernation

Summary

Agents connected to MCP servers via addMcpServer can now handle MCP elicitation ↗ requests. Two modes are supported:

  • form: collect structured, non-sensitive data from the user
  • url: request consent before opening an out-of-band flow (e.g., third‑party auth or payment)

Key Points

  • Register handlers in onStart with this.mcp.configureElicitationHandlers({ form: (req, serverId) => ..., url: (req, serverId) => ... }). Handlers should return a Promise resolving an ElicitResult.
  • Only modes with configured handlers are advertised to the MCP server; an Agent with no handlers advertises no elicitation capability and the server may use a fallback.
  • Advertised modes are persisted with each MCP server registration so they survive Durable Object hibernation; callback functions are kept in memory and reattach when onStart() runs.
  • Examples: refer to the mcp-client and mcp-elicitation examples for server/client flow and a browser forwarding pattern.
  • Upgrade: install the latest SDK (e.g. npm i agents@latest, yarn add agents@latest, pnpm add agents@latest, or bun add agents@latest).

Implementation tip: show the elicitation request in your UI, resolve with accept, decline, or cancel, and for url mode open the URL only after explicit user consent.

Full Translation

Translations

A translation section that keeps the flow of the original article.

openaijamodel: gpt-5-mini-2025-08-07

Agents、Workers — Agents が MCP のエリシテーション要求に応答可能に

Changelog — Cloudflare の新しい更新と改善

公開日: 2026-07-13

概要

Agents が Model Context Protocol (MCP) サーバーへ addMcpServer で接続している場合、サーバーからの「elicitation ↗」要求を処理できるようになりました。

  • エリシテーションは、MCP サーバーがツール呼び出しを処理中にユーザー入力を要求するための仕組みです。
  • form モードは構造化された非機密データを収集します。
  • url モードは、サードパーティの認可や支払いなどのアウトオブバンドフローを開く前に同意を求めます。

シーケンス(概要)

  • Server -> Agent: elicitation/create
  • Agent -> User: サーバー情報・理由・入力またはURLを表示
  • User -> Agent: 提出(Submit)、開く(Open)、拒否(Decline)、またはキャンセル(Cancel)
  • Agent -> Browser: 同意後に URL を開く(URL モード)
  • Agent -> Server: acceptdecline、または cancel
  • Server ->> Agent: 任意の URL 完了通知

ハンドラーの登録

サポートする各モードについて、onStart() 内でハンドラーを登録してください。接続は、設定されたハンドラーがあるモードのみを広告(advertise)します。ハンドラーが無い Agent はエリシテーション機能を広告しないため、サーバーはフォールバックを使用できます。

SDK は MCP サーバー登録ごとに広告されたモードを保存するので、Durable Object のハイバネーションをまたいで保持されます。コールバック関数はメモリ上に残り、onStart() が再実行されると再アタッチされます。

JavaScript 例

import { Agent } from "agents";

export class MyAgent extends Agent {
  onStart() {
    this.mcp.configureElicitationHandlers({
      form: (request, serverId) => this.forwardToUser(request, serverId),
      url: (request, serverId) => this.forwardToUser(request, serverId),
    });
  }

  forwardToUser(request, serverId) {
    // UI にリクエストを表示し、ユーザーの応答後に解決するように実装します。
    throw new Error(`Implement elicitation for ${serverId}: ${request.params.message}`);
  }
}

TypeScript 例

import { Agent } from "agents";
import type { ElicitRequest, ElicitResult } from "agents/mcp";

export class MyAgent extends Agent<Env> {
  onStart() {
    this.mcp.configureElicitationHandlers({
      form: (request, serverId) => this.forwardToUser(request, serverId),
      url: (request, serverId) => this.forwardToUser(request, serverId),
    });
  }

  private forwardToUser(request: ElicitRequest, serverId: string): Promise<ElicitResult> {
    // UI にリクエストを表示し、ユーザーの応答後に Promise を解決する実装を行ってください。
    throw new Error(`Implement elicitation for ${serverId}: ${request.params.message}`);
  }
}

実装の詳細と参考

  • 実装の詳細およびブラウザへの転送パターンについては「MCP client elicitation ↗」を参照してください。
  • mcp-client ↗mcp-elicitation ↗ のサンプルは、サーバー側とクライアント側の双方(両方の側面)を実装しています。

アップグレード

このリリースにアップデートするには、以下のいずれかのコマンドを使用してください:

  • npm i agents@latest
  • yarn add agents@latest
  • pnpm add agents@latest
  • bun add agents@latest

その他

  • 接続時に広告されるモードは、configureElicitationHandlers に登録したハンドラーに基づきます。
  • Durable Object のハイバネーション後も設定は保持され、コールバックは onStart() 実行時に再アタッチされます。

参照: Cloudflare ドキュメント、API リファレンス、該当サンプルプロジェクト(mcp-clientmcp-elicitation)。

© 2026 Cloudflare, Inc. プライバシーポリシー | 利用規約 | セキュリティ問題の報告 | 商標情報

Agents, Workers - Agents can respond to MCP elicitation requests | Cloudflare Developer Platform | DocsDigest