Skip to content

M3: resources, prompts, completion, caching and the client counterparts - #4

Merged
t11z merged 2 commits into
mainfrom
claude/jolly-johnson-e4bd7k
Sep 23, 2026
Merged

t11z merged 2 commits into
mainfrom
claude/jolly-johnson-e4bd7k

Conversation

@t11z

@t11z t11z commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

This PR implements milestone M3 (server primitives) from ROADMAP.md. The M3 block of conformance-baseline.yml (12 server scenarios) is removed with nothing added in its place, and every scenario in it now passes.

Server

  • Resources: Register-McpResource can serve:
    • Fixed text or binary content (-Content), answered in the dispatcher without running user code.
    • A file (-Path <file>).
    • A handler (-ScriptBlock/-Command).
    • RFC 6570 templates (levels 1–3; each template variable binds to the handler parameter of the same name). Level 4 modifiers are rejected at registration, because matching them in reverse is ambiguous.
    • A directory (-Path <dir>), served as the template <base>/{+path}. Paths that escape the directory through .., absolute paths or symbolic links are reported as not found.
  • resources/read errors: an unknown resource returns -32602 with data.uri (SEP-2164). Each resource can set its own caching hints (-TtlMs, -CacheScope).
  • Prompts: Register-McpPrompt derives arguments from the param() block (Mandatory, help text, ValidateSet) or takes them from explicit -Arguments. Handler output is shaped into messages: strings, content blocks and New-McpPromptMessage.
  • Completion: completion/complete offers values from -Completion lists, handlers and ValidateSet, capped at 100 with total and hasMore.
  • Capabilities: resources, prompts and completions are declared only when something is registered; otherwise their methods return -32601.
  • Pagination: list cursors are bound to their list, so a tools/list cursor is rejected by prompts/list.

Core

  • Handler descriptor, binding and invocation live in Private/Handler.ps1 and are shared by all handler kinds.
  • The worker path dispatches by kind (Tool, Resource, Prompt, Completion); the request context gains a Name property.
  • When a request asks for log notifications, handler Warning/Information/Verbose records are also sent as notifications/message.
  • Icons and content annotations are validated. New-McpContent gets -Icons (resource links) and -ResourceMeta (embedded resources).
  • Script-block tools named a-b and a_b used to share one worker function; they no longer do.

Client

  • New commands: Get-McpResource [-Template], Read-McpResource (pipeline input; ObjectNotFound for -32602 with data.uri and for the legacy -32002), Get-McpPrompt, Invoke-McpPrompt, Get-McpCompletion.
  • Per-session TTL cache for discover, list and resources/read results. For a multi-page list the shortest ttlMs applies; ttlMs = 0 is never cached.
  • Content blocks and resource contents are typed objects with GetBytes(), and have format views.

Conformance, examples, docs

  • The fixture server registers the resources, template, prompts and completions that the scenarios use.
  • The fixture client reads resources and renders prompts when the server declares them. http-standard-headers goes from 3 to 9 checks, now including Mcp-Method/Mcp-Name for resources/read and prompts/get.
  • New examples/weather-server.ps1 (all primitives, with a stdio integration test) and docs/concepts/server-primitives.md.
  • README, ROADMAP (M3 → Done), CHANGELOG, about help, docs/conformance.md and docs/development.md are updated.

Also fixed: build.ps1 -Bootstrap hid the real install error behind a strict-mode error about the missing Optional key.

Checklist

  • ./build.ps1 -Task CI passes locally (Analyze, Test, Package, PublishLocal). Only partly verified. The PowerShell Gallery is blocked by egress policy in the development container, so ModuleBuilder could not be installed and Build/Package/PublishLocal did not run. What did run:
    • Analyze: Invoke-Build Analyze with PSScriptAnalyzer 1.25.0 from the official GitHub release; no findings.
    • Test: Pester 6.2 against a module assembled in the same file order ModuleBuilder uses, on pwsh 7.4.20. 406 passed, 0 failed, 5 skipped.
  • New behaviour is covered by tests:
    • Unit: UriTemplate, Resources, Prompts/Completion, Metadata/Pagination.
    • Integration: ServerPrimitives (in-memory), HTTP (Mcp-Name, 400/-32602), stdio (weather example).
  • CHANGELOG.md has an entry under [Unreleased].
  • conformance-baseline.yml shrank: the M3 block is removed. Server and client legs of the pinned 0.2.0-alpha.11 exit 0 locally against it.
  • Documentation updated.

🤖 Generated with Claude Code

https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE


Generated by Claude Code

Server: Register-McpResource serves fixed content, files, handlers and
RFC 6570 resource templates (levels 1 to 3, variables bound to handler
parameters), and directories as <base>/{+path} templates that reject
'..', absolute paths and symbolic links leading outside. resources/read
answers unknown URIs with -32602 and data.uri (SEP-2164) and carries
per-resource caching hints. Register-McpPrompt derives prompt arguments
from the handler's parameters; prompts/get validates them and shapes
strings, content blocks and New-McpPromptMessage into messages.
completion/complete serves -Completion value lists, handlers and
ValidateSet values, capped at 100 with total and hasMore. The resources,
prompts and completions capabilities are declared only when something is
registered (-32601 otherwise); list cursors are bound to their list.

Core: handler descriptors, parameter binding and invocation are shared by
all handler kinds; the worker path dispatches tools, resources, prompts
and completions; handler warning, information and verbose records become
notifications/message when the request asks for them. Icons and content
annotations are validated; New-McpContent takes -Icons and -ResourceMeta.
Script block tools whose names differ only in special characters no
longer share a worker function.

Client: Get-McpResource, Read-McpResource, Get-McpPrompt,
Invoke-McpPrompt and Get-McpCompletion; a per-session cache that reuses
discover, list and resources/read results for their ttlMs; typed content
blocks and resource contents with GetBytes(); format views.

Conformance: fixtures for the resource, prompt, completion and caching
scenarios, whose baseline entries are removed; the fixture client reads
resources and renders prompts when the server declares them. Adds
examples/weather-server.ps1 and docs/concepts/server-primitives.md.

build.ps1 -Bootstrap now reports why a dependency could not be installed
instead of a strict-mode error about the missing Optional key.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE
-ErrorVariable of Read-McpResource also collects the protocol exceptions
caught inside the command, not all of them as ErrorRecords; the Test task
runs Pester under Set-StrictMode -Version Latest, where reading
FullyQualifiedErrorId from those objects throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01ATyZ6eV1KJ8g6koeUnCdcE
@t11z t11z self-assigned this Sep 23, 2026
@t11z t11z added the enhancement Type: new feature or request label Sep 23, 2026
@t11z
t11z merged commit 61d1a9f into main Sep 23, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Type: new feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants