Skip to content

Commit c466c0e

Browse files
authored
Merge branch 'main' into copilot/improve-elicitation-enum-schema
2 parents 40513d5 + 3f39ba7 commit c466c0e

17 files changed

Lines changed: 153 additions & 47 deletions

.github/dependabot.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ updates:
1717
patterns:
1818
- "xunit.*"
1919
- "Microsoft.NET.Test.Sdk"
20-
- "Microsoft.Testing.*"
2120
- "coverlet.*"
2221
- "GitHubActionsTestLogger"
2322
- "Moq"

Directory.Build.props

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,8 @@
2929
</PropertyGroup>
3030

3131
<PropertyGroup>
32-
<UseMicrosoftTestingPlatformRunner>true</UseMicrosoftTestingPlatformRunner>
33-
<_MTPResultsDirectory>$(ArtifactsTestResultsDir)</_MTPResultsDirectory>
34-
<TestingPlatformCommandLineArguments>$(TestingPlatformCommandLineArguments) --results-directory $(_MTPResultsDirectory) --report-trx --report-trx-filename $(MSBuildProjectName).$(TargetFramework).$(OS).trx</TestingPlatformCommandLineArguments>
32+
<VSTestLogger Condition="'$(VSTestLogger)' == ''">trx%3bLogFileName=$(MSBuildProjectName).$(TargetFramework).$(OS).trx</VSTestLogger>
33+
<VSTestResultsDirectory Condition="'$(VSTestResultsDirectory)' == ''">$(ArtifactsTestResultsDir)</VSTestResultsDirectory>
3534
</PropertyGroup>
3635

3736
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

Directory.Packages.props

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
<System8Version>8.0.22</System8Version>
55
<System9Version>9.0.11</System9Version>
66
<System10Version>10.0.0</System10Version>
7-
<MicrosoftTestingPlatformVersion>2.0.2</MicrosoftTestingPlatformVersion>
87
</PropertyGroup>
98

109
<!-- Product dependencies shared -->
@@ -53,17 +52,19 @@
5352

5453
<!-- Testing dependencies -->
5554
<PackageVersion Include="Anthropic.SDK" Version="5.8.0" />
56-
<PackageVersion Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.1.0" />
57-
<PackageVersion Include="Microsoft.Testing.Extensions.HangDump" Version="$(MicrosoftTestingPlatformVersion)" />
58-
<PackageVersion Include="Microsoft.Testing.Extensions.CrashDump" Version="$(MicrosoftTestingPlatformVersion)" />
59-
<PackageVersion Include="Microsoft.Testing.Extensions.TrxReport" Version="$(MicrosoftTestingPlatformVersion)" />
55+
<PackageVersion Include="coverlet.collector" Version="6.0.4">
56+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
57+
<PrivateAssets>all</PrivateAssets>
58+
</PackageVersion>
59+
<PackageVersion Include="GitHubActionsTestLogger" Version="2.4.1" />
6060
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="10.0.0-preview.1.25559.3" />
6161
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(System10Version)" />
6262
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(System10Version)" />
6363
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(System10Version)" />
6464
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(System10Version)" />
6565
<PackageVersion Include="Microsoft.Extensions.Options" Version="$(System10Version)" />
6666
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="$(System10Version)" />
67+
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
6768
<PackageVersion Include="Moq" Version="4.20.72" />
6869
<PackageVersion Include="OpenTelemetry" Version="1.14.0" />
6970
<PackageVersion Include="OpenTelemetry.Exporter.InMemory" Version="1.14.0" />
@@ -72,13 +73,14 @@
7273
<PackageVersion Include="OpenTelemetry.Extensions.Hosting" Version="1.14.0" />
7374
<PackageVersion Include="OpenTelemetry.Instrumentation.AspNetCore" Version="1.14.0" />
7475
<PackageVersion Include="Serilog.Extensions.Hosting" Version="9.0.0" />
75-
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.1" />
76-
<PackageVersion Include="Serilog.Sinks.Console" Version="6.0.0" />
76+
<PackageVersion Include="Serilog.Extensions.Logging" Version="9.0.2" />
77+
<PackageVersion Include="Serilog.Sinks.Console" Version="6.1.1" />
7778
<PackageVersion Include="Serilog.Sinks.Debug" Version="3.0.0" />
7879
<PackageVersion Include="Serilog.Sinks.File" Version="7.0.0" />
7980
<PackageVersion Include="Serilog" Version="4.3.0" />
8081
<PackageVersion Include="System.Linq.AsyncEnumerable" Version="$(System10Version)" />
81-
<PackageVersion Include="xunit.v3.mtp-v2" Version="3.2.0" />
82+
<PackageVersion Include="xunit.v3" Version="3.2.0" />
83+
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
8284
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
8385
<PackageVersion Include="JsonSchema.Net" Version="7.4.0" />
8486
</ItemGroup>

