Code Velocity
AI สำหรับองค์กร

Amazon Bedrock: ความสามารถของไคลเอนต์ MCP แบบ Stateful บน AgentCore Runtime

·7 นาทีอ่าน·AWS·แหล่งที่มา
แชร์
แผนภาพที่แสดงความสามารถของไคลเอนต์ MCP แบบ stateful บน Amazon Bedrock AgentCore Runtime พร้อมโฟลว์ของเอเจนต์ AI แบบโต้ตอบ

นอกเหนือจากแฟล็กนี้แล้ว ความสามารถของไคลเอนต์ทั้งสามจะพร้อมใช้งานโดยอัตโนมัติเมื่อไคลเอนต์ MCP ประกาศการสนับสนุนสำหรับความสามารถเหล่านั้นระหว่างการจับมือเริ่มต้น

เจาะลึกความสามารถไคลเอนต์ใหม่: Elicitation, Sampling และ Progress

ด้วยการเปลี่ยนไปใช้โหมด stateful, Amazon Bedrock AgentCore Runtime ได้ปลดล็อกความสามารถของไคลเอนต์ที่ทรงพลังสามประการจากข้อกำหนด MCP โดยแต่ละความสามารถได้รับการออกแบบมาเพื่อจัดการรูปแบบการโต้ตอบที่แตกต่างกันซึ่งมีความสำคัญต่อเอเจนต์ AI ขั้นสูง ความสามารถเหล่านี้เปลี่ยนจากการดำเนินการคำสั่งแบบทางเดียวที่ตายตัวไปสู่การสนทนาแบบสองทางที่ลื่นไหลระหว่างเซิร์ฟเวอร์ MCP และไคลเอนต์ที่เชื่อมต่อ สิ่งสำคัญคือต้องทราบว่าคุณสมบัติเหล่านี้เป็นแบบเลือกใช้ (opt-in) ซึ่งหมายความว่าไคลเอนต์จะประกาศการสนับสนุนของตนในระหว่างการเริ่มต้น และเซิร์ฟเวอร์จะต้องใช้เฉพาะความสามารถที่ไคลเอนต์ที่เชื่อมต่อได้ประกาศไว้เท่านั้น

Elicitation: การเปิดใช้งานข้อมูลจากผู้ใช้แบบไดนามิกในเอเจนต์ AI

Elicitation ถือเป็นรากฐานสำคัญของ AI แบบโต้ตอบ ซึ่งช่วยให้เซิร์ฟเวอร์ MCP สามารถหยุดการทำงานชั่วคราวอย่างรอบคอบ และร้องขอข้อมูลเฉพาะที่มีโครงสร้างจากผู้ใช้ผ่านไคลเอนต์ ความสามารถนี้ช่วยให้เครื่องมือสามารถถามคำถามที่แม่นยำในเวลาที่เหมาะสมในขั้นตอนการทำงานของตน ไม่ว่าจะเป็นการยืนยันการตัดสินใจ รวบรวมความชอบของผู้ใช้ หรือรวบรวมค่าที่ได้จากการดำเนินการก่อนหน้า เซิร์ฟเวอร์จะเริ่มต้นด้วยการส่งคำขอ elicitation/create แบบ JSON-RPC ซึ่งรวมถึงข้อความที่อ่านง่ายสำหรับมนุษย์และ requestedSchema ที่เป็นทางเลือก ซึ่งอธิบายโครงสร้างการตอบกลับที่คาดหวัง

ข้อกำหนด MCP มีสองโหมดที่แข็งแกร่งสำหรับการเรียกข้อมูล:

  • โหมดฟอร์ม (Form mode): เหมาะสำหรับการรวบรวมข้อมูลที่มีโครงสร้างโดยตรงผ่านไคลเอนต์ MCP เช่น พารามิเตอร์การกำหนดค่า ความชอบของผู้ใช้ หรือการยืนยันง่ายๆ ที่ไม่มีข้อมูลที่ละเอียดอ่อนเกี่ยวข้อง
  • โหมด URL (URL mode): สำหรับการโต้ตอบที่จำเป็นต้องมีกระบวนการที่ปลอดภัยและนอกช่องทาง เช่น โฟลว์ OAuth การประมวลผลการชำระเงิน หรือการป้อนข้อมูลรับรองที่ละเอียดอ่อน โหมด URL จะนำผู้ใช้ไปยัง URL ภายนอก สิ่งนี้ช่วยให้มั่นใจว่าข้อมูลที่ละเอียดอ่อนจะข้ามไคลเอนต์ MCP ไปทั้งหมด ซึ่งช่วยเพิ่มความปลอดภัยและการปฏิบัติตามข้อกำหนด

