Commit graph

218 commits

Author SHA1 Message Date
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
Stephen Toub
d65ddce268
Fix HandlesIProgressParameter test sporadically failing in CI (#327) 2025-04-18 09:23:19 -07:00
Stephen Toub
b0cd6541ce
Add WithTools/Prompts overloads that accept McpServerTool/Prompts (#319)
To avoid folks needing to know how you should be registering tool instances into DI.
2025-04-16 15:06:19 -04:00
Stephen Toub
227f440ab9
Support progress notifications with McpClientTool and McpClientExtensions.CallToolAsync (#312) 2025-04-16 09:03:07 -04:00
Stephen Toub
90748b1198
Delete faulty assert (#313)
We need better coverage of Subscribe/Unsubscribe separately, but for now this assert is bad.
2025-04-15 16:00:43 -07:00
Jeff Handley
c1e294ca05
Bump version to 0.1.0-preview.10 (#315) 2025-04-15 11:14:44 -07:00
Stephen Toub
312aede7d6
Clean up logging (#286) v0.1.0-preview.9 2025-04-14 10:55:45 -04:00
Mike Alhayek
dc544f929b
Remove unessesary $ and fix some typos (#305) 2025-04-14 10:47:13 -04:00
Stephen Halter
9c124b1770
Add StreamableHttpHandler and WithHttpTransport (#291)
* Simplify ModelContextProtocol.AspNetCore README

* Add StreamableHttpHandler

* Use "docker info" in CheckIsDockerAvailable

* Call WithHttpTransport in samples, tests and README

* Cleanup test namespaces

* Add CanConnect_WithMcpClient_AfterCustomizingRoute test

* Simplify relative URI handling

* Handle request made directly to the MapMcp route pattern

* Add Messages_FromNewUser_AreRejected test

* Fix README

* Shorten UserIdClaim ValueTuple names

* Remove MaxReconnectAttempts and ReconnectDelay from SseClientTransportOptions

- Add proper AdditionalHeaders support
2025-04-14 10:15:33 -04:00
じゅううん
bca5d2609d
Add AdditionalHeader handling to ReceiveMessageAsync (#295) 2025-04-13 14:49:40 -07:00
Liudmila Molkova
d6cc65aced
OpenTelemetry: context propagation and semconv update (#262) 2025-04-12 22:12:11 -04:00
Mike Alhayek
f2fd2046f3
Fix the docs and make the more readable (#281) 2025-04-12 08:41:41 -04:00
Stephen Toub
f4c87f5e2f
Wrap each request in a service scope (#276)
* Wrap each request in a service scope

* Change request/notification delegates to return ValueTask

* Address feedback
2025-04-11 19:19:12 -04:00
Jeff Handley
f1cc2d81de
Workflow refactoring and improvements (#273)
* Remove code coverage PR commenting

* Only run markdown-link-check when markdown files are updated

* Declare CI workflow permissions

* Refactor release workflow and declare permissions

* Pin all actions to SHAs

* Run CI manually, on all pushes to main, or if code changes in a PR

* NuGet publishing doesn't need any permissions
2025-04-11 12:18:17 -07:00
Eirik Tsarpalis
adb95c8d53
Bump version to 0.1.0-preview.9 (#284) 2025-04-11 18:04:36 +01:00
Eirik Tsarpalis
ce4e6586d2
Expose a JsonSerializerOptions setting in the prompts APIs (#279) v0.1.0-preview.8
* Expose a JsonSerializerOptions setting in the prompts APIs

* Change namespace for workaround converter.
2025-04-11 18:02:21 +01:00
Stephen Toub
a896fa8055
Delete some dead methods from Log.cs (#277) 2025-04-11 10:12:55 +01:00
Stephen Toub
c88afe8d86
Augment McpServerTool/Prompt docs with details of parameter/result marshaling (#271)
* Augment McpServerTool/Prompt docs with details of parameter/result marshaling

* Address feedback
2025-04-11 00:05:09 -04:00
Eirik Tsarpalis
e3aa54eb3c
Disable STJ reflection for testing. (#266)
* Disable STJ reflection for testing.

* Remove params method and redundant overload.

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-04-10 16:02:00 +01:00
Stephen Toub
45dcfe07ca
Fix CreateMessageRule.Role to be of type Role (#264) 2025-04-10 10:51:41 -04:00
Rob Chambers
77871c5aac
AI seeded comments from robch and then edited by stephentoub (#238)
* AI generated `///` comment updates

* Fix compilation issues

* Fix incorrect XML comment structure

* Update all Client comments

* Update all Configuration comments

* Update all Messages comments

* Update all Transport comments

* Update all Types comments

* Update all Server comments

* Undo some commenting

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-04-10 01:30:44 -04:00
Eirik Tsarpalis
07300389ee
Bump version to 0.1.0-preview.8 (#256) 2025-04-09 19:19:24 +01:00
Eirik Tsarpalis
39ab6cde0d
Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. (#254) v0.1.0-preview.7
* Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible.

* Fix merge conflicts.

* Update tests/ModelContextProtocol.Tests/ModelContextProtocol.Tests.csproj

Co-authored-by: Stephen Halter <halter73@gmail.com>

* Revert "Fix merge conflicts."

This reverts commit 852169b96786bad2144795540fa164e20b4b197e.

* Fix merge conflicts

---------

Co-authored-by: Stephen Halter <halter73@gmail.com>
2025-04-09 19:16:53 +01:00
Stephen Halter
08f9cdbf7d
Fix race in TransportBase.SetConnected (#253)
* Fix race in TransportBase.SetConnected

- Previously the ChannelWriter could already be completed if multiple
  threads raced in SetConnected(false)

* Fix WriteMessageAsync IsConnected test
2025-04-09 19:10:51 +01:00
Stephen Halter
b3a5a82544
Use TryAddEnumerable for McpServerOptionsSetup (#252) 2025-04-09 10:41:34 -07:00
token
cae5dff318
Improve SSE response handling and URI construction in SseClientSessio… (#251) 2025-04-09 08:33:49 -07:00
Dominik Guhr
43266ad268
Fixes #248 - Add CultureInfo.InvariantCulture to string interpolation… (#249)
* Fixes #248 - Add CultureInfo.InvariantCulture to string interpolation for langitude and longitude so the sample works everywhere.

* Update samples/QuickstartWeatherServer/Tools/WeatherTools.cs

Co-authored-by: Stephen Toub <stoub@microsoft.com>

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-04-09 09:08:27 -04:00
Stephen Toub
0c502c43af
Update M.E.AI to latest version (#241)
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2025-04-09 09:03:24 +01:00
Stephen Toub
dfafebd8fe
Avoid propagating server tool exception message to client (#242)
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2025-04-09 08:55:13 +01:00
Jeff Handley
b9c0f269d6
Update markdown-link-check to ignore external links causing 403 in CI (#246)
* Update markdown-link-check to ignore external links causing 403 in CI

* Apply wildcards on ignored links

* Bump version of mlc to latest to gain --ignore-links arg

* Do not warn on redirects from markdown-link-check action

* Do not warn on redirects from markdown-link-check action

* Update comment
2025-04-09 08:14:09 +01:00
Tyler Kendrick
03e3094dcc
Fix and enhance cancellation operations across MCP Sessions. (#179)
* Propagate CancellationToken request cancellation to remote endpoint

* Refactor existing tests to have a shared base class

* Add cancellation tests

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-04-08 16:12:12 -04:00
Jeff Handley
4dd2f42b82
Add SECURITY.md (#239) 2025-04-08 11:43:02 -07:00