* Adding code coverage to tests in workflow
This is using the pattern from the Aspire Community Toolkit which will publish coverage results to the GitHub Actions summary, as well as a comment on the PR (if the job was run by someone with permissions to write comments).
Also added the GitHubActionsTestLogger so that it writes a nicer log out to the run.
Fixes#11
* Feedback from code review
* Slight change to structure
* Bad indentation
* Ensuring .NET SDK is installed
* Disabling fail-fast so that jobs aren't terminated if one fails
* Forgot to include coverlet.collector
* Update Directory.Packages.props
---------
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* Add acknowledgements to README
* Apply suggestions from PR review.
Co-authored-by: Stephen Toub <stoub@microsoft.com>
---------
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Add XunitLoggerProvider
* Avoid logging to stale ITestOutputHelper in fixture disposal
* Use LoggedTest base class everywhere an ILoggerFactory is used
* Make client config optional to McpClientFactory.CreateAsync
Unless you're specifying capabilities (sampling/rooting) or need a specific client name/version, the client information can be inferred from the assembly, simplifying the getting-started experience.
* Cache default options
* Update src/ModelContextProtocol/Client/McpClientFactory.cs
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
---------
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* fix: Enforce UTF-8 encoding for stdio transport
This change replaces the default system encoding with an explicit UTF8Encoding (without BOM)
for both client and server transports. This ensures proper handling of Unicode characters,
including Chinese characters and emoji.
- Use UTF8Encoding explicitly for StreamReader and StreamWriter.
- Add tests for Chinese characters ("上下文伺服器") and emoji (🔍🚀👍) to confirm the fix.
Fixes#35.
* Remove relaxed JSON encoder
* Address PR feedback
---------
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix private reflection
Two changes in this PR
- Remove private reflection from one of the tests
- Move to use `TaskCompletionSource` (feedback from previous PR)
* fix
* spelling
* Remove reflection from Connect test
This removes the reflection from the double connection test and replaces it with a
`MockHttpHandler` to let the connection actually succeed and then test the
redundant `ConnectAsync` call.
partial fix for #48
* remove unneeded using
---------
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Add initial support for Resource Templates
* Make ListResourceTemplatesHandler not required
The server was throwing if this handler wasn't specified, and it should probably be optional anyway.
* Remove extra line
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix spaces
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix spaces
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Add and use a default ListResourceTemplatesHandler
If no ListResourceTemplatesHandler is specified, use a default one that returns an empty result.
* Fix spaces
* Spaces
* Add Client extensions for ListResourceTemplates
* Integration Test for Client ListResourceTemplates
* Fix comment
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Make Defaults internal
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Simplify test call
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Make delegate static
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Fix test comment
* Spaces
* Fix xml doc
Co-authored-by: Stephen Toub <stoub@microsoft.com>
* Make default handler inline
* Spaces
Co-authored-by: Stephen Halter <halter73@gmail.com>
---------
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Stephen Halter <halter73@gmail.com>
* Change type of Tool.InputSchema to be JsonElement
* Add schema validation in the InputSchema property setter.
* Simplify AIFunction tool adapter.
---------
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
* Add AspNetCoreSseMcpTransport sample
* Fix build errors after rebase
* React to McpServerFactory changes
* Make Utf8JsonWriter non thread static
* Fix test errors caused by not rebasing the HttpLister changes on factory overhaul commit
* Integrate Microsoft.Extensions.AI as a foundational building block
As with logging abstractions coming from M.E.Logging and DI abstractions coming from M.E.DependencyInjection, M.E.AI provides the relevant AI abstractions.
- Adds AsAIFunction and GetAIFunctionsAsync methods for getting functions for tools via a client.
- Uses AIFunctionFactory to implement McpServerBuilderExtensions.WithTools.
- Adds a RequestSamplingAsync overload that accepts ChatMessages/Options.
- Adds an AsSamplingChatClient method that provides an IChatClient usable on the server to request sampling of the client.
- Adds a CreateSamplingHandler method to enable an IChatClient to be easily used to satisfy sampling requests on the client.
- Deprecate McpDotNet.Extensions.AI.
* Address PR feedback
Handlers are now specified before connecting the client/server. Otherwise, race conditions exist. Handlers move into being a part of the McpClientOptions/McpServerOptions, so that they're provided to the factories. Where relevant, the handlers are specified as part of the capability descriptors, so that they go hand in hand.
The factories are no longer stateful. Instead of allocating a factory and then calling a create method on it, you just call a static factory method.