1+ <#
2+ . SYNOPSIS
3+ Evaluates tool and prompt descriptions and produces a Markdown results report using Tool Description Evaluator from Mcp repo.
4+
5+ . DESCRIPTION
6+ This script builds and runs the ToolDescriptionEvaluator (.NET) against a set of tool and prompt definitions.
7+ It restores and compiles the evaluator, executes it with the provided JSON inputs, and emits a `results.md`
8+ report. The script supports configuration via parameters and environment variables for the embedding model
9+ service used during evaluation.
10+
11+ . PARAMETER EvaluatorPath
12+ The path to the evaluator project root (or its `src` directory) that will be restored, built, and executed.
13+
14+ . PARAMETER ToolsFilePath
15+ The path to the JSON file containing tool definitions to be evaluated.
16+
17+ . PARAMETER PromptsFilePath
18+ The path to the JSON file containing prompt definitions to be evaluated.
19+
20+ . PARAMETER outputFilePath
21+ The target folder where the generated `results.md` will be moved after the evaluator runs.
22+
23+ . PARAMETER AoaiEndpoint
24+ The full endpoint URL for the embedding model (e.g., Azure OpenAI embeddings) used by the evaluator.
25+
26+ . PARAMETER TextEmbeddingApiKey
27+ The API key used to authenticate with the embedding endpoint. Prefer providing this via a secure
28+ secret store or environment variable rather than hard-coding.
29+
30+ . NOTES
31+ - The evaluator emits `results.md` in the evaluator folder; this script moves it to `outputFilePath`.
32+ - Requires .NET SDK available on PATH.
33+ - Set-StrictMode is enabled.
34+
35+ . EXAMPLE
36+ .\Run-Evaluator.ps1 `
37+ -EvaluatorPath "C:\work\mcp\eng\tools\ToolDescriptionEvaluator\src" `
38+ -ToolsFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli\azure-sdk-tools.json" `
39+ -PromptsFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli\azure-sdk-prompts.json" `
40+ -outputFilePath "C:\work\azure-sdk-tools\tools\azsdk-cli" `
41+ -AoaiEndpoint "https://<your-endpoint>/openai/deployments/text-embedding-3-large/embeddings?api-version=2023-05-15" `
42+ -TextEmbeddingApiKey (Get-Secret -Name 'TextEmbeddingApiKey')
43+
44+ Runs the evaluator with the specified tools and prompts files, then moves the generated results to the output path.
45+ #>
46+ param (
47+ [Parameter (Mandatory = $true )]
48+ [string ] $EvaluatorPath ,
49+
50+ [Parameter (Mandatory = $true )]
51+ [string ] $ToolsFilePath ,
52+
53+ [Parameter (Mandatory = $true )]
54+ [string ] $PromptsFilePath ,
55+
56+ [Parameter (Mandatory = $true )]
57+ [string ] $outputFilePath ,
58+
59+ # Environment Variables
60+ [Parameter (Mandatory = $true )]
61+ [string ] $AoaiEndpoint ,
62+
63+ [Parameter (Mandatory = $true )]
64+ [string ] $TextEmbeddingApiKey
65+ )
66+
67+ Set-StrictMode - Version 3
68+
69+ # Build & run the evaluator
70+ Write-Host " Changing directory to evaluator: $EvaluatorPath "
71+ Push-Location $EvaluatorPath
72+ try {
73+ $env: AOAI_ENDPOINT = $AoaiEndpoint
74+ $env: TEXT_EMBEDDING_API_KEY = $TextEmbeddingApiKey
75+
76+ Write-Host " Restoring packages..."
77+ dotnet restore
78+
79+ Write-Host " Building (Release)..."
80+ dotnet build -- configuration Release
81+
82+ Write-Host " Running Tool..."
83+ dotnet run -- -- tools- file " $ToolsFilePath " -- prompts- file " $PromptsFilePath "
84+ }
85+ finally {
86+ Pop-Location
87+ }
88+
89+ # The tool emits results.md in the evaluator folder
90+ $generatedName = ' results.md'
91+ $EvaluatorRoot = Split-Path $EvaluatorPath - Parent
92+ $generatedPath = Join-Path - Path $EvaluatorRoot - ChildPath $generatedName
93+ if (-not (Test-Path - Path $generatedPath - PathType Leaf)) {
94+ throw " Expected output file not found: $generatedPath "
95+ }
96+
97+ Write-Host " Moving Results File: $generatedPath -> $outputFilePath "
98+ Move-Item - Path $generatedPath - Destination $outputFilePath - Force
99+ Write-Host " Successfully moved results file to $outputFilePath "
0 commit comments