@@ -83,6 +83,20 @@ class SessionDeps:
8383 documentation_urls : str
8484 functional_requirements : str
8585 test_list : str
86+ from typing import Annotated , Any , Callable
87+
88+ @dataclass
89+ class SessionDeps :
90+ """Dependencies containing the current webapp session state."""
91+
92+ yaml_content : str
93+ connector_name : str
94+ source_api_name : str
95+ documentation_urls : str
96+ functional_requirements : str
97+ test_list : str
98+ set_source_api_name : Callable [[str ], Any ] | None = None
99+ set_connector_name : Callable [[str ], Any ] | None = None
86100
87101
88102mcp_server = MCPServerStdio (
@@ -357,4 +371,64 @@ def replace_manifest_lines(
357371 except Exception as e :
358372 return f"Error replacing lines in manifest: { str (e )} "
359373
374+ @agent .tool
375+ def set_api_name (
376+ ctx : RunContext [SessionDeps ],
377+ api_name : Annotated [
378+ str , Field (description = "The name of the API (e.g., 'JSONPlaceholder API')" )
379+ ],
380+ ) -> str :
381+ """Set the Source API Name in the requirements form.
382+
383+ Use this tool when the user tells you what API they want to build a connector for.
384+ This will populate the 'Source API name' field in the Define Requirements tab.
385+
386+ Args:
387+ ctx: Runtime context with session dependencies
388+ api_name: The name of the API
389+
390+ Returns:
391+ A confirmation message indicating success.
392+ """
393+ try :
394+ if ctx .deps .set_source_api_name :
395+ ctx .deps .set_source_api_name (api_name )
396+ return f"Successfully set the Source API Name to '{ api_name } ' in the requirements form."
397+ else :
398+ return "Error: Unable to update Source API Name (callback not available)"
399+ except Exception as e :
400+ return f"Error setting API name: { str (e )} "
401+
402+ @agent .tool
403+ def set_connector_name (
404+ ctx : RunContext [SessionDeps ],
405+ connector_name : Annotated [
406+ str ,
407+ Field (
408+ description = "The connector name in the format 'source-{name}' (e.g., 'source-jsonplaceholder')"
409+ ),
410+ ],
411+ ) -> str :
412+ """Set the Connector Name in the requirements form.
413+
414+ Use this tool to populate the 'Connector name' field in the Define Requirements tab.
415+ The connector name should follow the format 'source-{name}' where {name} is derived
416+ from the API name (e.g., 'JSONPlaceholder API' -> 'source-jsonplaceholder').
417+
418+ Args:
419+ ctx: Runtime context with session dependencies
420+ connector_name: The connector name in source-{name} format
421+
422+ Returns:
423+ A confirmation message indicating success.
424+ """
425+ try :
426+ if ctx .deps .set_connector_name :
427+ ctx .deps .set_connector_name (connector_name )
428+ return f"Successfully set the Connector Name to '{ connector_name } ' in the requirements form."
429+ else :
430+ return "Error: Unable to update Connector Name (callback not available)"
431+ except Exception as e :
432+ return f"Error setting connector name: { str (e )} "
433+
360434 return agent
0 commit comments