Commit graph

94 commits

Author SHA1 Message Date
Zae Chao
96ba2fa076
Fix enum serialization (#61)
* Fix enum serialization

* Add tests for enum serialization

* Add missing enum serialization configuration.

* Ensure enums serialize as expected using defaults

---------

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2025-03-24 12:51:24 +00:00
ConanYao
1a5732b158
docs: add McpServerOptionsSetup code comment (#77) 2025-03-23 22:30:39 -04:00
Aaron Powell
c3988737c9
Adding merge files to gitignore (#78) 2025-03-23 22:26:34 -04:00
Weihan Li
a97a74f330
docs: update McpToolAttribute name comment (#63) 2025-03-23 11:51:48 -04:00
Jared Parsons
e76dbb5372
Fix private reflection (#60)
* 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
2025-03-22 12:09:43 -04:00
Jared Parsons
d18da9a08d
Remove reflection from Connect test (#57)
* 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>
2025-03-22 11:56:05 +02:00
Stephen Halter
08e7da100f
Run integration test SSE server in process (#56)
* Run integration test SSE server in process

* Handle expected OCE disposing fixture
2025-03-21 22:18:55 -04:00
Stephen Toub
54e60fe7a2
Update README.MD (#58) 2025-03-21 22:14:49 -04:00
Peder Holdgaard Pedersen
10c712a12f
Logging Capability (#53)
* Logging Capability

* Readability

* Redundant using

---------

Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-03-21 17:50:41 -04:00
Jeff Handley
4d61007c11
Set the NuGet package copyright text (#54) v0.1.0-preview.1.25171.12
* Set the NuGet package copyright text

* Temporarily set authors/copyright to Microsoft for publishing
2025-03-21 14:31:27 -07:00
Stephen Halter
1b1c7fa8ca
Move the SseResponseStreamTransport out of sample (#47) 2025-03-21 13:47:29 -07:00
Jeff Handley
e1a5828036
Remove Nerdbank.GitVersioning and set version to 0.1.0-preview (#52) 2025-03-21 13:09:58 -07:00
Jeff Handley
0309dfc447
Add a release workflow for package build/publishing (#51)
* Add a release workflow for package build/publishing

* Use Windows. Set the fetch depth. Fix build/test/pack for output folder. Upload the artifact.
2025-03-21 12:46:45 -07:00
Jonathan Dick
0cbcad7447
Refactor Resource/ResourceTemplate to subclass Annotated (#50)
The `Resource` and `ResourceTemplate` types should derive from a base `Annotated` type having the `Annotations` property as per the [spec](https://github.com/modelcontextprotocol/specification/blob/main/schema/2024-11-05/schema.ts#L821)

This small change makes the C# types match the schema more closely.

Also renamed Resources.cs to Resource.cs to reflect the type name.
2025-03-21 15:10:27 -04:00
Jonathan Dick
fe6b401014
Add initial support for Resource Templates (#18)
* 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>
2025-03-21 14:09:45 -04:00
Eirik Tsarpalis
50cc48830e
Add strong naming (#49) 2025-03-21 17:51:05 +00:00
Eirik Tsarpalis
0be5963f8c
Remove InternalsVisibleTo from main project. (#46) 2025-03-21 17:35:19 +00:00
Eirik Tsarpalis
c8c974ada3
Add a markdown link checker (#17)
* Add a markdown link checker

* Fix broken link

* Fix more broken links
2025-03-21 14:29:30 +00:00
Stephen Toub
3e4dd011a1
Simplify client samples (#14)
- Remove duplicate projects
- Replace client sample with a simple chat app
2025-03-20 23:25:10 -04:00
Stephen Toub
33b9582199
Address some static analysis and TODOs (#12) 2025-03-20 23:09:38 -04:00
Stephen Toub
3de19d38e4
Change type of Tool.InputSchema to be JsonElement (#4)
* 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>
2025-03-20 19:16:41 +02:00
Mike Kistler
d23e065945
Update copyright in LICENSE file and add THIRD-PARTY-NOTICES.txt (#9) 2025-03-20 11:32:16 -04:00
Stephen Toub
27ba8b1b6a
Upgrade to xunit.v3 (#8)
* Upgrade to xunit.v3

* Use Assert.Skip where applicable.

---------

Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2025-03-20 16:19:35 +02:00
Stephen Toub
6b8c288029
Make McpJsonUtilities public and remove IVT to sample (#5)
Also adds in the same encoder used by AIJsonUtilities.
2025-03-20 16:00:23 +02:00
Stephen Toub
555933a06e
Ensure all test client instances are cleaned up (#3) 2025-03-19 17:27:49 -04:00
Stephen Toub
fd358b437d Fix GetAIFunctionsAsync test to be more deterministic 2025-03-19 16:20:45 -04:00
Stephen Toub
37214bdc70 Fix nuget config 2025-03-19 15:12:55 -04:00
Stephen Toub
17fe8a0e93 Fix global.json's SDK version 2025-03-19 14:57:21 -04:00
Stephen Toub
79b34976ad Fix a few issues in the README 2025-03-19 14:35:08 -04:00
Eirik Tsarpalis
a1b2803e55
Merge pull request #2 from modelcontextprotocol/update-infra
Add Directory.Build.props, apply CPM, use NB.GitVersioning, update package publishing
2025-03-19 17:46:00 +02: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
32f5e07254 Update README.md 2025-03-19 15:42:48 +02:00
Eirik Tsarpalis
c9ed453745 Rename project and namespaces 2025-03-19 15:02:38 +02:00
Eirik Tsarpalis
e7fa6194f6
Turn on the AOT analyzer. (#92)
* Turn on the AOT analyzer.

* Address feedback

* Add missing types.

* Fix build and react to conflicts.

* Fix failing test.

* Address feedback.
2025-03-18 18:48:28 +02:00
Diego Colombo
c0e1d0dd9a
Change handlers to support cancellation token (#99)
* wire the cancellation

* missed file
2025-03-18 17:36:22 +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
Peder Holdgaard Pedersen
b5a26e4c33
HttpListener based SSE Server Support (#73) 2025-03-17 14:56:03 -07:00
Stephen Toub
4597bbd7c2
Integrate Microsoft.Extensions.AI as a foundational building block (#94)
* 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
2025-03-17 16:34:00 -04:00
Stephen Toub
a0afc28ad6
Remove TextReader/Writer parameterization from StdioServerTransport (#96)
It had been added only for tests.
2025-03-17 18:30:37 +01:00
Peder Holdgaard Pedersen
34a6f1c665
Fix resource subscription handling (#89)
* Fix resource subscription handling
Add resource subscription tests

* Fix typo

* Typo

* small fixes

* Fix concurrency issue with test

* Align with specification schemas
2025-03-17 17:54:29 +01:00
Stephen Toub
08b0a04dab
Overhaul McpClientFactory/McpServerFactory (#87)
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.
2025-03-16 12:08:52 -04:00
Peder Holdgaard Pedersen
63b24a4036
Upgrade Anthropic.SDK to 4.7.1 (#86)
Tweak AnthropicTools sample prompt
2025-03-15 23:07:45 -04:00
Peder Holdgaard Pedersen
7bf450e443
Fix docker based integration tests to be more robust (#74)
* Fix docker based integration tests to be more robust
* Make docker based integration tests manual
2025-03-15 20:56:46 +01:00
Stephen Toub
729c8b5eb9
Make logging optional in all public APIs (#72) 2025-03-13 18:16:21 -04:00
Stephen Toub
2c852f0757
Update README to work with latest code (#70) 2025-03-13 12:50:37 -04:00
Stephen Toub
9e92bc9ce0
Remove InputOutputStreams and clean up StdioServerTransport ctors (#71)
- There doesn't appear to be a meaningful scenario for injecting different readers/writers than stdin/stdout, and having InputOutputStreams complicates the API.
- Logically folks talk about "input and output", "readers and writers", etc., and "stdio" is "standard input and output", so having input specified first is less likely to be a source of bugs.
- Logger should be optional, not required, to simplify the common and getting-started cases.
2025-03-13 12:45:30 -04:00
Peder Holdgaard Pedersen
9c500b4be7
Ensure CamelCase of enum serialization (#67) 2025-03-13 15:28:38 +01:00
Stephen Toub
67320b22d5
Move functionality out of IMcpClient/Server into extensions (#60) 2025-03-13 07:55:06 -04:00
Clay Upton
cdcf134e7a
Update StdioClientTransport.cs (#68) 2025-03-13 06:26:53 +01:00
Peder Holdgaard Pedersen
d83640d552
Bump version to 1.1.0 (#65) 2025-03-12 21:20:06 +01:00