Thank you for helping to build the PowerShell SDK for the Model Context Protocol. This document explains how the repository is organised, how to build and test it, and the conventions pull requests are expected to follow. The design is described in docs/implementation-plan.md.
- PowerShell 7.4 or later (7.4, 7.5 and 7.6 are tested in CI). Windows PowerShell 5.1 is not supported.
- Node.js 20 or later with
npxfor the conformance suite and the MCP Inspector. - Build and test dependencies are installed by
./build.ps1 -Bootstrap(seerequirements.psd1). In environments without access to the PowerShell Gallery, drop the.nupkgfiles intotools/packages/and run./build.ps1 -Bootstrap -DependencySource Offline(seetools/README.md).
| Path | Content |
|---|---|
src/ |
Module sources: Enums/, Classes/ (numbered for deterministic order), Private/, Public/ (one function per file, file name = function name), Types/, Formats/, en-US/, Suffix.ps1, build.psd1 (ModuleBuilder settings) |
tests/ |
Pester tests: Unit/, Integration/, Spec/ (vendored schemas), Compat/, Conformance/ (fixtures of the conformance suite), Support/ |
tools/ |
Custom PSScriptAnalyzer rules, maintenance scripts, offline package drop folder |
docs/ |
Concept documentation, generated command help, the implementation plan and research material |
output/ |
Build output (ignored by git) |
./build.ps1 -Bootstrap # install build dependencies (once)
./build.ps1 # Build: assemble output/ModelContextProtocol/<version>/
./build.ps1 -Task Format # Invoke-Formatter over the sources, in place
./build.ps1 -Task Analyze # PSScriptAnalyzer with the repository settings and custom rules
./build.ps1 -Task Test # Build + Pester (unit, integration, spec, compat)
./build.ps1 -Task Test -CodeCoverage # same, with JaCoCo coverage under output/coverage/
./build.ps1 -Task Package # Build + .nupkg under output/packages/
./build.ps1 -Task CI # Analyze, Test, Package, PublishLocal: what CI runs
./build.ps1 -Task ? # list all tasksTests import the built module, never src/ directly. Set MCP_MODULE_MANIFEST to test a specific build.
- Public functions use approved verbs (
Get-Verb) with the noun prefixMcp,[CmdletBinding()],[OutputType()]and comment-based help, and never declare a-ProgressActionparameter (it is an automatic common parameter since 7.4). - Nothing outside the transport writer writes to stdout or the host: no
Write-Host,Out-Host,Out-Default,Read-Host,[Console]::Write*,[Console]::Out,[Console]::OpenStandardOutput,$Host.UI. The custom ruleMeasure-McpStdoutPurityenforces this forsrc/; diagnostics belong on stderr or innotifications/message. Invoke-Expression,InvokeCommand.InvokeScriptandInvokeCommand.ExpandStringare forbidden everywhere (Measure-McpNoInvokeExpression);[scriptblock]::Createis flagged and needs a justified suppression.- Wire objects are ordered dictionaries that omit absent fields; optional fields are never sent as
null. - Engine classes carry
[NoRunspaceAffinity()]and are exported through type accelerators inSuffix.ps1; nothing in the public API requiresusing module. - Sources are UTF-8 without BOM, LF line endings, 4-space indentation, One True Brace Style (
.editorconfig, enforced by the PSScriptAnalyzer formatting rules).Invoke-Formatter -Settings ./PSScriptAnalyzerSettings.psd1formats a file. - Module import is side-effect free: no output on any stream, no console changes, no global variables.
- Unit tests exercise the built module (
InModuleScope,Mock -ModuleName) and never spawn processes. - Integration tests spawn real
pwshprocesses and use loopback HTTP; files go to$TestDrive. - Specification tests derive expectations from the vendored
schema.json; every schema definition receives a constructor and a parser test as the type model grows (tests/Spec/definitions-checklist.txt). - Conformance runs (
./build.ps1 -Task Conformance) use the pinned@modelcontextprotocol/conformanceversion andconformance-baseline.yml; the baseline may only shrink.
- Branch from
main; keep pull requests focused on one milestone item. - Run
./build.ps1 -Task CIlocally before pushing. CI runs the same tasks on ubuntu, windows and macOS with pinned PowerShell 7.4, 7.5 and 7.6. - Add a changelog entry under
## [Unreleased]inCHANGELOG.mdfor user-visible changes. - Commit messages: imperative subject line; the body explains why.
Issues follow the label taxonomy of the MCP SDK tiering guidelines (.github/labels.json): one type label
(bug, enhancement, question), one status label (needs confirmation, needs repro, ready for work,
good first issue, help wanted) and, once actionable, a priority (P0 to P3). P0 means a security issue
with CVSS 7.0 or higher, or a failure of core MCP operations (connection, message exchange, tools, resources,
prompts). Targets: triage within 2 business days, P0 fixed within 7 days.
By contributing you agree that your contributions are licensed under the MIT License of this repository.