Commit graph

249 commits

Author SHA1 Message Date
Stephen Halter
046903c27b
Don't conflate request and response IDs in Streamable HTTP transports (#475) v0.2.0-preview.3 2025-06-03 12:17:11 -07:00
Stephen Toub
e0b058f260
Improve protocol version handling (#468)
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.
2025-06-02 23:03:57 -04:00
Stephen Halter
703b0fe50b
Add ModelContextProtocol.Core package (#428) 2025-06-02 15:16:45 -07:00
Stephen Toub
57458241b9
Update dependency versions (#474) 2025-05-31 06:07:40 -04:00
Eirik Tsarpalis
888f1711f6
Convert solution to slnx (#472)
* Convert solution to slnx

* Bump sdk version in global.json
2025-05-30 18:19:55 +03:00
Eirik Tsarpalis
47e6a6412e
Convert records to classes (#470)
* Convert records to classes

* Make properties in SseClientTransportOptions settable.

* Convert missing property from init to set
2025-05-30 17:34:36 +03:00
Stephen Toub
5cc7c00456
Add elicitation capability (#467)
* Add elicitation capability
2025-05-29 22:03:03 -04:00
Jeff Handley
36a70a03f8
Bump version to 0.2.0-preview.3 (#465)
https://www.nuget.org/packages/ModelContextProtocol/0.2.0-preview.2 has been published
2025-05-29 21:17:39 +03:00
Eirik Tsarpalis
6351b3dd43
Update documentation of McpJsonUtilities.DefaultOptions. (#463) v0.2.0-preview.2 2025-05-29 07:22:26 -04:00
Stephen Toub
72e7623b11
Set CreateNoWindow=true in RunProcessAndWaitForExit (#462) 2025-05-29 06:53:37 -04:00
Stephen Halter
317f468807
Automatically fall back from Streamable HTTP to SSE on the client by default (#456) 2025-05-28 11:06:58 -07:00
кɵɵѕнī
adb2098e4d
Log tool invocation errors (#447)
* Log tool errors
* add test and implement source generated logging
2025-05-23 14:48:47 -07:00
Eirik Tsarpalis
77f9e64e04
SSE client transport: tolerate return of RPC responses in POST requests. (#445)
* SSE client transport: handle return of RPC responses in POST requests.

* Remove accidental change.

* Address feedback

* Remove unused namespace.
2025-05-23 21:39:54 +03:00
Gavin Luo
ee9b04b7e5
Update README.md (#437)
fix example error
2025-05-20 05:10:29 -07:00
Stephen Halter
d23f442a69
Allow more accept headers (#429) 2025-05-19 17:31:20 -07:00
Andy Gocke
849809771d
Serilog AOT has been fixed as of 4.3.0 (#434)
See https://github.com/serilog/serilog/releases/tag/v4.3.0
2025-05-19 11:57:55 +03:00
Jeff Handley
63df4517fa
Bump version to 0.2.0-preview.2 (#424) 2025-05-16 19:24:22 +03:00
Stephen Toub
9c3ac60819
Remove internal GetBase64Data helper (#422) 0.2.0-preview.1
This can now just use DataContent.Base64Data.
2025-05-16 09:10:50 -04:00
Stephen Toub
915f281658
Fix NRT annotation on StdioClientTransportOptions.EnvironmentVariables (#419) 2025-05-16 00:32:29 -04:00
Stephen Toub
2bbfab1789
Update to stable M.E.AI :) (#421) 2025-05-16 00:31:17 -04:00
Jeff Handley
4a8b7fd6cf
Bump version to 0.2.0-preview.1 (#417) 2025-05-15 10:04:24 -04:00
Stephen Toub
106ab8064f
Clean up namespaces (#410) v0.1.0-preview.14
No meaningful code changes, just lots of namespace shuffling to have fewer namespaces and to put things in better namespaces.
2025-05-14 14:50:26 -04:00
Stephen Toub
c11c634945
Improve exception diagnostics for stdio client (#376)
* 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
2025-05-14 10:46:49 -04:00
Stephen Toub
8d4f51da50
Fix McpServerResource registration (#411)
- 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.
2025-05-14 09:08:59 -04:00
Stephen Halter
ce9f73f43f
Add stateless Streamable HTTP support (#392)
- 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
2025-05-14 04:51:03 -07:00
Stephen Toub
ca3a8ab921
Update M.E.AI.Abstractions to 9.5.0-preview.1.25262.9 (#412) 2025-05-14 13:24:24 +03:00
Jeff Handley
4043538285
Bump next version to preview.14 (#403) 2025-05-10 09:18:46 -07:00
Jeff Handley
b460a0f091
Make small corrections to release process docs (#402)
The 'auto' selection for the previous tag has been working well. And this also fixes a typo.
2025-05-10 09:03:28 -07:00
Stephen Toub
61092e0266
Update to latest M.E.AI version (#401) v0.1.0-preview.13 2025-05-10 07:53:04 -04:00
Stephen Toub
26c3622101
Use WithResources in EverythingServer sample (#400) 2025-05-10 06:13:42 -04:00
Stephen Toub
d86b3277d4
Add McpServer/ClientResource{Template} and friends (#391)
* 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
2025-05-09 18:21:11 -04:00
Astaggrock
47de86ab91
Set IsError on CallToolResponse to true when result is ErrorContent (#394)
* 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>
2025-05-08 23:15:58 -04:00
Stephen Halter
c750f09e97
Bump version to v0.1.0-preview.13 2025-05-05 15:46:42 -07:00
Stephen Halter
bac97efec6
Remove batching support from StreamableHttpServerTransport (#372) v0.1.0-preview.12 2025-05-01 15:48:53 -07:00
Stephen Toub
b743889987
Update System and M.E.AI dependencies (#374) 2025-05-01 11:25:17 -04:00
Stephen Halter
e913d80f05
Add client-side Streamable HTTP transport support (#356) 2025-04-30 17:21:43 -07:00
Stephen Toub
7c507bc1d7
Add a McpClientTool.CallAsync helper (#367) 2025-04-30 14:53:48 -04:00
Stephen Toub
e457f0fcf3
Fix typo in McpSession.cs (#371) 2025-04-30 14:53:36 -04:00
Adrian Cole
17a94272d9
Backfills trace injection test and migrates from request.params to request.params._meta (#360)
* Adds test to show where trace IDs are encoded

Signed-off-by: Adrian Cole <adrian.cole@elastic.co>

* update impl to params._meta

Signed-off-by: Adrian Cole <adrian.cole@elastic.co>

---------

Signed-off-by: Adrian Cole <adrian.cole@elastic.co>
2025-04-29 12:38:14 -04:00
Mike Kistler
2eeb61f4fa
Add static resources to EverythingServer sample (#361)
* Add static resources
* Apply suggestions from PR review

---------

Co-authored-by: Stephen Halter <halter73@gmail.com>
2025-04-28 21:15:37 -05:00
Vladimir Negacevschi
86dd11a199
Improve WeatherTools.GetAlerts description in sample (#363)
The latest api.weather.gov API spec requires to use the 2 letter abbreviation for the state (e.g. NY), when getting the alerts for a state.
2025-04-28 18:08:45 -07:00
1357310795
e190844218
Add SchemaCreateOptions in McpServerToolCreateOptions/McpServerPromptCreateOptions (#354)
* Add SchemaCreateOptions in McpServerToolCreateOptions

* Use TransformSchemaNode for SchemaCreateOptions testing

* Add SchemaCreateOptions in McpServerPromptCreateOptions also
2025-04-25 16:36:00 +03:00
Stephen Halter
ea296f5dc4
Bump version to v0.1.0-preview.12 2025-04-24 11:02:08 -07:00
Stephen Halter
e3ff552824
Improve testing for StreamableHttpHandler and IdleTrackingBackgroundService (#345) v0.1.0-preview.11
* Add idle session pruning tests
* Remove redundant CTS from StreamableHttpHandler
  * StreamableHttpServerTransport.HandlePostRequest already creates the equivelant CTS
    which DeleteRequest_CompletesSession_WhichCancelsLongRunningToolCalls verifies
* Fix accept header validation for GET
* Use InvalidOperationException for transport-not-connected errors in doc comments
* Fix flaky Cancellation_ThrowsCancellationException test
2025-04-24 10:49:02 -07:00
Peder Holdgaard Pedersen
4fd3ebf3fe
Fixed issue preventing client example from compiling. (#346) 2025-04-23 11:58:18 -07:00
Ferry To
f2ae0cace6
Clarify McpClientTool inherits from AIFunction in README.md
Co-authored-by: Stephen Halter <halter73@gmail.com>
2025-04-21 18:57:59 -07:00
dogdie233
0c9e91f98c
Emit root-relative /message endpoint when using SSE Server (#323) 2025-04-20 14:31:48 -07:00
Jeff Handley
9505eb5160
Bump version to v0.1.0-preview.11 (#332) 2025-04-18 17:56:28 -07:00
Stephen Halter
7dcba357d4
Add server-side Streamable HTTP transport support (#330) v0.1.0-preview.10
- Changes IJsonRpcMessage to an abstract base class so RelatedTransport will always be available
- Streamable HTTP supports multiple concurrent HTTP request with their own indpendent SSE response streams
- RelatedTransport indicates the source or destination of the JsonRpcMessage

- Changes the default RequestId to a JSON number for better compatibility with MCP servers in the wild
2025-04-18 17:07:23 -07:00
Stephen Toub
7d77be68cf
Clean up (use of) McpException and McpTransportException (#321)
* Clean up (use of) McpException

* Replace McpTransportException with InvalidOperationException

* Add cancellation test
2025-04-18 09:25:29 -07:00