Skip to content
Merged
Show file tree
Hide file tree
Changes from 11 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ bld/
# Visual Studio 2017 auto generated files
Generated\ Files/

# Local validation logs
**/.validation/

# MSTest test Results
[Tt]est[Rr]esult*/
[Bb]uild[Ll]og.*
Expand Down
3 changes: 2 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"githubPullRequests.ignoredPullRequestBranches": [
"main"
]
],
"files.eol": "\n"
}
73 changes: 73 additions & 0 deletions AI/mcp-server/validate-sample.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
param(
[switch]$SkipInstall,
[switch]$SkipTests,
[switch]$SkipBrowser,
[switch]$KeepProcesses,
[switch]$Headed,
[int]$TimeoutSec = 90
)

Set-StrictMode -Version Latest
$ErrorActionPreference = 'Stop'

. (Join-Path $PSScriptRoot '../../Tools/powershell/SampleValidation.ps1')

$appRoot = $PSScriptRoot
$envFile = Join-Path $appRoot '.env'
$nodeEnvironment = Get-ValidationNodeEnvironment
$runtimeHandle = $null

try {
Write-Step 'Preflight checks'
Assert-CommandExists 'node'
Assert-CommandExists 'npm'

if (-not $SkipInstall) {
Write-Step 'Installing dependencies'
Invoke-ExternalCommand -FilePath 'npm' -Arguments @('install') -WorkingDirectory $appRoot -Environment $nodeEnvironment
}

Write-Step 'Building MCP server'
Invoke-ExternalCommand -FilePath 'npm' -Arguments @('run', 'build') -WorkingDirectory $appRoot -Environment $nodeEnvironment

if ($SkipTests) {
Write-Host 'Skipping tests because -SkipTests was specified.' -ForegroundColor Yellow
}
else {
Write-Host 'No automated test script is defined for this sample.' -ForegroundColor Yellow
}

if (-not (Test-Path $envFile)) {
Write-Host 'Skipping runtime smoke check because .env is missing.' -ForegroundColor Yellow
Write-ValidationSummary -Status 'SKIP_CONFIG' -Message 'Build validation passed; runtime smoke skipped because .env is missing.'
return
}

$environment = Get-DotEnvMap -Path $envFile
if (-not $environment.ContainsKey('PORT')) {
$environment['PORT'] = '3100'
}

Write-Step 'Starting MCP server'
$logPath = New-ValidationLogPath -WorkingDirectory $appRoot -Name 'mcp-server'
$runtimeHandle = Start-LoggedProcess -FilePath 'npm' -Arguments @('run', 'start') -WorkingDirectory $appRoot -LogPath $logPath -Environment (Merge-EnvironmentTables @($nodeEnvironment, $environment))

$healthUrl = "http://localhost:$($environment['PORT'])/health"
$healthResponse = Wait-ForHttpEndpoint -Url $healthUrl -TimeoutSec $TimeoutSec -AllowedStatusCodes @(200) -ProcessHandle $runtimeHandle
$body = [string]$healthResponse.Content
if ($body -notmatch '"status"\s*:\s*"ok"') {
throw "Health endpoint returned an unexpected response: $body"
}

Write-Host "Runtime smoke check passed at $healthUrl" -ForegroundColor Green
Write-ValidationSummary -Status 'PASS' -Message "Build and runtime smoke checks passed at $healthUrl."
}
catch {
Write-ValidationSummary -Status 'FAIL' -Message $_.Exception.Message
throw
}
finally {
if ($null -ne $runtimeHandle -and -not $KeepProcesses) {
Stop-LoggedProcess -Handle $runtimeHandle
}
}
2 changes: 2 additions & 0 deletions AI/ocr/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

# production
/build
**/.dist/*.js
**/.dist/**/*.js

# misc
.DS_Store
Expand Down
139 changes: 102 additions & 37 deletions AI/ocr/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion AI/ocr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.17",
"axios": "^1.15.2",
"express": "^4.21.2",
"isomorphic-fetch": "3.0.0",
"jsonwebtoken": "9.0.2",
"jwks-rsa": "3.1.0",
Expand All @@ -32,7 +33,7 @@
"start": "run-s build:backend start:apps",
"start:apps": "run-p start:frontend start:backend",
"start:frontend": "npm run start-cre",
"start:backend": "env-cmd --silent -f .env node ./server/index.js",
"start:backend": "npm run build:backend && env-cmd --silent -f .env node ./server/.dist/index.js",
"start-cre": "react-scripts start",
"build-cre": "react-scripts build",
"test-cre": "react-scripts test",
Expand All @@ -57,6 +58,7 @@
]
},
"devDependencies": {
"@types/express": "^5.0.3",
"@microsoft/microsoft-graph-types": "2.40.0",
"@types/isomorphic-fetch": "0.0.39",
"@types/jsonwebtoken": "9.0.5",
Expand Down
Empty file added AI/ocr/server/.dist/.gitkeep
Empty file.
Loading