* Update content according to latest spec
* Add Title to a bunch of types
* Add _meta to lots of types
* Address feedback, more cleanup, fix NAOT test failure
* Make enums serialize as strings if using the reflection-based serializer.
* Remove unnecessary partial
* Use an explicit reflection-based converter for enums.
* Update comments
* Make the reflection-based enum converter public.
Right now by default, the client and server hardcode the initial spec version, and if there's a mismatch, the request fails.
With this change, by default both client and server are allowed to float to any supported version.
* Improve exception diagnostics for stdio client
Track the last several lines of stderr and include those in an exception created as part of CleanupAsync if the server process has already exited. This is based on an assumption that the server should never exit prior to CleanupAsync being called.
* Address feedback and fix test failure
- Add missing filling of ResourceCollection in McpServerOptionsSetup
- Remove AIFunctionMcpServerXx.ToString overrides; for resources, it was changing behavior undesirably, and for the others it was duplicate code.
- Fix notification method used for resource list changes.
- Fix type in WithResources parameter name.
- It allows a single MCP session spanning multiple requests
to be handled by different servers without sharing state
- It does require the servers share data protection keys, but this
is standard for ASP.NET Core cookies and antiforgery as well
- It immediately throws for unsupported operations like sampling
* Add McpServer/ClientResource{Template} and friends
This PR copies the same design used by tools and prompts to add McpServerResource, McpServerResourceAttribute, McpServerResourceTypeAttribute, McpClientResource, and then all of those for ResourceTemplate as well.
Unlike the others, [McpServerResource] is permitted not only on methods but also on properties. This convenience is afforded because such resources aren't parameterized, and thus can be easily modeled as properties, likely auto-props, e.g.
```C#
[McpServerResource]
public static BlobResourceContents MyAmazingData { get; } = Create();
```
Details about resources can be encoded into the attributes or provided via McpServerResource{Template}.Create methods. If not URI is explicitly defined, one is derived from the member name and arguments. For templates, this means manufacturing a URI template that includes variables for all non-DI parameters.
This also fixes a few issues discovered along the way:
- McpClientExtensions are updated to use `ValueTask<T>` instead of `Task<T>` where relevant.
- McpServerPrompt was missing handling for progress notifications; that's been rectified. It was also missing configuring the description on the ProtocolPrompt.
- Renamed IMcpServerPrimitive.Name to Id. For resources, names aren't unique.
- After going back and forth, updated McpServer to not fail for missing handlers and to instead register default handlers. It simplifies the implementation and makes it more consistent.
- Added a bunch of primitive types into the McpJsonUtilities JSON source generator context so that such primitives are usable with tools/prompts/resources without folks being required to add them into their own context for Native AOT. I think we should consider pushing this down to AIJsonUtilities, instead, and that will then flow up to McpJsonUtilities automatically.
* Address feedback
* Set IsError on CallToolResponse to true when result is ErrorContent
* Updated the `IsError` determination for a list of AIContent to require that all items in `contentItems` are instances of `ErrorContent` and that the collection is not empty
* Introduce ConvertAiContentEnumerableToCallToolResponse to transform an IEnumerable<AIContent> into a CallToolResponse
* Move location of ConvertAIContentEnumerableToCallToolResponse helper function
---------
Co-authored-by: Andy Tagg <antagg@microsoft.com>