@@ -58,18 +58,18 @@ def main():
5858 print ("Connecting to MCPServer 'weather'..." )
5959
6060 client = DaprMCPClient (timeout_in_seconds = 30 )
61- client .connect (" weather" )
61+ client .connect (' weather' )
6262
6363 tools = client .get_all_tools ()
64- print (f" \n Discovered { len (tools )} tool(s):\n " )
64+ print (f' \n Discovered { len (tools )} tool(s):\n ' )
6565 for tool in tools :
66- print (f" Name: { tool .name } " )
67- print (f" Description: { tool .description } " )
68- print (f" Server: { tool .server_name } " )
69- print (f" Workflow: { tool .call_tool_workflow } " )
70- if tool .input_schema .get (" properties" ):
71- props = list (tool .input_schema [" properties" ].keys ())
72- print (f" Parameters: { ', ' .join (props )} " )
66+ print (f' Name: { tool .name } ' )
67+ print (f' Description: { tool .description } ' )
68+ print (f' Server: { tool .server_name } ' )
69+ print (f' Workflow: { tool .call_tool_workflow } ' )
70+ if tool .input_schema .get (' properties' ):
71+ props = list (tool .input_schema [' properties' ].keys ())
72+ print (f' Parameters: { ", " .join (props )} ' )
7373 print ()
7474
7575 # ------------------------------------------------------------------
@@ -78,35 +78,33 @@ def main():
7878 # durable tool calls via child workflows.
7979 # ------------------------------------------------------------------
8080 if not tools :
81- print (" No tools discovered — exiting." )
81+ print (' No tools discovered — exiting.' )
8282 return
8383
8484 tool = tools [0 ]
8585 print (f"Using tool '{ tool .name } ' in a workflow...\n " )
8686
8787 # Build a Pydantic model from the tool's JSON Schema for validation.
8888 if tool .input_schema :
89- ArgsModel = create_pydantic_model_from_schema (
90- tool .input_schema , f"{ tool .name } Args"
91- )
92- print (f" Args model: { ArgsModel .__name__ } " )
93- print (f" Fields: { list (ArgsModel .model_fields .keys ())} \n " )
89+ ArgsModel = create_pydantic_model_from_schema (tool .input_schema , f'{ tool .name } Args' )
90+ print (f' Args model: { ArgsModel .__name__ } ' )
91+ print (f' Fields: { list (ArgsModel .model_fields .keys ())} \n ' )
9492
9593 # Define a simple workflow that calls the MCP tool.
9694 def call_mcp_tool_workflow (ctx : DaprWorkflowContext , input : dict ):
9795 """Workflow that calls an MCP tool as a child workflow."""
9896 result = yield ctx .call_child_workflow (
9997 workflow = tool .call_tool_workflow ,
10098 input = {
101- " toolName" : tool .name ,
102- " arguments" : input .get (" arguments" , {}),
99+ ' toolName' : tool .name ,
100+ ' arguments' : input .get (' arguments' , {}),
103101 },
104102 )
105103 return result
106104
107105 def print_result (ctx : WorkflowActivityContext , input ):
108106 """Activity that prints the tool result."""
109- print (f" Tool result: { input } " )
107+ print (f' Tool result: { input } ' )
110108
111109 # Register and run the workflow.
112110 wfr = WorkflowRuntime ()
@@ -117,9 +115,9 @@ def print_result(ctx: WorkflowActivityContext, input):
117115 wf_client = DaprWorkflowClient ()
118116 instance_id = wf_client .schedule_new_workflow (
119117 workflow = call_mcp_tool_workflow ,
120- input = {" arguments" : {" location" : " Seattle" }},
118+ input = {' arguments' : {' location' : ' Seattle' }},
121119 )
122- print (f" Scheduled workflow: { instance_id } " )
120+ print (f' Scheduled workflow: { instance_id } ' )
123121
124122 state = wf_client .wait_for_workflow_completion (
125123 instance_id = instance_id ,
@@ -128,14 +126,14 @@ def print_result(ctx: WorkflowActivityContext, input):
128126 )
129127
130128 if state :
131- print (f" Status: { state .runtime_status .name } " )
132- print (f" Output: { state .serialized_output } " )
129+ print (f' Status: { state .runtime_status .name } ' )
130+ print (f' Output: { state .serialized_output } ' )
133131 else :
134- print (" Workflow timed out." )
132+ print (' Workflow timed out.' )
135133
136134 wfr .shutdown ()
137- print (" \n Done." )
135+ print (' \n Done.' )
138136
139137
140- if __name__ == " __main__" :
138+ if __name__ == ' __main__' :
141139 main ()
0 commit comments