Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
# ServiceOwners: @smritiy @srnagar @jongio @zaaslam

# PRLabel: %tools-ManagedLustre
/tools/Azure.Mcp.Tools.ManagedLustre/ @wolfgang-desalvador @microsoft/azure-mcp
/tools/Azure.Mcp.Tools.ManagedLustre/ @wolfgang-desalvador @microsoft/azure-mcp
# ServiceLabel: %tools-ManagedLustre
# ServiceOwners: @wolfgang-desalvador

Expand Down Expand Up @@ -245,3 +245,9 @@

# ServiceLabel: %tools-ConfidentialLedger
# ServiceOwners: @taicchoumsft @ivarprudnikov

# PRLabel: %tools-ResourceHealth
/tools/Azure.Mcp.Tools.ResourceHealth/ @pkaza-msft @microsoft/azure-mcp

# ServiceLabel: %tools-ResourceHealth
# ServiceOwners: @pkaza-msft @microsoft/azure-mcp
1 change: 0 additions & 1 deletion .vscode/cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@
"functionapp",
"functionapps",
"germanynorth",
"gethealth",
"grpcio",
"gsaascend",
"gsamas",
Expand Down
12 changes: 12 additions & 0 deletions eng/scripts/Analyze-Code.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,18 @@ try {
Write-Host "✅ Tool description evaluation did not detect any issues."
}

# Run tool name length validation
$toolNameResult = & "$PSScriptRoot/Test-ToolNameLength.ps1"

if ($LASTEXITCODE -ne 0) {
Write-Host "❌ Tool name length validation failed"
Write-Host "Maximum Length Allowed: $($toolNameResult.MaxAllowed). $($toolNameResult.ViolationCount) tool(s) exceeding this limit. Review the above output for details."
$hasErrors = $true
} else {
Write-Host "✅ Tool name length validation passed."
Write-Host "All tools are within the $($toolNameResult.MaxAllowed) character limit."
}

if($hasErrors) {
exit 1
}
Expand Down
234 changes: 234 additions & 0 deletions eng/scripts/Test-ToolNameLength.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,234 @@
#!/usr/bin/env pwsh
#Requires -Version 7

<#
.SYNOPSIS
Validates that all tool names don't exceed the maximum length
.DESCRIPTION
This script validates that tool name length doesn't exceed 48 characters.
Tool name format: {area}_{resource}_{operation}
Example: "managedlustre_filesystem_subnetsize_validate-length" = 50 chars (EXCEEDS)
The limit does NOT include the MCP server prefix (e.g., "AzureMCP-AllTools-").
.PARAMETER MaxLength
Maximum allowed length for tool names (default: 48)
.PARAMETER ServerName
Name of the server to test. If not specified, all servers will be tested.
#>

param(
[int]$MaxLength = 48,
[string]$ServerName
)

$ErrorActionPreference = 'Stop'

