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 M4 (multi-round-trip requests and subscriptions): handlers ask for input with
`Request-McpElicitation` (form mode with the flat primitive schema subset, or URL mode),
`Request-McpSampling` and `Request-McpRoot`; the request is answered with an `InputRequiredResult`, and on
the retry the handler runs again and receives the answer. `-Defer` and `Wait-McpInput` ask for several
inputs in one round; answers of earlier rounds and `$Context.State` travel in a `requestState` signed with
HMAC-SHA256 and bound to method, target, argument digest and expiry (`New-McpServer -RequestStateKey`,
`-RequestStateTtlSeconds`). Tampered or foreign states, malformed `inputResponses` and answers that do not
match the request fail with `-32602`; input types the client did not declare fail with `-32021` and
`data.requiredCapabilities`. Works for `tools/call`, `prompts/get` and `resources/read`.
- `subscriptions/listen` on the server: acknowledgement first with the honoured filter, every notification
tagged with the subscription id, a strictly honoured filter, `resources/updated` for subscribed URIs and
their sub-resources, a stream per listen request over Streamable HTTP (dropped when the client closes it),
cancellation by `notifications/cancelled` over stdio, and a graceful `complete` result for every open
subscription when the server stops. `Send-McpToolListChanged`, `Send-McpPromptListChanged`,
`Send-McpResourceListChanged` and `Send-McpResourceUpdated` announce changes from handlers or any runspace.
- Dynamic registration: `Register-McpTool`, `Register-McpResource` and `Register-McpPrompt` on a running server
and the new `Unregister-McpTool`, `Unregister-McpResource` and `Unregister-McpPrompt` notify subscribers;
handlers registered after the start are callable at once. `listChanged` and `resources.subscribe` are
declared as `true`.
- Client: `Connect-McpServer -OnElicitation`, `-OnSampling`, `-OnRoots` (which declare their capabilities)
and `-MaxInputRounds`; `Invoke-McpTool`, `Invoke-McpPrompt` and `Read-McpResource` run the input rounds
transparently and echo the `requestState` verbatim. `Register-McpSubscription`,
`Unregister-McpSubscription` and `Receive-McpNotification` read subscriptions in the background (a reader
runspace over stdio and in memory, one per stream over Streamable HTTP, with reconnects), invalidate the
result cache on list changes and resource updates, and run `-Action` callbacks in the caller's runspace.
- Conformance: the fixture server implements the input-request and list-change fixtures, the fixture client
answers input requests; the server baseline is empty and the client baseline holds only the authorization
scenarios. `examples/elicitation-server.ps1` demonstrates input requests and list-change notifications.
- 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
Expand Down Expand Up @@ -94,6 +122,10 @@ support, dependency and breaking-change policy.

### Fixed

- A request id can be reused as soon as its response was sent; before, a request that arrived while the
previous request with the same id was still winding down in its worker was rejected with `-32600`.
- `Connect-McpServer -Server` fails at once for a server object that is already running, instead of waiting
for the `server/discover` timeout.
- `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
Expand Down
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@ 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 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
> **Status: milestone M4 (input requests and subscriptions).** 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). Handlers ask the user for input (elicitation) or the client for sampling
> and roots through multi-round-trip requests with a signed `requestState`; clients subscribe to list changes
> and resource updates with `subscriptions/listen`, and tools, resources and prompts can be registered while
> the server runs. The client side consumes all of it over both transports and caches results for the
> `ttlMs` the server sends. The official conformance suite runs in CI: every 2026-07-28 server scenario
> passes, and on the client side everything but authorization, which is listed in
> [conformance-baseline.yml](conformance-baseline.yml) and follows in M6. 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 @@ -83,6 +85,22 @@ Get-McpResource | Read-McpResource # cached for the ttl
Disconnect-McpServer
```

A handler that needs input asks for it; the client answers through a callback, and the request is retried
with the answer (see [docs/concepts/mrtr.md](docs/concepts/mrtr.md)):

```powershell
Register-McpTool -Name 'delete-files' -ScriptBlock {
param([Parameter(Mandatory)] [string] $Pattern, $Context)
$answer = Request-McpElicitation -Context $Context -Key 'confirm' -Message "Delete '$Pattern'?" -Schema @{ ok = @{ type = 'boolean' } } -Required ok
if ($answer.Action -ne 'accept' -or -not $answer.Content.ok) { return 'Cancelled.' }
Remove-Item -Path $Pattern
}

$session = Connect-McpServer -Command pwsh -Arguments '-File', './server.ps1' -OnElicitation { param($Request) @{ ok = $true } }
$subscription = Register-McpSubscription -ToolsListChanged -ResourceUri 'weather://stations'
Receive-McpNotification -Subscription $subscription -TimeoutSeconds 30
```

Over Streamable HTTP the same server listens on a URL, and the same client commands connect to it:

```powershell
Expand All @@ -101,7 +119,7 @@ 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/weather-server.ps1`
(all server primitives), `examples/http-server.ps1`,
(all server primitives), `examples/elicitation-server.ps1` (input requests), `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.

Expand Down
4 changes: 2 additions & 2 deletions ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ against the requirement sets `2026-07-28` (37 server + 32 client scenarios) and
| **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` | 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 |
| **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, list-changed and resource-updated fan-out, dynamic registration | All 14 `input-required-result-*`; the `subscriptions/listen` checks of `server-stateless` (acknowledgement, subscription id, filter, tools and prompts list changes); client `sep-2322-client-request-state` | Done |
| **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 |
| **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; `requestState` encrypted (AES-GCM) and bound to the authenticated principal | All client `auth/*` scenarios of the 2026-07-28 requirement set | Planned |
| **M7 Extensions** | Tasks, Skills, Apps (server side), OAuth client credentials, enterprise-managed authorization | `tasks-*` (10), `auth/client-credentials-*`, `auth/enterprise-managed-authorization` | Planned |
| **M8 Developer experience and 1.0** | Discovery styles, launcher and client-configuration helpers, scaffolder, examples, PlatyPS help, concept documentation, performance pass | Empty baseline for both requirement sets; PowerShell Gallery release 1.0.0 | Planned |

Expand Down
17 changes: 1 addition & 16 deletions conformance-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,8 @@
# This file may only shrink. Version 1.0.0 requires empty lists for both requirement sets
# (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:
# 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
- input-required-result-basic-list-roots
- input-required-result-request-state
- input-required-result-multiple-input-requests
- input-required-result-multi-round
- input-required-result-missing-input-response
- input-required-result-non-tool-request
- input-required-result-result-type
- input-required-result-tampered-state
- input-required-result-capability-check
- input-required-result-ignore-extra-params
server: []
client:
# M4: input requests
- sep-2322-client-request-state
# M6: authorization
- auth/metadata-default
- auth/metadata-var1
Expand Down
3 changes: 2 additions & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
| [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/mrtr.md](concepts/mrtr.md) | Multi-round-trip requests: elicitation, sampling and roots as input requests, `requestState` |
| [concepts/subscriptions.md](concepts/subscriptions.md) | `subscriptions/listen`: list-changed and resource-updated notifications, dynamic registration |
| [concepts/authorization.md](concepts/authorization.md) | OAuth client flows and server-side bearer validation |
| `help/` | Generated command reference (PlatyPS markdown; produced by `./build.ps1 -Task Help` from milestone M1) |
| [research/](research/README.md) | Secondary material the plan was written from (specification extractions, platform research) |
Expand Down
Loading
Loading