Skip to content

Testing and Distribution

The testing and distribution infrastructure for glean-powershell ensures that the generated module remains faithful to the upstream API specification and that the MCP server adheres to the JSON-RPC protocol. The test suite is divided into contract fidelity checks, which validate parameter and HTTP call correctness against a generated contract, and protocol tests that verify the MCP server’s behavior over stdio. The build pipeline automates regeneration, testing, and packaging into a versioned, checksummed ZIP archive, while the installer script handles secure installation and optional MCP server registration.

The contract fidelity tests (tests/Contract.Tests.ps1) serve as a “fidelity gate” to prove that the module captures the published specification by contract, rather than just checking file counts . These tests are data-driven from generator/contract.json and verify coverage, parameter fidelity, required-flag honoring, and call fidelity for every operation .

The suite first validates coverage by ensuring the operation count matches the published spec (111 operations: 68 client + 43 indexing, with one removed by overlay) . It confirms that every operation maps to exactly one exported function, that every function is listed in the manifest’s FunctionsToExport, and that every alias resolves to its corresponding function .

For each operation, the tests verify parameter fidelity by ensuring every spec parameter and body field is exposed as a PowerShell parameter, and that every required spec parameter is marked as Mandatory in its parameter set .

Call fidelity tests verify that invoking a function issues the expected HTTP method and path . The tests synthesize minimal invocation arguments by resolving mandatory path, query, and header parameters, and include a -Body escape hatch for body-bearing operations . They use mocks to assert that Invoke-GleanHttp is called with the correct method and a URI matching the templated path .

diagram

The MCP server tests (tests/Mcp.Tests.ps1) validate the PowerShell MCP server’s JSON-RPC protocol handling and tool dispatch, with the Glean HTTP seam mocked . These tests ensure the server correctly initializes, handles notifications, and dispatches tool calls.

The protocol tests verify that the server responds to initialize with the correct protocol version (2024-11-05) and server info (glean-powershell), and that it exposes tools capability . It confirms that the notifications/initialized message returns no response, that ping returns the correct ID, and that unknown methods return a -32601 error .

The tools/list tests verify that the core Glean tools (glean_search, glean_chat, glean_read_document, glean_people_search) are listed, while glean_invoke is only exposed when allowed . It also ensures every tool has a valid object inputSchema with non-empty name and description .

The tools/call tests verify that glean_search returns formatted results with isError false, and that tool errors are reported as isError true rather than throwing exceptions . It also confirms that glean_invoke is rejected with a “disabled” error when not allowed .

A stdio integration smoke test verifies that the server handles a real initialize and tools/list over stdin/stdout, ensuring the notification gets no reply and the responses are correctly formatted .

diagram

The build script (Build-GleanPackage.ps1) regenerates the module from specs, runs tests, and produces a versioned, checksummed distribution package . It stages the module and MCP server into a clean tree, zips it as Glean-<version>.zip, and writes SHA256SUMS covering the zip and install.ps1 so consumers can verify integrity before installing .

The script first regenerates the module by running generator/generate.py if Python is available . It then runs Pester tests (unless skipped) and fails if any tests fail .

The packaging stage copies the Glean and mcp directories, along with README.md, SECURITY.md, and LICENSE, into a temporary staging directory . It compresses the staging directory into a ZIP file in the output directory, copies install.ps1, and generates SHA256SUMS for both the zip and the installer .

diagram

The installer script (install.ps1) installs the Glean PowerShell module from a verified package . It verifies the package SHA256 before copying anything, then installs the module to the user module path and optionally registers the MCP server .

The script resolves the expected hash from the -ExpectedHash parameter or a SHA256SUMS file next to the package . It compares the actual hash against the expected hash and refuses to proceed on a mismatch .

The installer determines the destination module path based on the OS (Windows: Documents/PowerShell/Modules, Unix: ~/.local/share/powershell/Modules) . It expands the package into a temporary directory, validates the presence of Glean.psd1, and copies the module to the destination .

If the -RegisterMcp switch is provided and the claude CLI is available, it registers the MCP server with Claude Code . The script then reports the number of installed cmdlets and provides next steps for connecting to Glean .

diagram