Commit graph csharp-sdk/tests/ModelContextProtocol.Tests/Server
Author SHA1 Message Date
Copilot
89fcf3f8b7
Wait for in-flight message handlers before ProcessMessagesCoreAsync returns (#1403)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-03-02 18:59:02 -05:00
Copilot
4af2596019
Auto-populate completion handlers from AllowedValuesAttribute on prompt/resource parameters (#1380)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2026-03-01 13:41:00 -05:00
Copilot
94aa6952eb
Fix Extensions not being copied to ServerCapabilities during initialization (#1399)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-02-27 19:36:15 -05:00
Mackinnon Buck
669c36b229
Unify service configuration for ISseEventStreamStore, IMcpTaskStore, and ISessionMigrationHandler (#1362) 2026-02-23 23:22:59 -08:00
Copilot
124b43b5c1
Add explicit [Experimental] protected constructors to McpClient and McpServer (#1363)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
2026-02-23 21:37:39 -05:00
Copilot
0a0a575a3d
Normalize CallToolResult.StructuredContent to JsonElement? (#1357)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2026-02-23 18:04:09 -05:00
Copilot
4f7095453c
Prevent cancellation of initialize request per MCP spec (#1350)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-02-23 15:40:17 -05:00
Copilot
79b2dbeb20
Fix Metadata delegation in DelegatingMcpServerTool/Prompt/Resource (#1338)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
2026-02-21 00:36:30 -05:00
Copilot
5c35ea9207
Replace concrete collection types with interfaces in public API surface (#1326)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-02-19 19:48:45 -08:00
Copilot
80b1ad21d7
Use ReadOnlyMemory<byte> for binary data to eliminate UTF-16 transcoding (#1070)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
2026-02-19 14:08:05 -08:00
Copilot
b967835144
Use TimeProvider in InMemoryMcpTaskStore for deterministic testing (#1303) 2026-02-18 21:47:31 -08:00
Copilot
186cb93630
Update McpErrorCode XML docs and fix error code usage to align with MCP spec (#1291)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-02-17 13:12:29 -08:00
Copilot
53e9ed8f65
Log tool call name on success, not just failure (#1256) 2026-02-13 09:24:02 -08:00
Stephen Toub
27b5eb8031
Bring up to 0.1.13 conformance (#1254) 2026-02-10 08:33:52 -08:00
Mackinnon Buck
d5c6b0d7f9
Add DistributedCacheEventStreamStore (#1136)
Co-authored-by: Stephen Halter <halter73@gmail.com>
2026-02-03 15:48:57 -08:00
Copilot
e47f88419c
Fix keyset pagination with monotonic UUIDv7-like task IDs (#1215)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2026-01-30 17:09:24 -05:00
Copilot
283caf9810
Fix race condition in AutomaticInputRequiredStatusTests polling logic (#1223)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2026-01-30 15:21:28 -05:00
Copilot
8e57ac6b0e
Centralize test timeout constants to fix sporadic CI failures (#1210)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: ericstj <8918108+ericstj@users.noreply.github.com>
Co-authored-by: Eric StJohn <ericstj@microsoft.com>
2026-01-29 22:06:17 -05:00
Eirik Tsarpalis
10e4f5b20f
Implement MCP task support (SEP-1686) (#1170)
Co-authored-by: Stephen Halter <halter73@gmail.com>
2026-01-27 19:21:02 -08:00
Copilot
46d30444a8
Fix ToJsonObject serialization failure with anonymous types and add support for custom JsonSerializerOptions (#1113)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2026-01-20 11:21:11 +02:00
Mackinnon Buck
b8311756b4
Streamable HTTP resumability + redelivery + SSE polling via server-side disconnect (#1077)
Co-authored-by: Stephen Halter <halter73@gmail.com>
2026-01-14 22:54:25 -08:00
Copilot
8b73a42c9d
Remove private reflection from tests (#1107)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: halter73 <54385+halter73@users.noreply.github.com>
2025-12-16 21:20:42 +02:00
dependabot[bot]
d0ee6a0bef
Bump the other-testing group with 1 update (#1101)
Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Eirik Tsarpalis <eirik.tsarpalis@gmail.com>
2025-12-15 19:46:21 +02:00
Stephen Toub
4a84412331
Add McpClient/Session methods using .Protocol types (#1063) 2025-12-05 13:45:12 -05:00
Copilot
d76bc16bd1
Add ResourceNotFound error code (-32002) (#1062) 2025-12-05 10:39:30 -08:00
Copilot
4808ca0324
Synthesize return description into tool description when UseStructuredContent is false (#1049) 2025-12-05 10:24:49 -08:00
Stephen Halter
ae17ba0b4b
Add support for URL mode elicitation (#1021) 2025-12-05 00:03:16 -08:00
Mike Kistler
c447973972
Add request options bag to high level requests and include Meta (#970)
Co-authored-by: Stephen Toub <stoub@microsoft.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2025-12-04 17:32:12 -05:00
Copilot
db0f4d13b4
Add support for data to McpProtocolException (#1028) 2025-12-03 15:37:54 -08:00
Copilot
136755f2be
Remove obsolete APIs from codebase and standardize MCP diagnostic IDs (#985)
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>
Co-authored-by: eiriktsarpalis <2813363+eiriktsarpalis@users.noreply.github.com>
Co-authored-by: Mackinnon Buck <mackinnon.buck@gmail.com>
Co-authored-by: jeffhandley <1031940+jeffhandley@users.noreply.github.com>
Co-authored-by: Jeff Handley <jeffhandley@users.noreply.github.com>
2025-12-02 10:28:46 -08:00
Stephen Toub
15139cc569
Add tools support to sampling (#976) 2025-11-20 09:52:23 -05:00
Mackinnon Buck
d540dc1fb1
Make RequestId non-required (#984) 2025-11-18 16:03:31 -08:00
Copilot
4b241e7ddc
Align error handling documentation with SEP-1303 (#967)
* Initial plan

* Update documentation to clarify error handling per SEP-1303

- Updated McpErrorCode.InvalidParams documentation to clarify it's for protocol-level errors (malformed requests, unknown primitives)
- Updated CallToolResult documentation to distinguish between tool execution errors and protocol errors
- Updated McpProtocolException documentation to emphasize it's only for protocol-level errors
- Added test to verify input validation errors are returned as tool execution errors (IsError=true)
- Implementation already correctly handles input validation as tool execution errors per SEP-1303

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
2025-11-17 10:01:30 -05:00
Stephen Toub
5fc50fb528
Implement SEP-986: Specify Format for Tool Names (#945)
We can add static analysis to provide compile-time diagnostics later, once the analyzers project is merged. For now, this adds run-time validation.
2025-11-06 08:45:02 -05:00
Mackinnon Buck
121929da36
Audit protocol types (#892) 2025-11-04 15:41:10 -08:00
Stephen Halter
1343dd3ebd
Fix regression matching templated McpServerResources (#897) 2025-10-20 11:13:37 -07:00
Copilot
3bff0adc2f
Add McpMetaAttribute for attaching metadata to tools, prompts, and resources (#857)
* Initial plan

* Add McpMetaAttribute and integrate with tools, prompts, and resources

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Add tests and sample usage for McpMetaAttribute

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Add Meta property to options classes and update logic to merge with attributes

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Fix missing using directives and clarify McpMetaAttribute documentation

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Make Name and Value constructor parameters in McpMetaAttribute and check AIFunction.Metadata.UnderlyingMethod

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Change Value type to object and use JsonSerializer.SerializeToNode, fix nullable warnings

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Fix UnderlyingMethod property path, use SerializerOptions, and fix JsonObject cref

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Simplify MethodInfo resolution to use function.UnderlyingMethod directly

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Fix IL2026 trimming warning by providing type info to JsonSerializer.SerializeToNode

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Fix remaining issues

* Revert to string-based JSON values for McpMetaAttribute with StringSyntax annotation

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Add StringSyntax attribute to Value property and fix sample code to use escaped quotes

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

* Fix tests and a bit of cleanup

* Change approach and add lots of tests

* Use JsonContext for serialization and fix floating point test comparison

Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: stephentoub <2642209+stephentoub@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-10-17 09:02:54 -04:00
Copilot
8f2e21d734
Fix: Synthesize handlers for empty tool/prompt/resource collections (#865)
* Initial plan

* Allow handlers for empty tool/prompt/resource collections

Changed condition from `IsEmpty: false` to `not null` check in McpServerImpl.cs for resources (line 298), prompts (line 459), and tools (line 547). This allows handlers to be synthesized even when collections are empty, enabling dynamic addition of items after initialization.

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: Stephen Toub <stoub@microsoft.com>
2025-10-16 09:57:50 -04:00
Stephen Toub
bfc0980ef5
Add net10.0 assets and run some fixers (#875) 2025-10-15 15:27:43 -04:00
Stephen Halter
3255adb4d6
Propagate tool call exceptions through filters (#844)
* Add McpProtocolException specifically for JSON-RPC errors
2025-10-14 19:10:55 -07:00
Copilot
f28639119b
Implement SEP-973: Icons and metadata support for Implementations, Resources, Tools, and Prompts (#802)
* Initial plan

* Initial plan for SEP-973 implementation

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Implement SEP-973: Add Icon class and icon support to Implementation, Resource, Tool, and Prompt

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Complete SEP-973 implementation with documentation and fix property consistency

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Address code review feedback: improve tests, remove docs, split test files

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Fix tests to use S.T.J. source generator

* Styling fixes

* Simplify Icons property documentation as suggested in code review

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Rename Icon.Src property to Icon.Source for more .NET-y naming

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Add icon support to McpServerTool infrastructure and attributes

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Cleanup

* Refactor icon tests to use Delegate overload instead of MethodInfo pattern

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Change Icon.Sizes property from string to IList<string> per spec update

Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>

* Add icon support to Prompts and Resources (CreateOptions and Attributes)

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Add client-server integration tests for Icons and WebsiteUrl

Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>

* Fix nullability warnings

* Revert "Add client-server integration tests for Icons and WebsiteUrl"

This reverts commit f37de15569e54e86a0709121c9bdf80c5045511c.

* More nullability fixes

* Add more tests

* Address code review feedback: add Theme property, fix docs, improve test patterns

Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>

* Update Icon tests to exercise Theme property

Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>

* Add Theme property assertions to client-server integration tests

Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>

* Fix nullability

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: MackinnonBuck <10456961+MackinnonBuck@users.noreply.github.com>
Co-authored-by: Mackinnon Buck <mackinnon.buck@gmail.com>
Co-authored-by: jozkee <16040868+jozkee@users.noreply.github.com>
Co-authored-by: David Cantú <dacantu@microsoft.com>
2025-10-08 12:23:01 -07:00
David Cantú
5f992994c3
Decouple Handlers and Collections from protocol types (#765)
* Decouple Handlers and Collections (e.g. ToolsHandler and ToolsCollection) from Capabilities by promoting them to the options types.

Also, group all handlers in container classes, for server, I decided to move McpServerHandlers down to Mcp.Core and move the NotificationHandlers there too.

Also, Fix ListResourceTemplatesHandler issue.

* Add remarks for empty protocol capability types

* Keep JsonIgnore properties and mark them as Obsolete

* Continue supporting Obsolete members

* Update Obsolete messages to indicate the member will be removed

* Add EditorBrowsable Never to the remaining obsolete members
2025-09-24 09:42:03 -05:00
Eirik Tsarpalis
7cfe0ef621
Add McpSessions.NegotiatedProtocolVersion property. (#794) 2025-09-19 13:11:01 +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
Stephen Halter
d344c65120
Add middleware and authz support for server-side handlers (#733) 2025-09-10 10:07:45 -07:00
Stephen Toub
70960e1f1b
Remove special-casing of string enumerables in McpServerTool (#699)
We special-case string enumerables, translating them to an array of text content blocks, but other enumerables just get serialized, and there's a reasonable expectation that returning a string[] would produce a JSON array of strings. Just delete the special-casing.
2025-08-13 13:05:42 -04:00
Eirik Tsarpalis
3156818d66
Update MEAI version and add regression test for #601. (#628) 2025-07-16 16:17:49 +03:00
Eirik Tsarpalis
aa75f6f37e
Enable netfx testing. (#588)
* Enable netfx testing.

* Skip impacted tests and re-enable netfx testing.

* Remove redundant comment.

* Remove unnecessary project configuration.

* Simplify test server copying.
2025-07-08 18:50:37 +03:00
Stephen Toub
f3539cc2ca
Enable injecting IMcpServer and friends into ctors (#570) 2025-06-30 10:58:08 -04: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