Commit graph csharp-sdk/samples/TestServerWithHosting
Author SHA1 Message Date
Eirik Tsarpalis
7628b3064f
Onboard repo to the .NET 10 sdk (#822)
* Onboard repo to the .NET 10 sdk

* Remove redundant property.

* Remove console logger

* Disabling failing tests in .NET 10.
2025-09-30 20:36:12 +03:00
Mackinnon Buck
38b4a26998
Restructure IMcpEndpoint, IMcpClient, and IMcpServer (#723)
* Remove `McpEndpoint` & `IMcpClient`

* Revise naming, add abstract classes

* Fix missing renames

* Move extension methods to instance methods

* Add back old API, but obsoleted

* Add back obsoleted factory classes

* Move deprecation attributes

* `SseClientTransport` -> `HttpClientTransport`

* Update src/ModelContextProtocol.Core/Server/AugmentedServiceProvider.cs

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

* PR feedback

* PR feedback

* Add back dispose lock

* Fix docs projects

* PR feedback

* Undo `docs/*.md` changes

---------

Co-authored-by: Stephen Halter <halter73@gmail.com>
2025-09-16 10:22:10 -07:00
Eirik Tsarpalis
55bda787ae
Styling: remove a few redundant parens from object initializer expressions. (#548)
* Styling: remove a few redundant parens from object initializer expressions.

* Fix build error.
2025-06-26 16:55:54 +03:00
Stephen Toub
2bcff315f8
Update content according to latest spec (#513)
* 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
2025-06-16 19:39:41 -04:00
Stephen Toub
5cc7c00456
Add elicitation capability (#467)
* Add elicitation capability
2025-05-29 22:03:03 -04: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
Stephen Toub
106ab8064f
Clean up namespaces (#410)
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
Eirik Tsarpalis
39ab6cde0d
Separate ASP.NET Core tests into a distinct project and make the main test project netfx compatible. (#254)
* 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
bab74d5895
Fix StdioServerTransport.DisposeAsync hang (#235)
- It's not just Unix, it's all platforms that can hang
- Windows doesn't hang on Ctrl-C because that triggers
  the end of the Stream, but that doesn't help in IHostApplicationLifetime.StopAsync() scenarios

4e9627e311/src/libraries/System.Console/src/System/ConsolePal.Unix.ConsoleStream.cs (L13)
4e9627e311/src/libraries/System.Console/src/System/ConsolePal.Windows.cs (L1149)
2025-04-08 10:20:16 -07:00
Andy Gocke
f652b1a03d
Mark samples as AOT compatible (#184)
* Revert changes to remove APIs

* Apply suggestions from code review

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

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-04-03 14:12:25 -04:00
Stephen Toub
5d3fb65b11
Add McpServerPrompt / McpClientPrompt and friends (#126) 2025-03-31 09:54:40 -04:00
Stephen Toub
62e92fa154
Add ToolAnnotations support (#124)
* Add ToolAnnotations support

* Address feedback
2025-03-28 11:08:29 -04:00
nevermore
9330774795
complete fix for SampleLlmTool discovery (#102)
https://github.com/modelcontextprotocol/csharp-sdk/issues/80

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-03-27 18:22:25 -04:00
Stephen Toub
caca2ae61d
Overhaul tool handling (#89)
* Overhaul tool handling

- Renames [McpTool{Type}] to [McpServerTool{Type}], in order to distinguish representations of tools on the server from tools on the client.
- Enables [McpServerTool] methods to have arguments injected from DI, as well as a specific set of types from the implementation directly, like IMcpServer.
- Renames WithTools to WithToolsFromAssembly.
- All of the WithToolsXx methods now publish each individual McpServerTool into DI; other code can do so as well. The options setup code gathers all of the tools from DI and combines them into a collection which is then stored in McpServerOptions and used to construct the server.
- The server tools specified via DI as well as manually-provided handlers, using CallToolHandler as a fallback in case the requested tool doesn't exist in the tools collection, and ListToolsHandler augments the information for whatever tools exist.
- The tools are stored in McpServerOptions in a new McpServerToolCollection type, which is a thread-safe container that exposes add/removal notification. Adding/removing tools triggers a change notification that in turn sends a notification to the client about a tools update.
- The ServerOptions are exposed from the server instance.
- Removed cursor-based APIs from McpClientExtensions.
- Changed McpClientExtensions APIs to return `Task<IList<...>` rather than `IAsyncEnumerable<...>`.

I'm sure this will need to evolve further before we're "done", but it's a significant improvement from where we are now. One area I'm not super happy with is the notifying collection; that might work ok for a stdio server, where you can grab the created collection from the server's options and mutate it, but I don't know how well that's going to work for sse servers.

* Make McpServerTool{Collection} extensible

* Fix README.md example

* Add notifications test

* Address feedback
2025-03-25 15:32:46 -04:00
Eirik Tsarpalis
2e1e20645f Add Directory.Build.props, apply CPM, use NB.GitVersioning, update package publishing 2025-03-19 17:27:18 +02:00
Eirik Tsarpalis
c9ed453745 Rename project and namespaces 2025-03-19 15:02:38 +02:00
Stephen Halter
90dfc35fbd
Add AspNetCoreSseServer sample (#81)
* 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
2025-03-18 12:56:44 +02:00
Stephen Toub
33d2b0d762
Use DescriptionAttribute and HasDefaultValue in server builder extensions (#46) 2025-03-09 11:16:00 +01:00
Stephen Toub
587e05f057
Enable .NET SDK code analyzers (#41) 2025-03-08 17:18:09 +01:00
Toni Wenzel
ec9bdfcf5d
Improve tool handling (#28)
* Improve tool handling

* Rework stuff with new hosting options

* Update readme

* Fix build

* Try run client tests

* Fix build

* Fix issues on linux

* Try to run testserver on linux

* Fix test issue

* Fix code smells
2025-03-07 16:48:55 +01:00
Toni Wenzel
7d69499ad5
Remove warnings from build (#29)
* Remove warnings from build

* More fixes.

* Using const for transport types
2025-03-06 21:02:13 +01:00
Toni Wenzel
257a97a659
Improve how to host McpServer (#30) 2025-03-05 21:15:22 +01:00