Spaces:
Runtime error
Runtime error
Update mcp_task_client.py
Browse files- mcp_task_client.py +5 -5
mcp_task_client.py
CHANGED
|
@@ -11,17 +11,17 @@ async def run():
|
|
| 11 |
# Get task description suggestion using prompt
|
| 12 |
print("Getting prompt...")
|
| 13 |
prompt_result = await session.get_prompt("task_description", {"task_title": "Do shopping"})
|
| 14 |
-
print(f"
|
| 15 |
|
| 16 |
# Display all tasks
|
| 17 |
-
print("
|
| 18 |
response = await session.read_resource("tasks://list")
|
| 19 |
tasks = json.loads(json.loads(response.contents[0].text)['contents'][0]['text'])
|
| 20 |
for task in tasks['tasks']:
|
| 21 |
print(f"• {task['title']}: {task['description']}")
|
| 22 |
|
| 23 |
|
| 24 |
-
print("
|
| 25 |
# Add a new task
|
| 26 |
await session.call_tool("add_task", {
|
| 27 |
"params": {
|
|
@@ -29,10 +29,10 @@ async def run():
|
|
| 29 |
"description": "Order lunch from the local restaurant"
|
| 30 |
}
|
| 31 |
})
|
| 32 |
-
print("Task added!
|
| 33 |
|
| 34 |
|
| 35 |
-
print("
|
| 36 |
# Display again all tasks
|
| 37 |
response = await session.read_resource("tasks://list")
|
| 38 |
tasks = json.loads(json.loads(response.contents[0].text)['contents'][0]['text'])
|
|
|
|
| 11 |
# Get task description suggestion using prompt
|
| 12 |
print("Getting prompt...")
|
| 13 |
prompt_result = await session.get_prompt("task_description", {"task_title": "Do shopping"})
|
| 14 |
+
print(f"Suggested description: {prompt_result.messages[0].content.text}")
|
| 15 |
|
| 16 |
# Display all tasks
|
| 17 |
+
print("\nDisplaying all tasks...")
|
| 18 |
response = await session.read_resource("tasks://list")
|
| 19 |
tasks = json.loads(json.loads(response.contents[0].text)['contents'][0]['text'])
|
| 20 |
for task in tasks['tasks']:
|
| 21 |
print(f"• {task['title']}: {task['description']}")
|
| 22 |
|
| 23 |
|
| 24 |
+
print("\nAdding new task....")
|
| 25 |
# Add a new task
|
| 26 |
await session.call_tool("add_task", {
|
| 27 |
"params": {
|
|
|
|
| 29 |
"description": "Order lunch from the local restaurant"
|
| 30 |
}
|
| 31 |
})
|
| 32 |
+
print("Task added!")
|
| 33 |
|
| 34 |
|
| 35 |
+
print("\nDisplaying all tasks again...")
|
| 36 |
# Display again all tasks
|
| 37 |
response = await session.read_resource("tasks://list")
|
| 38 |
tasks = json.loads(json.loads(response.contents[0].text)['contents'][0]['text'])
|