. "$PSScriptRoot/../common/scripts/common.ps1"
$RepoRoot = $RepoRoot.Path.Replace('\', '/')

if ($ServerName) {
Write-Host "Validating tool name length for $ServerName"
} else {
Write-Host "Validating tool name length for all servers"
}
Write-Host "Max length: $MaxLength characters"
Write-Host ""

# Use the build infrastructure - New-BuildInfo.ps1 and Build-Code.ps1
$buildInfoPath = "$RepoRoot/.work/build_info.json"
$buildOutputPath = "$RepoRoot/.work/build"

# Clean up previous build artifacts
Remove-Item -Path $buildOutputPath -Recurse -Force -ErrorAction SilentlyContinue -ProgressAction SilentlyContinue

# Create build metadata
& "$RepoRoot/eng/scripts/New-BuildInfo.ps1" `
-ServerName $ServerName `
-PublishTarget none `
-BuildId 12345

if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to create build info"
exit 1
}

# Build the server
& "$RepoRoot/eng/scripts/Build-Code.ps1"

if ($LASTEXITCODE -ne 0) {
Write-Error "Failed to build $ServerName"
exit 1
}

# Read build_info.json to get server information
$buildInfo = Get-Content $buildInfoPath -Raw | ConvertFrom-Json -AsHashtable

# Get servers to test
$serversToTest = $buildInfo.servers
if (-not $serversToTest -or $serversToTest.Count -eq 0) {
Write-Error "No servers found in build_info.json"
exit 1
}

Write-Host "Testing $($serversToTest.Count) server(s)"
Write-Host ""

# Track overall results
$overallViolations = @()
$overallSuccess = $true
$testedServers = 0
$skippedServers = 0

foreach ($serverInfo in $serversToTest) {
$currentServerName = $serverInfo.name
Write-Host "=================================================="
Write-Host "Testing: $currentServerName"
Write-Host "=================================================="

# Get the executable name and find the built platform
$executableName = $serverInfo.cliName + $(if ($IsWindows) { ".exe" } else { "" })

# Find the first platform that was actually built
$builtPlatform = $serverInfo.platforms | Where-Object {
Test-Path "$buildOutputPath/$($_.artifactPath)"
} | Select-Object -First 1

if (-not $builtPlatform) {
Write-Warning "No built platform found for $currentServerName - skipping"
$skippedServers++
Write-Host ""
continue
}

$executablePath = "$buildOutputPath/$($builtPlatform.artifactPath)/$executableName"

if (-not (Test-Path $executablePath)) {
Write-Error "Executable not found at $executablePath for $currentServerName"
exit 1
}

# Try to get tools - some servers may not support 'tools list'
Write-Host "Loading tools from $currentServerName"
try {
$toolsJson = & $executablePath tools list 2>&1 | Out-String

if ($LASTEXITCODE -ne 0) {
Write-Warning "$currentServerName 'tools list' command failed with exit code $LASTEXITCODE (may have no tools) - skipping"
$skippedServers++
Write-Host ""
continue
}

if ([string]::IsNullOrWhiteSpace($toolsJson)) {
Write-Warning "No output received from '$currentServerName tools list' - skipping"
$skippedServers++
Write-Host ""
continue
}

$toolsResult = $toolsJson | ConvertFrom-Json
$tools = $toolsResult.results

if ($null -eq $tools -or $tools.Count -eq 0) {
Write-Warning "No tools found in $currentServerName - skipping"
$skippedServers++
Write-Host ""
continue
}

Write-Host "Loaded $($tools.Count) tools"
$testedServers++

# Validate tool name lengths
$violations = @()
$maxToolNameLength = 0

foreach ($tool in $tools) {
$toolName = $tool.command -replace ' ', '_'
$fullLength = $toolName.Length

if ($fullLength -gt $maxToolNameLength) {
$maxToolNameLength = $fullLength
}

if ($fullLength -gt $MaxLength) {
$violations += [PSCustomObject]@{
Server = $currentServerName
ToolName = $toolName
Command = $tool.command
Length = $fullLength
Excess = $fullLength - $MaxLength
}
}
}

Write-Host "Longest tool name: $maxToolNameLength characters"

if ($violations.Count -eq 0) {
Write-Host "All $($tools.Count) tool names are within the $MaxLength character limit!" -ForegroundColor Green
}
else {
Write-Host "Found $($violations.Count) violation(s):" -ForegroundColor Red
$violations | ForEach-Object {
Write-Host " - $($_.ToolName) ($($_.Length) chars, exceeds by $($_.Excess))" -ForegroundColor Red
}
$overallViolations += $violations
$overallSuccess = $false
}
}
catch {
Write-Warning "Error testing $currentServerName : $_"
Write-Host "This server may not support tool validation - skipping"
$skippedServers++
}

Write-Host ""
}

# Final summary
Write-Host "=================================================="
Write-Host "SUMMARY"
Write-Host "=================================================="
Write-Host "Servers tested: $testedServers"
Write-Host "Servers skipped: $skippedServers"
Write-Host "Total violations: $($overallViolations.Count)"
Write-Host ""

if ($overallViolations.Count -gt 0) {
Write-Host "VIOLATIONS FOUND:" -ForegroundColor Red
Write-Host ""

$overallViolations | Sort-Object -Property Length -Descending | ForEach-Object {
Write-Host " Server: $($_.Server)"
Write-Host " Tool: $($_.ToolName)"
Write-Host " Command: $($_.Command)"
Write-Host " Length: $($_.Length) characters (exceeds by $($_.Excess))"
Write-Host ""
}
}

# Prepare return object
$result = [PSCustomObject]@{
MaxAllowed = $MaxLength
ServersTested = $testedServers
ServersSkipped = $skippedServers
ViolationCount = $overallViolations.Count
}

$result

if ($overallSuccess -and $testedServers -gt 0) {
Write-Host "All tested servers passed validation!" -ForegroundColor Green
exit 0
}
elseif ($testedServers -eq 0) {
Write-Error "No servers were successfully tested. All $($skippedServers) server(s) were skipped."
exit 1
}
else {
Write-Host "Validation failed - see violations above" -ForegroundColor Red
exit 1
}
4 changes: 2 additions & 2 deletions eng/tools/ToolDescriptionEvaluator/prompts.json
Original file line number Diff line number Diff line change
Expand Up @@ -774,10 +774,10 @@
"azmcp_virtualdesktop_hostpool_list": [
"List all host pools in my subscription"
],
"azmcp_virtualdesktop_hostpool_sessionhost_list": [
"azmcp_virtualdesktop_hostpool_session_list": [
"List all session hosts in host pool <hostpool_name>"
],
"azmcp_virtualdesktop_hostpool_sessionhost_usersession-list": [
"azmcp_virtualdesktop_hostpool_session_user_list": [
"List all user sessions on session host <sessionhost_name> in host pool <hostpool_name>"
],
"azmcp_workbooks_create": [
Expand Down
1 change: 1 addition & 0 deletions servers/Azure.Mcp.Server/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ The Azure MCP Server updates automatically by default whenever a new release com
### Other Changes

- Updated how `IsServerCommandInvoked` telemetry is captured to more correctly report whether learning or tool call was performed. [[#874](https://github.com/microsoft/mcp/pull/874)]
- Added tool name length validation to ensure all tool names stay within 48 character limit for compatibility with MCP clients. [[#881](https://github.com/microsoft/mcp/pull/881)]

## 0.9.4 (2025-10-17)

Expand Down
Loading