docs: restructure into topical sections and add the four most-asked-for pages (#3044)
This commit is contained in:
parent
080f2a869d
commit
220d362112
1 changed files with 2403 additions and 343 deletions
19
docs_src/troubleshooting/tutorial006.py
Normal file
19
docs_src/troubleshooting/tutorial006.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
from pydantic import BaseModel
|
||||
|
||||
from mcp.server import MCPServer
|
||||
from mcp.server.mcpserver import Context
|
||||
|
||||
mcp = MCPServer("Bistro")
|
||||
|
||||
|
||||
class Confirmation(BaseModel):
|
||||
confirm: bool
|
||||
|
||||
|
||||
@mcp.tool()
|
||||
async def book_table(date: str, ctx: Context) -> str:
|
||||
"""Book a table at the bistro."""
|
||||
result = await ctx.elicit(f"Book a table for {date}?", schema=Confirmation)
|
||||
if result.action == "accept" and result.data.confirm:
|
||||
return f"Booked for {date}."
|
||||
return "No booking made."
|
||||
Loading…
Reference in a new issue