Makefile

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,18 @@ build: restore
1818
test: build
1919
dotnet test \
2020
--no-build \
21-
--no-progress \
2221
--configuration $(CONFIGURATION) \
23-
--filter-not-trait 'Execution=Manual' \
24-
--crashdump \
25-
--hangdump \
26-
--hangdump-timeout 7m \
27-
--coverage \
28-
--coverage-output-format cobertura \
29-
-p:_MTPResultsDirectory=$(ARTIFACT_PATH)/testresults \
22+
--filter '(Execution!=Manual)' \
23+
--blame \
24+
--blame-crash \
25+
--blame-hang-timeout 7m \
26+
--diag "$(ARTIFACT_PATH)/diag.txt" \
27+
--logger "trx" \
28+
--logger "GitHubActions;summary.includePassedTests=true;summary.includeSkippedTests=true" \
29+
--collect "XPlat Code Coverage" \
30+
--results-directory $(ARTIFACT_PATH)/testresults \
31+
-- \
32+
RunConfiguration.CollectSourceInformation=true
3033

3134
pack: restore
3235
dotnet pack --no-restore --configuration $(CONFIGURATION)

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ To get started writing a client, the `McpClient.CreateAsync` method is used to i
4141
to a server. Once you have an `McpClient`, you can interact with it, such as to enumerate all available tools and invoke tools.
4242

4343
```csharp
44+
using ModelContextProtocol.Client;
45+
using ModelContextProtocol.Protocol;
46+
4447
var clientTransport = new StdioClientTransport(new StdioClientTransportOptions
4548
{
4649
Name = "Everything",
@@ -63,7 +66,7 @@ var result = await client.CallToolAsync(
6366
cancellationToken:CancellationToken.None);
6467

6568
// echo always returns one and only one text content object
66-
Console.WriteLine(result.Content.First(c => c.Type == "text").Text);
69+
Console.WriteLine(result.Content.OfType<TextContentBlock>().First().Text);
6770
```
6871

6972
You can find samples demonstrating how to use ModelContextProtocol with an LLM SDK in the [samples](samples) directory, and also refer to the [tests](tests/ModelContextProtocol.Tests) project for more examples. Additional examples and documentation will be added as in the near future.

docs/index.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ For more information about MCP:
1818

