pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/BlocksecPHD/python-sdk/tree/main/examples/servers/simple-task-interactive

thub.githubassets.com/assets/primer-bf8570e4081bd07e.css" /> python-sdk/examples/servers/simple-task-interactive at main · BlocksecPHD/python-sdk · GitHub
Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

README.md

Simple Interactive Task Server

A minimal MCP server demonstrating interactive tasks with elicitation and sampling.

Running

cd examples/servers/simple-task-interactive
uv run mcp-simple-task-interactive

The server starts on http://localhost:8000/mcp by default. Use --port to change.

What it does

This server exposes two tools:

confirm_delete (demonstrates elicitation)

Asks the user for confirmation before "deleting" a file.

  • Uses task.elicit() to request user input
  • Shows the elicitation flow: task -> input_required -> response -> complete

write_haiku (demonstrates sampling)

Asks the LLM to write a haiku about a topic.

  • Uses task.create_message() to request LLM completion
  • Shows the sampling flow: task -> input_required -> response -> complete

Usage with the client

In one terminal, start the server:

cd examples/servers/simple-task-interactive
uv run mcp-simple-task-interactive

In another terminal, run the interactive client:

cd examples/clients/simple-task-interactive-client
uv run mcp-simple-task-interactive-client

Expected server output

When a client connects and calls the tools, you'll see:

Starting server on http://localhost:8000/mcp

[Server] confirm_delete called for 'important.txt'
[Server] Task created: <task-id>
[Server] Sending elicitation request to client...
[Server] Received elicitation response: action=accept, content={'confirm': True}
[Server] Completing task with result: Deleted 'important.txt'

[Server] write_haiku called for topic 'autumn leaves'
[Server] Task created: <task-id>
[Server] Sending sampling request to client...
[Server] Received sampling response: Cherry blossoms fall
Softly on the quiet pon...
[Server] Completing task with haiku

Key concepts

  1. ServerTaskContext: Provides elicit() and create_message() for user interaction
  2. run_task(): Spawns background work, auto-completes/fails, returns immediately
  3. TaskResultHandler: Delivers queued messages and routes responses
  4. Response routing: Responses are routed back to waiting resolvers
pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy