This example demonstrates how MCP (Model Context Protocol) elicitation works in docker-agent. Elicitation allows MCP tools to request additional input from the user during tool execution.
Elicitation is an MCP feature that enables tools to interactively prompt users for information that wasn't provided in the initial tool call. For example:
- Asking for confirmation before destructive actions
- Requesting missing required parameters
- Gathering additional details when needed
agent.yaml- The agent configuration that uses the elicitation MCP serverserver.py- A Python MCP server that demonstrates various elicitation patternsREADME.md- This documentation
You need uvx (part of uv) installed:
# Install uv (includes uvx)
curl -LsSf https://astral.sh/uv/install.sh | shThe MCP SDK will be automatically installed when the server starts via uvx.
# From the docker-agent root directory
$ docker agent run examples/elicitation/agent.yamlThe example MCP server provides several tools that demonstrate different elicitation patterns:
Shows a basic yes/no confirmation dialog before performing an action.
Example prompt: "Confirm that I want to delete the database"
Demonstrates a multi-field form with validation:
- Required string fields (username, email, role)
- Optional fields (bio)
- Email format validation
- Enum/choice fields (role selection)
- Boolean fields (active status)
Example prompt: "Create a new user"
Shows number fields with min/max validation. Supports presets.
Example prompt: "Configure settings with performance preset"
Demonstrates multiple boolean fields with default values.
Example prompt: "Set up my preferences"
Shows multiple enum/dropdown fields for making selections.
Example prompt: "Help me select deployment options"
- Agent decides to call an MCP tool
- Tool execution starts
- Tool sends an elicitation request with a message and JSON schema
- docker-agent displays an interactive dialog based on the schema
- User fills in the form and submits (or cancels)
- Response is sent back to the tool
- Tool continues execution with the provided data
string- Text input (with optional format: email, uri, date, etc.)integer- Whole number inputnumber- Decimal number inputboolean- Yes/No toggleenum- Choice from predefined options (viaenumarray in schema)
Fields can include validation constraints:
required- Field must be filled (specified at schema level)minLength/maxLength- String length constraintsminimum/maximum- Number range constraintspattern- Regex pattern matchingformat- Built-in formats (email, uri, date)default- Default value for the field
You can test the MCP server directly:
# Test initialization
echo '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2024-11-05","capabilities":{},"clientInfo":{"name":"test","version":"1.0"}}}' | \
uvx --with "mcp[cli]" python examples/elicitation/server.pyWhen an elicitation dialog appears in the TUI:
- ↑/↓ or Tab/Shift+Tab - Navigate between fields
- Space - Toggle boolean fields
- Y/N - Set boolean to Yes/No
- Enter - Submit the form
- Esc - Cancel the elicitation