1919
For how-to guides, tutorials, and additional guidance, refer to the [official MCP documentation](https://modelcontextprotocol.io/).
2020

21+
## Official SDK packages
22+
23+
The official C# SDK packages for stable and pre-release versions are published to the [NuGet Gallery](https://www.nuget.org) under the [ModelContextProtocolOfficial](https://www.nuget.org/profiles/ModelContextProtocolOfficial) profile.
24+
25+
Continuous integration builds are published to the modelcontextprotocol organization's [GitHub NuGet package registry](https://github.com/orgs/modelcontextprotocol/packages?ecosystem=nuget).
26+
2127
## License
2228

2329
This project is licensed under the [MIT License](https://github.com/modelcontextprotocol/csharp-sdk/blob/main/LICENSE).

docs/toc.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ items:
33
href: concepts/index.md
44
- name: API Reference
55
href: api/ModelContextProtocol.yml
6-
- name: Github
7-
href: https://github.com/ModelContextProtocol/csharp-sdk
6+
- name: Versioning
7+
href: versioning.md
8+
- name: GitHub
9+
href: https://github.com/ModelContextProtocol/csharp-sdk

docs/versioning.md

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
---
2+
title: C# SDK Versioning
3+
author: jeffhandley
4+
description: ModelContextProtocol C# SDK approach to versioning, breaking changes, and support
5+
uid: versioning
6+
---
7+
The ModelContextProtocol specification continues to evolve rapidly, and it's important for the C# SDK to remain current with specification additions and updates. To enable this, all NuGet packages that compose the SDK will follow [Semantic Versioning 2.0.0](https://semver.org/spec/v2.0.0.html) with MAJOR.MINOR.PATCH version numbers, and optional pre-release versions.
8+
9+
Given a version number MAJOR.MINOR.PATCH, the package versions will increment the:
10+
11+
* MAJOR version when incompatible API changes are included
12+
* MINOR version when functionality is added in a backward-compatible manner
13+
* PATCH version when backward-compatible bug fixes are included
14+
15+
*A pre-release version indicates that the version is unstable and might not satisfy the intended compatibility requirements.*
16+
17+
## Supported versions
18+
19+
Beginning with the 1.0.0 release, the following support policy will be applied for the official C# ModelContextProtocol SDK packages:
20+
21+
1. New functionality and additive APIs will be introduced in MINOR releases within the current MAJOR version only
22+
* New functionality will not be added to an earlier MAJOR version
23+
2. Bugs will be fixed within either:
24+
1. A new PATCH release against the latest MAJOR.MINOR version
25+
2. A new MINOR release against the latest MAJOR version
26+
3. Critical, blocking issues will be fixed against:
27+
1. The latest MINOR version within _the current_ MAJOR version
28+
2. The latest MINOR version within _one previous_ MAJOR version, until the latest MAJOR version has been published for 3 months
29+
30+
## Experimental APIs
31+
32+
MAJOR or MINOR version updates might introduce or alter APIs annotated as [`[Experimental]`](https://learn.microsoft.com/dotnet/api/system.diagnostics.codeanalysis.experimentalattribute). This attribute indicates that an API is experimental and it may change at any time--including within PATCH or MINOR version updates.
33+
34+
Experimental APIs require suppression of diagnostic codes specific to the MCP SDK APIs, using an `MCPEXP` prefix.
35+
36+
## Breaking changes
37+
38+
Prior to the release of a stable 1.0.0 set of NuGet packages, the SDK remains in preview and breaking changes can be introduced without prior notice. All versions beginning with the stable 1.0.0 release will follow semantic versioning, and breaking changes will require increments to the MAJOR version.
39+
40+
If feasible, the SDK will support all versions of the MCP spec. However, if breaking changes to the spec make this infeasible, preference will be given to the most recent version of the MCP spec, and this would be considered a breaking change necessitating a new MAJOR version.
41+
42+
All releases are posted to https://github.com/modelcontextprotocol/csharp-sdk/releases with release notes. Issues and pull requests labeled with `breaking-change` are highlighted in the corresponding release notes.
43+
44+
### Specification schema changes
45+
46+
If the MCP specification changes the schema for JSON payloads, the C# SDK may use the [`McpSession.NegotiatedProtocolVersion`](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.McpSession.html#ModelContextProtocol_McpSession_NegotiatedProtocolVersion) to dynamically change the payload schema, potentially using internal data transfer objects (DTOs) to achieve the needed deserialization behavior. These techniques will be applied where feasible to maintain backward- and forward-compatibility between MCP specification versions.
47+
48+
Refer to the following prototypes for illustrations of how this could be achieved:
49+
50+
* [Support multiple contents in sampling results](https://github.com/eiriktsarpalis/csharp-sdk/pull/2)
51+
* [Support multiple contents in sampling results (using DTOs)](https://github.com/eiriktsarpalis/csharp-sdk/pull/3)
52+
53+
### Obsolete APIs
54+
55+
If APIs within the SDK become obsolete due to changes in the MCP spec or other evolution of the SDK's APIs, the [`[Obsolete]`](https://learn.microsoft.com/dotnet/api/system.obsoleteattribute) attribute will be applied to the affected APIs.
56+
57+
1. Within a MINOR version update, APIs may be marked as `[Obsolete]` to produce _build warnings_ while the API remains functional. The build warnings will provide guidance specific to the affected APIs.
58+
2. Within a MAJOR version update, APIs may be marked as `[Obsolete]` to produce _build errors_ indicating the API is no longer functional and always throws exceptions. The build errors will provide guidance specific to the affected APIs.
59+
3. Within a MAJOR version update, obsolete APIs may be removed. API removals are expected to be rare and avoided wherever possible, and `[Obsolete]` attributes will be applied ahead of the API removal.
60+
61+
Beginning with the 1.0.0 release, all obsoletions will use diagnostic codes specific to the MCP SDK APIs, using an `MCPOBS` prefix.

global.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,5 @@
22
"sdk": {
33
"version": "10.0.100",
44
"rollForward": "minor"
5-
},
6-
"test": {
7-
"runner": "Microsoft.Testing.Platform"
85
}
96
}

src/ModelContextProtocol.Core/Server/McpServerPrompt.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ namespace ModelContextProtocol.Server;
4646
/// <item>
4747
/// <description>
4848
/// <see cref="McpServer"/> parameters are bound directly to the <see cref="McpServer"/> instance associated
49-
/// with this request's <see cref="RequestContext{CallPromptRequestParams}"/>. Such parameters may be used to understand
49+
/// with this request's <see cref="RequestContext{GetPromptRequestParams}"/>. Such parameters may be used to understand
5050
/// what server is being used to process the request, and to interact with the client issuing the request to that server.
5151
/// </description>
5252
/// </item>

0 commit comments

Comments
 (0)