เมื่อได้รับคำขอเรียกข้อมูล ไคลเอนต์จะแสดงอินเทอร์เฟซสำหรับป้อนข้อมูลที่เหมาะสม การดำเนินการของผู้ใช้ที่ตามมาจะกระตุ้นรูปแบบการตอบกลับสามการกระทำกลับไปยังเซิร์ฟเวอร์: accept (ผู้ใช้ให้ข้อมูลที่ร้องขอ), decline (ผู้ใช้ปฏิเสธคำขออย่างชัดเจน) หรือ cancel (ผู้ใช้ยกเลิกพร้อมต์โดยไม่เลือก) เซิร์ฟเวอร์อัจฉริยะได้รับการออกแบบมาเพื่อจัดการแต่ละสถานการณ์เหล่านี้ได้อย่างราบรื่น เพื่อให้มั่นใจถึงประสบการณ์ที่แข็งแกร่งและเป็นมิตรกับผู้ใช้ ตัวอย่างเช่น เครื่องมือ add_expense_interactive ดังที่แสดงในเอกสารต้นฉบับ สามารถนำผู้ใช้ผ่านชุดคำถาม—จำนวนเงิน คำอธิบาย หมวดหมู่ และการยืนยันขั้นสุดท้าย—ก่อนที่จะส่งข้อมูลไปยังแบ็กเอนด์ เช่น Amazon DynamoDB แต่ละขั้นตอนใช้โมเดล Pydantic เพื่อกำหนดอินพุตที่คาดหวัง ซึ่ง FastMCP จะแปลงเป็น JSON Schema ที่จำเป็นสำหรับคำขอ elicitation/create ได้อย่างราบรื่น

Sampling และ Progress Notifications: เพิ่มปฏิสัมพันธ์ของ LLM และความโปร่งใส

นอกเหนือจากการโต้ตอบโดยตรงกับผู้ใช้แล้ว Sampling ยังช่วยให้เซิร์ฟเวอร์ MCP มีความสามารถในการร้องขอเนื้อหาที่สร้างโดยโมเดลภาษาขนาดใหญ่ (LLM) ที่ซับซ้อนได้โดยตรงจากไคลเอนต์ผ่าน sampling/createMessage นี่เป็นกลไกที่สำคัญเนื่องจากช่วยให้ตรรกะของเครื่องมือบนเซิร์ฟเวอร์สามารถใช้ประโยชน์จากความสามารถของโมเดลภาษาที่ทรงพลังโดยไม่จำเป็นต้องจัดการข้อมูลประจำตัว LLM ของตนเอง หรือการผสานรวม API โดยตรง เซิร์ฟเวอร์เพียงแค่ให้พร้อมต์และค่ากำหนดโมเดลเสริม และไคลเอนต์ซึ่งทำหน้าที่เป็นตัวกลาง จะส่งต่อคำขอนี้ไปยัง LLM ที่เชื่อมต่อและส่งคืนการตอบกลับที่สร้างขึ้น สิ่งนี้เปิดโอกาสให้เกิดแอปพลิเคชันเชิงปฏิบัติมากมาย รวมถึงการสร้างสรุปส่วนบุคคล การสร้างคำอธิบายภาษาธรรมชาติจากข้อมูลที่มีโครงสร้างที่ซับซ้อน หรือการสร้างคำแนะนำที่คำนึงถึงบริบทจากการสนทนาที่กำลังดำเนินอยู่

สำหรับการดำเนินการที่ใช้เวลานาน Progress Notifications จะมีคุณค่าอย่างยิ่ง ความสามารถนี้ช่วยให้เซิร์ฟเวอร์ MCP สามารถรายงานการอัปเดตแบบเพิ่มทีละน้อยระหว่างงานที่ใช้เวลานานได้ ด้วยการใช้ ctx.report_progress(progress, total) เซิร์ฟเวอร์สามารถส่งการอัปเดตอย่างต่อเนื่องที่ไคลเอนต์สามารถแปลเป็นข้อมูลภาพ เช่น แถบความคืบหน้า หรือตัวบ่งชี้สถานะ ไม่ว่าจะเป็นการค้นหาข้อมูลจากแหล่งข้อมูลขนาดใหญ่ หรือการดำเนินการคำนวณที่ซับซ้อน การอัปเดตความคืบหน้าที่โปร่งใสช่วยให้ผู้ใช้ได้รับข้อมูลอยู่เสมอ ป้องกันความหงุดหงิด และยกระดับประสบการณ์ของผู้ใช้โดยรวม แทนที่จะปล่อยให้พวกเขานั่งจ้องหน้าจอว่างเปล่าโดยไม่รู้ว่าระบบยังทำงานอยู่หรือไม่

การพัฒนาเอเจนต์ AI ที่พร้อมสำหรับอนาคตด้วย Bedrock AgentCore Runtime

