cloudflare-agents について
Cloudflare上でLLMアプリケーションを開発する人向けのエージェント構築ガイドです。ツール登録、プロバイダー、Cloudflareバインディング、MCP連携、実装テンプレートを扱います。
主な機能
- 01ツールの登録と実行
- 02OpenAI、Anthropic、Geminiのプロバイダー
- 03Cloudflare D1、KV、R2、Durable Objects
- 04HTTP、SSE、WebSocketのパターン
- 05状態管理とスケジュールタスク
- 06エージェントとMCP連携のテンプレート
活用シーン
- 01登録済みツールを呼び出すエージェントの構築
- 02エージェントとCloudflareストレージバインディングの接続
- 03ストリーミングまたはWebSocketのエージェント画面の実装
- 04CloudflareエージェントへのMCP連携の追加
MCP 対応
MCPプロトコルのサポートを扱い、MCP連携のリファレンスと、MCPサーバーをエージェントに接続するテンプレートを提供します。
インストール
コマンドをコピーしてターミナルで実行します。
$
npx skills add https:/ / github.com/ secondsky/ claude-skills --skill cloudflare-agentsインストール後、Claude Code で/cloudflare-agentsを入力して読み込まれたか確認します。
同梱ファイル
SKILL.md と一緒にインストールされる参考資料やスクリプト。
references/advanced-features.mdagent-api.mdconfiguration-guide.mderror-catalog.mdhttp-sse-guide.mdmcp-integration.mdpatterns-concepts.mdstate-management.mdwebsockets-guide.mdtemplates/basic-agent.tsbrowser-agent.tscalling-agents-worker.tschat-agent-streaming.tshitl-agent.tsmcp-server-basic.tsrag-agent.tsreact-useagent-client.tsxscheduled-agent.tsstate-sync-agent.tswebsocket-agent.tsworkflow-agent.tswrangler-agents-config.jsonc詳細
Cloudflare Agents
最終更新日:2025-11-21
クイックスタート
export default {
async fetch(request, env, ctx) {
const agent = {
tools: [
{ name: 'getTodo', handler: async ({id}) => ({id, title: 'Task'}) }
],
async run(input) {
return await processWithLLM(input, this.tools);
}
};
return Response.json(await agent.run(await request.text()));
}
};
主な機能
- ツール統合:ツールの登録と実行
- LLM プロバイダー:OpenAI、Anthropic、Google Gemini
- MCP プロトコル:Model Context Protocol に対応
- Cloudflare バインディング:D1、KV、R2、Durable Objects
エージェントパターン
const agent = {
tools: [...],
systemPrompt: 'You are a helpful assistant',
model: 'gpt-4o',
async run(input) {
// Process with LLM
}
};
リソース
コアドキュメント
references/patterns-concepts.md(317 lines) - Cloudflare Agents とは何か、パターンと概念、重要なルール、既知の問題の防止策references/configuration-guide.md(152 lines) - 設定の詳細な解説references/agent-api.md(115 lines) - Agent Class API の完全なリファレンス
統合ガイド
references/http-sse-guide.md(74 lines) - HTTP と Server-Sent Eventsreferences/websockets-guide.md(110 lines) - WebSocket の統合references/state-management.md(388 lines) - 状態管理、スケジュールされたタスク、ワークフローreferences/mcp-integration.md(130 lines) - Model Context Protocol の統合
高度な機能
references/advanced-features.md(637 lines) - ブラウザー自動化、RAG、AI モデルの統合、エージェントの呼び出し、クライアント API
エラーリファレンス
references/error-catalog.md(10 lines) - よくあるエラーと解決策
テンプレート
templates/basic-agent.ts- 基本的なエージェントのセットアップtemplates/browser-agent.ts- ブラウザー自動化templates/calling-agents-worker.ts- 他のエージェントの呼び出しtemplates/chat-agent-streaming.ts- ストリーミングチャットエージェントtemplates/hitl-agent.ts- ヒューマン・イン・ザ・ループtemplates/mcp-server-basic.ts- MCP サーバーの統合templates/rag-agent.ts- RAG の実装templates/react-useagent-client.tsx- React クライアントの統合templates/scheduled-agent.ts- スケジュールされたタスクtemplates/state-sync-agent.ts- 状態の同期templates/websocket-agent.ts- WebSocket エージェントtemplates/workflow-agent.ts- ワークフローの統合templates/wrangler-agents-config.jsonc- Wrangler の設定
公式ドキュメント:https://developers.cloudflare.com/cloudflare-for-platforms/cloudflare-agents/
コメント
Markdown 対応