@@ -196,22 +196,28 @@ def tox_tool(package_path: str, environment: str, repo_path: str, tox_ini_path:
196196 return run_command (command , cwd = repo_path )
197197
198198@mcp .tool ("init" )
199- def init_tool (tsp_config_url : str , repo_path : str ) -> Dict [str , Any ]:
200- """Initializes and generates a typespec client library directory given the url .
199+ def init_tool (tsp_config_path : str , repo_path : str , is_local : bool = False ) -> Dict [str , Any ]:
200+ """Initializes a new typespec client library directory.
201201
202202 Args:
203- tsp_config_url: The URL to the tspconfig.yaml file.
204- repo_path: The path to the repository root (i.e. ./azure-sdk-for-python/).
203+ :param str tsp_config_path: Either the URL to the tspconfig.yaml file or the path to a local tspconfig.yaml file.
204+ :param str repo_path: The path to the repository root (i.e. ./azure-sdk-for-python/).
205+ :param bool is_local: Whether the tsp_config_path is a local file path (True) or a URL (False).
206+
205207 Returns:
206208 A dictionary containing the result of the command.
207209 """
208210 try :
209- # Get updated URL with latest commit hash
210- updated_url = get_latest_commit (tsp_config_url )
211+ config_path = tsp_config_path
212+
213+ # If not a local path, get updated URL with latest commit hash
214+ if not is_local and tsp_config_path .startswith ("http" ):
215+ config_path = get_latest_commit (tsp_config_path )
216+ logger .info (f"Using updated TypeSpec config URL with latest commit: { config_path } " )
211217
212218 # Run the init command using the combined function
213219 return run_command (["init" ], cwd = repo_path , is_typespec = True ,
214- typespec_args = {"tsp-config" : updated_url })
220+ typespec_args = {"tsp-config" : config_path })
215221
216222 except RuntimeError as e :
217223 return {
@@ -221,25 +227,42 @@ def init_tool(tsp_config_url: str, repo_path: str) -> Dict[str, Any]:
221227 "stderr" : "" ,
222228 "code" : 1
223229 }
230+
231+ @mcp .tool ("update" )
232+ def update_tool (package_path : str , commit_hash : Optional [str ] = None , repo : Optional [str ] = None ,
233+ tsp_config : Optional [str ] = None , local_spec_repo : Optional [str ] = None ) -> Dict [str , Any ]:
234+ """Updates an existing client library with local or remote TypeSpec changes.
224235
225- @mcp .tool ("init_local" )
226- def init_local_tool (tsp_config_path : str , repo_path :str ) -> Dict [str , Any ]:
227- """Initializes and subsequently generates a typespec client library directory from a local azure-rest-api-specs repo.
228-
229- This command is used to generate a client library from a local azure-rest-api-specs repository. No additional
230- commands are needed to generate the client library.
236+ This command is used to update an existing client library.
231237
232238 Args:
233- tsp_config_path: The path to the local tspconfig.yaml file.
234- repo_path: The path to the repository root (i.e. ./azure-sdk-for-python/).
239+ :param str package_path: The path to the directory of the tsp-location.yaml (i.e. ./azure-sdk-for-python/sdk/eventgrid/azure-eventgrid).
240+ :param Optional[str] commit_hash: Optional. The commit hash to update to.
241+ :param Optional[str] repo: Optional. Repository where the project is defined.
242+ :param Optional[str] tsp_config: Optional. Path to tspconfig.yaml.
243+ :param Optional[str] local_spec_repo: Optional. Path to local spec repo.
235244
236245 Returns:
237- A dictionary containing the result of the command. """
246+ A dictionary containing the result of the command.
247+ """
238248 try :
249+ # Build TypeSpec arguments
250+ typespec_args = {
251+ "output-dir" : package_path
252+ }
239253
240- # Run the init command with local path using the combined function
241- return run_command (["init" ], cwd = repo_path , is_typespec = True ,
242- typespec_args = {"tsp-config" : tsp_config_path })
254+ if commit_hash :
255+ typespec_args ["commit" ] = commit_hash
256+ if repo :
257+ typespec_args ["repo" ] = repo
258+ if tsp_config :
259+ typespec_args ["tsp-config" ] = tsp_config
260+ if local_spec_repo :
261+ typespec_args ["local-spec-repo" ] = local_spec_repo
262+
263+ # Run the update command
264+ return run_command (["update" ], cwd = package_path , is_typespec = True ,
265+ typespec_args = typespec_args )
243266
244267 except RuntimeError as e :
245268 return {
@@ -250,7 +273,6 @@ def init_local_tool(tsp_config_path: str, repo_path:str) -> Dict[str, Any]:
250273 "code" : 1
251274 }
252275
253-
254276@mcp .tool ("check_library_health" )
255277def check_library_health (library_name : str ) -> Dict [str , Any ]:
256278 """Checks the health status of a client library.
0 commit comments