การนำความสามารถของไคลเอนต์ MCP แบบ stateful มาใช้บน Amazon Bedrock AgentCore Runtime ถือเป็นก้าวสำคัญในการพัฒนาเอเจนต์ AI ด้วยการเปลี่ยนการโต้ตอบแบบ stateless เดิมให้เป็นการสนทนาแบบไดนามิกและสองทิศทาง AWS จึงช่วยให้นักพัฒนาสามารถสร้างแอปพลิเคชัน AI ที่ชาญฉลาด ตอบสนองได้ดีขึ้น และเป็นมิตรกับผู้ใช้มากขึ้น ความสามารถเหล่านี้—Elicitation สำหรับการป้อนข้อมูลโดยผู้ใช้ที่ได้รับการแนะนำ, Sampling สำหรับการสร้าง LLM ตามความต้องการ, และ Progress Notifications สำหรับความโปร่งใสแบบเรียลไทม์—ร่วมกันปลดล็อกยุคใหม่ของเวิร์กโฟลว์เอเจนต์แบบโต้ตอบ ในขณะที่ AI ยังคงพัฒนาอย่างต่อเนื่อง ความสามารถพื้นฐานเหล่านี้จะมีความสำคัญอย่างยิ่งต่อการสร้าง operationalizing agentic AI ที่ซับซ้อน ซึ่งสามารถรวมเข้ากับกระบวนการทางธุรกิจที่ซับซ้อน ปรับให้เข้ากับความต้องการของผู้ใช้ และมอบคุณค่าที่ยอดเยี่ยมได้อย่างราบรื่น

คำถามที่พบบ่อย

What problem do stateful MCP client capabilities solve on Amazon Bedrock AgentCore Runtime?
Stateful Model Context Protocol (MCP) client capabilities on Amazon Bedrock AgentCore Runtime address the critical limitations of previous stateless AI agent implementations. Stateless agents struggled with interactive, multi-turn workflows, as they couldn't pause mid-execution to solicit user input for clarification, request dynamic large language model (LLM)-generated content, or provide real-time progress updates during lengthy operations. Each request was independent, lacking shared context. This new feature fundamentally transforms agent interactions by enabling bidirectional conversations, allowing agents to maintain conversational threads, gather necessary input precisely when needed, generate dynamic content on the fly, and transparently inform users about ongoing processes. This leads to the development of significantly more responsive, intelligent, and user-centric AI applications capable of complex, adaptive workflows.
How does the transition from stateless to stateful mode work on AgentCore Runtime?
The transition to stateful mode within Amazon Bedrock AgentCore Runtime is initiated by a simple configuration adjustment: setting `stateless_http=False` when starting your MCP server. Once enabled, AgentCore Runtime provisions a dedicated microVM for each individual user session. This microVM is designed for persistence throughout the session's duration, which can last up to 8 hours or expire after 15 minutes of inactivity, ensuring isolated CPU, memory, and filesystem resources for each session. Continuity across interactions is maintained through a unique `Mcp-Session-Id` header. This ID is established during the initial handshake and subsequently included by the client in all follow-up requests, ensuring they are accurately routed back to the correct, persistent session, thereby preserving context and enabling complex, interactive dialogues.
What is Elicitation, and how does it enhance AI agent interactions?
Elicitation is a powerful stateful MCP capability that allows an AI agent (acting as the MCP server) to intelligently pause its ongoing execution and request specific, structured input directly from the user via the client. This significantly enhances interactive agent workflows by enabling agents to ask targeted questions at precise, opportune moments within their operational flow. For example, an agent might use elicitation to confirm a decision, gather user preferences, or collect particular data values that are contingent on preceding steps. The feature supports two robust modes: 'Form mode' for direct structured data collection through the MCP client, and 'URL mode' for secure, out-of-band interactions that require directing the user to an external URL (e.g., for OAuth or sensitive credential entry). The user's response – whether accepting, declining, or canceling the request – is then returned to the server, allowing the agent to dynamically adapt its workflow based on real-time human feedback.
How does Sampling capability benefit AI agents without managing LLM credentials?
Sampling equips the MCP server with the ability to request sophisticated large language model (LLM)-generated content directly from the client using the `sampling/createMessage` mechanism. A key benefit is that the MCP server itself does not need to manage its own LLM credentials, API keys, or direct integrations with various LLM providers. Instead, the server simply provides a well-formed prompt and any optional model preferences to the client. The client then acts as an intelligent intermediary, forwarding this request to its connected LLM and returning the generated response back to the server. This abstraction allows AI agents to seamlessly leverage powerful language model capabilities for tasks such as crafting personalized summaries, generating natural-language explanations from complex structured data, or producing context-aware recommendations, all while simplifying the operational overhead and security concerns associated with LLM management on the server side.

อัปเดตข่าวสาร

รับข่าว AI ล่าสุดในกล่องจดหมายของคุณ

แชร์