Skip to content

Commit 7f47987

Browse files
authored
Merge branch 'main' into rads-1996/rate-limited-sampler-exporter
2 parents 71b09b2 + 27ed0de commit 7f47987

File tree

61 files changed

+1993
-6882
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1993
-6882
lines changed

.github/copilot-instructions.md

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ curl -s "https://api.github.com/repos/Azure/azure-rest-api-specs/commits?path=<p
7373
## EXECUTION SEQUENCE - 7 MANDATORY STEPS
7474

7575
**ESTIMATED TOTAL TIME: 10-15 minutes**
76-
- SDK Generation: 5-6 minutes
77-
- Static Validation: 3-5 minutes
78-
- Documentation & Commit: 2-4 minutes
76+
- SDK Generation: ~2 minutes
77+
- Static Validation: ~3-5 minutes
78+
- Documentation & Commit: ~2-4 minutes
7979

8080
**ALWAYS inform users of time expectations before starting any long-running operations.**
8181

@@ -89,18 +89,14 @@ IF missing dependencies:
8989

9090
### STEP 2: SDK GENERATION
9191
```
92-
ACTION: Use azure-sdk-python-mcp sdk generation server tools (init, init_local)
93-
TIMING: ALWAYS inform user before starting: "This SDK generation step will take approximately 5-6 minutes to complete."
94-
IF local path provided:
95-
USE local mcp tools with tspconfig.yaml path
92+
ACTION: Use azure-sdk-python-mcp sdk generation server tools (init for new packages, update for existing packages)
9693
IF commands fail:
9794
ANALYZE error messages
9895
DIRECT user to fix TypeSpec errors in source repo
9996
```
10097

10198
### STEP 3: STATIC VALIDATION (SEQUENTIAL)
10299
```
103-
TIMING: Inform user: "Static validation will take approximately 3-5 minutes for each step."
104100
FOR EACH validation step:
105101
RUN validation (tox mcp tool)
106102
IF errors/warnings found:

eng/tools/mcp/azure-sdk-python-mcp/main.py

Lines changed: 42 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -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: 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: Optional. Path to the local TypeSpec project (../azure-rest-api-specs/specification/eventgrid/Azure.Messaging.EventGrid/).
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:
261+
typespec_args["local-spec-repo"] = local_spec
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")
255277
def check_library_health(library_name: str) -> Dict[str, Any]:
256278
"""Checks the health status of a client library.

eng/tools/mcp/azure-sdk-python-mcp/pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
[project]
22
name = "azure-sdk-python-mcp"
3-
version = "0.1.2"
3+
version = "0.1.3"
44
description = "MCP server for Azure SDK for Python"
55
readme = "README.md"
6-
requires-python = "==3.10.*"
6+
requires-python = ">=3.10"
77
dependencies = [
88
"azure-core>=1.34.0",
99
"mcp[cli]>=1.9.2",

0 commit comments

Comments
 (0)