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
32 changes: 32 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,34 @@ support, dependency and breaking-change policy.

### Added

- Milestone M3 (server primitives): `Register-McpResource` registers resources with fixed text or binary
content, files, handlers and RFC 6570 resource templates (levels 1 to 3; variables are bound to the
handler's parameters), and directories as `<base>/{+path}` templates that reject `..`, absolute paths and
symbolic links leading outside; `resources/list`, `resources/templates/list` and `resources/read` with
`-32602` and `data.uri` for unknown resources (SEP-2164) and per-resource caching hints (`-TtlMs`,
`-CacheScope`).
- `Register-McpPrompt` registers prompts whose arguments are derived from the handler's parameters (or given
with `-Arguments`); `prompts/list` and `prompts/get` with argument validation and message shaping (strings,
content blocks, `New-McpPromptMessage`). `completion/complete` for prompt arguments and template variables
from `-Completion` value lists or handlers and from `ValidateSet`, capped at 100 values with `total` and
`hasMore`.
- The `resources`, `prompts` and `completions` capabilities are declared when something is registered; their
methods answer `-32601` otherwise. All list methods page with cursors bound to their list.
- `New-McpContent` validates annotations (`audience`, `priority`, `lastModified`) and takes `-Icons` for
resource links and `-ResourceMeta` for embedded resources; icons of servers, tools, resources and prompts are
validated; `New-McpPromptMessage` and `New-McpResourceContent` build prompt messages and resource contents.
- Warning, information, verbose and debug records of handlers are sent as `notifications/message` when the
request asks for log notifications (besides stderr); the request context has a `Name` for every kind of
handler.
- Client: `Get-McpResource [-Template]`, `Read-McpResource` (pipeline input, non-terminating `ObjectNotFound`
errors for `-32602` with `data.uri` and the legacy `-32002`), `Get-McpPrompt`, `Invoke-McpPrompt` and
`Get-McpCompletion`; a per-session cache that reuses `server/discover`, list and `resources/read` results
for their `ttlMs`; content blocks and resource contents are typed objects with `GetBytes()`; format views
for the new objects.
- Conformance: the fixture server registers the resources, template, prompts and completions of the
resource, prompt, completion and caching scenarios, whose baseline entries are removed; the fixture client
also reads resources and renders prompts when the server declares them. `examples/weather-server.ps1`
demonstrates every server primitive.
- Milestone M2 (Streamable HTTP): `Start-McpServer -Transport Http -Url ...` serves the MCP endpoint on
`System.Net.HttpListener`: one JSON-RPC request or notification per POST, responses as a single JSON
object or as a request-scoped SSE stream (progress and log notifications, keep-alive comments, a closed
Expand Down Expand Up @@ -66,6 +94,10 @@ support, dependency and breaking-change policy.

### Fixed

- `build.ps1 -Bootstrap` reports why a dependency could not be installed instead of failing with a strict-mode
error about the missing `Optional` key.
- Script block tools whose names differ only in characters outside `A-Z`, `a-z`, `0-9` and `_` (for example
`a-b` and `a_b`) no longer share one worker function.
- The `Analyze` build task no longer fails or hangs on PSScriptAnalyzer's sporadic rule failures: every path is
analysed in a fresh process with a timeout, and files on which a rule failed are re-analysed in further fresh
processes.
Expand Down
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@ PowerShell SDK for building and consuming [Model Context Protocol](https://model
and clients, targeting specification revision **2026-07-28** with dual-era support for 2025-11-25 and
2025-06-18.

> **Status: milestone M2 (Streamable HTTP).** Servers expose PowerShell functions, cmdlets, scripts and
> script blocks as tools over stdio and over Streamable HTTP with the stateless 2026-07-28 lifecycle
> (`server/discover`, per-request `_meta`, request metadata headers, progress, cancellation), and the client
> side connects to such servers over both transports. The official conformance suite runs in CI: every
> 2026-07-28 scenario of the tools, HTTP header validation and DNS rebinding groups passes on both legs;
> the remaining scenarios (resources, prompts, completion, input requests, subscriptions, authorization)
> are listed in [conformance-baseline.yml](conformance-baseline.yml) and follow in M3 to M7. The milestones
> are in [ROADMAP.md](ROADMAP.md); the design is in [docs/implementation-plan.md](docs/implementation-plan.md).
> **Status: milestone M3 (server primitives).** Servers expose PowerShell functions, cmdlets, scripts and
> script blocks as tools, resources (fixed content, files, directories, handlers, RFC 6570 templates) and
> prompts, with argument completion and caching hints, over stdio and Streamable HTTP with the stateless
> 2026-07-28 lifecycle (`server/discover`, per-request `_meta`, request metadata headers, progress,
> cancellation, log notifications). The client side consumes all of them over both transports and caches
> results for the `ttlMs` the server sends. The official conformance suite runs in CI: every 2026-07-28
> scenario of the tools, resources, prompts, completion, caching, HTTP header validation and DNS rebinding
> groups passes; the remaining scenarios (input requests, subscriptions, authorization) are listed in
> [conformance-baseline.yml](conformance-baseline.yml) and follow in M4 to M7. The milestones are in
> [ROADMAP.md](ROADMAP.md); the design is in [docs/implementation-plan.md](docs/implementation-plan.md).

## Requirements

Expand Down Expand Up @@ -54,6 +56,19 @@ validated against the generated JSON Schema and bound to the parameters; objects
`Write-McpProgress`/`Write-McpLog` reach the client through a `Context` parameter. Handlers run in a worker
runspace pool, so nothing they write to the host can reach stdout.

Resources and prompts are registered the same way; resource templates bind their variables to parameters,
prompt arguments come from the `param()` block, and a `ValidateSet` doubles as argument completion:

```powershell
Register-McpResource -Uri 'weather://stations' -MimeType application/json -Content '["Berlin","Vienna"]'
Register-McpResource -UriTemplate 'weather://{city}/current' -ScriptBlock { param($city) Get-Weather -Location $city } -TtlMs 10000
Register-McpResource -Path ./docs -Uri 'docs://' # every file below ./docs, as docs://{+path}
Register-McpPrompt -Name 'weather-report' -Description 'Asks for a weather report.' -ScriptBlock {
param([Parameter(Mandatory)] [ValidateSet('Berlin', 'Vienna')] [string] $City)
"Write a three-sentence weather report for $City."
}
```

The client side:

```powershell
Expand All @@ -62,6 +77,9 @@ Get-McpServerInfo | Format-List
Get-McpTool | Select-Object Name, Description
$result = Invoke-McpTool -Name Get-Weather -Arguments @{ Location = 'Berlin' }
$result.StructuredContent.temperature
Get-McpResource | Read-McpResource # cached for the ttlMs of each result
(Invoke-McpPrompt -Name weather-report -Arguments @{ City = 'Vienna' }).Messages
(Get-McpCompletion -PromptName weather-report -Argument City -Value 'Vi').Values
Disconnect-McpServer
```

Expand All @@ -82,8 +100,10 @@ SSE responses. See [docs/concepts/transports.md](docs/concepts/transports.md).

`Connect-McpServer -Server $serverObject` runs a server in a background runspace over an in-memory transport,
which is how the tests exercise servers without child processes. `Invoke-McpToolHandler` calls a registered
tool directly for unit tests of the tool itself. See `examples/echo-server.ps1`, `examples/http-server.ps1`
and [docs/development.md](docs/development.md) for the Inspector command line.
tool directly for unit tests of the tool itself. See `examples/echo-server.ps1`, `examples/weather-server.ps1`
(all server primitives), `examples/http-server.ps1`,
[docs/concepts/server-primitives.md](docs/concepts/server-primitives.md) and
[docs/development.md](docs/development.md) for the Inspector command line.

## Building from source

Expand Down
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ against the requirement sets `2026-07-28` (37 server + 32 client scenarios) and
| **M0 Foundation** | Toolchain, module skeleton, ModuleBuilder build, analyzer rules, Pester skeleton, vendored schemas, CI matrix, release dry run, governance documents | CI green on all matrix cells with the empty module; side-effect-free import; publishing to a local repository works | Done |
| **M1 Protocol core, stdio, tools (modern)** | System.Text.Json codec, JSON-RPC model, `_meta` validation, error codes, router, `server/discover`, capabilities, extension registry, in-memory transport, dispatcher and runspace pool, stdio server and client transports, `tools/list`, `tools/call` (text), schema generator and validator, progress, cancellation | Unit and integration tests green; Inspector CLI `tools/list` against `examples/echo-server.ps1`; startup and per-request overhead measured | Done |
| **M2 Streamable HTTP (modern)** | HttpListener host, header validation, Origin allowlist, JSON/SSE selection, keep-alive, disconnect → cancel; client HTTP transport with SSE parser; conformance fixtures and workflow | Conformance 2026-07-28: `server-stateless`, `tools-list`, `tools-call-simple-text/-error/-with-progress`, `dns-rebinding-protection`, `http-header-validation`, `http-custom-header-server-validation`; client `tools_call`, `request-metadata`, `http-*`, `json-schema-ref-no-deref`; first `0.1.0-preview` on the PowerShell Gallery | Done (the Gallery preview is published from the release workflow by tagging `v0.1.0-preview1`) |
| **M3 Server primitives** | Resources (static, file, templates, blob), prompts, completion, pagination, caching fields, all content types, `structuredContent`/`outputSchema`, icons, annotations, `notifications/message`; client counterparts with TTL cache | `tools-call-image/-audio/-embedded-resource/-mixed-content`, `json-schema-2020-12`, `resources-*`, `sep-2164-resource-not-found`, `prompts-*`, `completion-complete`, `caching`; client `json-schema-2020-12-preservation` | Planned |
| **M3 Server primitives** | Resources (static, file, templates, blob), prompts, completion, pagination, caching fields, all content types, `structuredContent`/`outputSchema`, icons, annotations, `notifications/message`; client counterparts with TTL cache | `tools-call-image/-audio/-embedded-resource/-mixed-content`, `json-schema-2020-12`, `resources-*`, `sep-2164-resource-not-found`, `prompts-*`, `completion-complete`, `caching`; client `json-schema-2020-12-preservation` | Done |
| **M4 MRTR and subscriptions** | Input-required machinery with signed `requestState`, capability gating, elicitation validator, sampling and roots as input requests, client retry loop; `subscriptions/listen` on server and client | All 14 `input-required-result-*`, `server-sse-multiple-streams`; client `sep-2322-client-request-state` | Planned |
| **M5 Dual era** | Legacy session (`initialize`, `ping`, `logging/setLevel`, `resources/subscribe`, server-initiated requests, HTTP sessions, GET SSE, DELETE), era-aware serialization, client legacy lifecycle | `--requirements 2025-11-25`: server 30/30, client 18/18; 2026-07-28 still green on the dual-era instance | Planned |
| **M6 Authorization** | Client OAuth provider (discovery, PKCE, resource indicators, `iss`, CIMD/DCR/pre-registered clients, scope step-up, token store); server bearer middleware and protected-resource metadata | All client `auth/*` scenarios of the 2026-07-28 requirement set | Planned |
Expand All @@ -34,7 +34,7 @@ against the requirement sets `2026-07-28` (37 server + 32 client scenarios) and
| stdio transport (server and client) | M1 |
| Streamable HTTP (server and client), header validation, Origin protection | M2 |
| `resources/*`, `prompts/*`, `completion/complete`, caching (`ttlMs`, `cacheScope`), pagination | M3 |
| `notifications/progress`, `notifications/cancelled`, `notifications/message` | M1 / M3 |
| `notifications/progress`, `notifications/cancelled`, `notifications/message` (including handler streams) | M1 / M3 |
| MRTR: `elicitation/create`, `sampling/createMessage`, `roots/list` as input requests | M4 |
| `subscriptions/listen`, list-changed and resource-updated notifications | M4 |
| Legacy revisions 2025-11-25 and 2025-06-18 (both roles) | M5 |
Expand Down
4 changes: 2 additions & 2 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ function Install-BuildDependency {
}
}
$message = "Could not install '$Name' $range.`n " + ($errors -join "`n ")
if ($Requirement.Optional) {
if ($Requirement.ContainsKey('Optional') -and $Requirement.Optional) {
Write-Warning "$message`n '$Name' is optional; tasks that need it will be skipped."
return $false
}
Expand All @@ -348,7 +348,7 @@ foreach ($entry in ($script:Requirements.Modules.GetEnumerator() | Sort-Object -
if ($Bootstrap) {
Write-Host (" {0,-32} {1,-14} installing..." -f $name, $requirement.Version)
$null = Install-BuildDependency -Name $name -Requirement $requirement -Source $DependencySource -OfflinePath $OfflinePackagePath
} elseif ($requirement.Optional) {
} elseif ($requirement.ContainsKey('Optional') -and $requirement.Optional) {
Write-Host (" {0,-32} {1,-14} missing (optional)" -f $name, $requirement.Version) -ForegroundColor Yellow
} else {
Write-Host (" {0,-32} {1,-14} missing" -f $name, $requirement.Version) -ForegroundColor Red
Expand Down
13 changes: 0 additions & 13 deletions conformance-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,6 @@
# (2026-07-28 and 2025-11-25). The milestone that removes an entry is noted next to it (see ROADMAP.md);
# the 2025-11-25 requirement set is run from milestone M5 (dual era) on.
server:
# M3: resources, prompts, completion and caching hints on their results
- completion-complete
- resources-list
- resources-read-text
- resources-read-binary
- resources-templates-read
- sep-2164-resource-not-found
- prompts-list
- prompts-get-simple
- prompts-get-with-args
- prompts-get-embedded-resource
- prompts-get-with-image
- caching
# M4: input requests (MRTR); the two scenarios that only warn today (SHOULD checks) are listed as well
- input-required-result-basic-elicitation
- input-required-result-basic-sampling
Expand Down
1 change: 1 addition & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
| [development.md](development.md) | Build, analysis, tests, packaging, CI and release mechanics |
| [conformance.md](conformance.md) | How the MCP conformance suite is run and how the baseline works |
| [concepts/transports.md](concepts/transports.md) | stdio and Streamable HTTP: framing, stdout hygiene, header validation |
| [concepts/server-primitives.md](concepts/server-primitives.md) | Tools, resources, templates, prompts and completion: handler contract, errors, caching, pagination |
| [concepts/dual-era.md](concepts/dual-era.md) | Serving 2026-07-28 and the legacy revisions side by side |
| [concepts/mrtr.md](concepts/mrtr.md) | Multi-round-trip requests: elicitation, sampling and roots as input requests |
| [concepts/authorization.md](concepts/authorization.md) | OAuth client flows and server-side bearer validation |
Expand Down
Loading
Loading