Skip to content

Commit 3e5cce5

Browse files
authored
Merge branch 'main' into mcp_chatclient
2 parents 298e76e + bafbb0a commit 3e5cce5

File tree

58 files changed

+2426
-829
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2426
-829
lines changed

.github/workflows/ci-build-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636

3737
steps:
3838
- name: 📥 Clone the repo
39-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
39+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4040
with:
4141
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
4242

@@ -85,7 +85,7 @@ jobs:
8585

8686
- name: 📤 Upload test results artifact
8787
if: always()
88-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
88+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
8989
with:
9090
name: testresults-${{ matrix.os }}-${{ matrix.configuration }}
9191
path: artifacts/testresults/**

.github/workflows/ci-code-coverage.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
publish-coverage:
1111
runs-on: ubuntu-latest
1212
steps:
13-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
13+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1414
- name: Setup .NET
1515
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
1616
with:
@@ -19,7 +19,7 @@ jobs:
1919
9.0.x
2020
2121
- name: Download test results
22-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
22+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
2323
with:
2424
pattern: testresults-*
2525

@@ -36,7 +36,7 @@ jobs:
3636
toolpath: "reportgeneratortool"
3737

3838
- name: Upload combined coverage XML
39-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
39+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
4040
with:
4141
name: coverage
4242
path: ${{ github.workspace }}/report
@@ -56,7 +56,7 @@ jobs:
5656
thresholds: "60 80"
5757

5858
- name: Upload combined coverage markdown
59-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
59+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
6060
with:
6161
name: coverage-markdown
6262
path: ${{ github.workspace }}/code-coverage-results.md

.github/workflows/copilot-setup-steps.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
contents: read
1212

1313
steps:
14-
- uses: actions/checkout@v5.0.1
14+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
1515

1616
- name: Install .NET SDK
1717
uses: actions/[email protected]

.github/workflows/docs.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
steps:
2929
- name: Checkout
30-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
30+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
3131

3232
- name: .NET Setup
3333
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1

.github/workflows/markdown-link-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ jobs:
1616
runs-on: ubuntu-latest
1717
steps:
1818
- name: Checkout
19-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
19+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
2020

2121
- name: Markup Link Checker (mlc)
22-
uses: becheran/mlc@18a06b3aa2901ca197de59c8b0b1f54fdba6b3fa # v1.0.0
22+
uses: becheran/mlc@7ec24825cefe0c9c8c6bac48430e1f69e3ec356e # v1.2.0
2323
with:
2424
# Ignore external links that result in 403 errors during CI. Do not warn for redirects where we want to keep the vanity URL in the markdown or for GitHub links that redirect to the login, and DocFX snippet links.
2525
args: --ignore-links "https://www.anthropic.com/*,https://hackerone.com/anthropic-vdp/*" --do-not-warn-for-redirect-to "https://modelcontextprotocol.io/*,https://github.com/login?*" --ignore-links "*samples/*?name=snippet_*" ./docs

.github/workflows/release.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545

4646
steps:
4747
- name: Clone the repo
48-
uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
48+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
4949
with:
5050
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
5151

@@ -73,7 +73,7 @@ jobs:
7373
version_suffix_args: ${{ github.event_name != 'release' && format('--version-suffix "{0}"', inputs.version_suffix_override || format('ci.{0}', github.run_number)) || '' }}
7474

7575
steps:
76-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
76+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
7777

7878
- name: Setup .NET
7979
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
@@ -89,7 +89,7 @@ jobs:
8989
--output "${{ github.workspace }}/artifacts/packages"
9090

9191
- name: Upload artifact
92-
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
92+
uses: actions/upload-artifact@b7c566a772e6b6bfb58ed0dc250532a479d7789f # v6.0.0
9393
if: ${{ !cancelled() }}
9494
with:
9595
name: build-artifacts
@@ -103,15 +103,15 @@ jobs:
103103
packages: write
104104

105105
steps:
106-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
106+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
107107

108108
- name: Setup .NET
109109
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
110110
with:
111111
dotnet-version: 10.0.x
112112

113113
- name: Download build artifacts
114-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
114+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
115115

116116
- name: Authenticate to GitHub registry
117117
run: dotnet nuget add source
@@ -138,10 +138,10 @@ jobs:
138138
packages: write
139139

140140
steps:
141-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
141+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
142142

143143
- name: Download build artifacts
144-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
144+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
145145

146146
- name: Upload release asset
147147
run: gh release upload ${{ github.event.release.tag_name }}
@@ -158,15 +158,15 @@ jobs:
158158
permissions: { }
159159

160160
steps:
161-
- uses: actions/checkout@93cb6efe18208431cddfb8368fd83d5badbf9bfd # v5.0.1
161+
- uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
162162

163163
- name: Setup .NET
164164
uses: actions/setup-dotnet@2016bd2012dba4e32de620c46fe006a3ac9f0602 # v5.0.1
165165
with:
166166
dotnet-version: 10.0.x
167167

168168
- name: Download build artifacts
169-
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
169+
uses: actions/download-artifact@37930b1c2abaa49bbe596cd826c3c89aef350131 # v7.0.0
170170

171171
- name: Publish to NuGet.org (Releases only)
172172
run: dotnet nuget push

CONTRIBUTING.md

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
# Contributing to MCP C# SDK
2+
3+
Thank you for your interest in contributing to the Model Context Protocol (MCP) C# SDK! This document provides guidelines and instructions for contributing to the project.
4+
5+
One of the easiest ways to contribute is to participate in discussions on GitHub issues. You can also contribute by submitting pull requests with code changes.
6+
7+
Also see the [overall MCP communication guidelines in our docs](https://modelcontextprotocol.io/community/communication), which explains how and where discussions about changes happen.
8+
9+
## Code of Conduct
10+
11+
This project follows the [Contributor Covenant Code of Conduct](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/CODE_OF_CONDUCT.md). By participating, you are expected to uphold this code.
12+
13+
## Bugs and feature requests
14+
15+
> [!IMPORTANT]
16+
> **If you want to report a security-related issue, please see the [Reporting security issues](SECURITY.md#reporting-security-issues) section of SECURITY.md.**
17+
18+
Before reporting a new issue, try to find an existing issue if one already exists. If it already exists, upvote (👍) it. Also, consider adding a comment with your unique scenarios and requirements related to that issue. Upvotes and clear details on the issue's impact help us prioritize the most important issues to be worked on sooner rather than later. If you can't find one, that's okay, we'd rather get a duplicate report than none.
19+
20+
If you can't find an existing issue, please [open a new issue on GitHub](https://github.com/modelcontextprotocol/csharp-sdk/issues).
21+
22+
## Prerequisites
23+
24+
Before you begin, ensure you have the following installed:
25+
26+
- **.NET SDK 10.0 or later** - Required to build and test the project
27+
- Download from [dotnet.microsoft.com/download](https://dotnet.microsoft.com/download)
28+
- Verify installation: `dotnet --version`
29+
30+
The dev container configuration in this repository includes all the necessary tools and SDKs to get started quickly.
31+
32+
## Building the Project
33+
34+
From the root directory of the repository, run:
35+
36+
```bash
37+
dotnet build
38+
```
39+
40+
This builds all projects in the solution with warnings treated as errors.
41+
42+
## Running Tests
43+
44+
### Run All Tests
45+
46+
From the root directory, run:
47+
48+
```bash
49+
dotnet test
50+
```
51+
52+
Some tests require Docker to be installed and running locally. If Docker is not available, those tests will be skipped.
53+
54+
Some tests require credentials for external services. When these are not available, those tests will be skipped.
55+
56+
Use the following environment variables to provide credentials for external services:
57+
58+
- AI:OpenAI:ApiKey - OpenAI API Key
59+
60+
### Run Tests for a Specific Project
61+
62+
```bash
63+
dotnet test tests/ModelContextProtocol.Tests/
64+
```
65+
66+
Tools like Visual Studio, JetBrains Rider, and VS Code also provide integrated test runners that can be used to run and debug individual tests.
67+
68+
### Building the Documentation
69+
70+
This project uses [DocFX](https://dotnet.github.io/docfx/) to generate its conceptual and reference documentation.
71+
72+
To view the documentation locally, run the following command from the root directory:
73+
74+
```bash
75+
make serve-docs
76+
```
77+
78+
Then open your browser and navigate to `http://localhost:8080`.
79+
80+
## Submitting Pull Requests
81+
82+
We are always happy to see PRs from community members both for bug fixes as well as new features.
83+
Here are a few simple rules to follow when you prepare to contribute to our codebase:
84+
85+
### Finding an issue to work on
86+
87+
Issues that are good candidates for first-time contributors are marked with the `good first issue` label.
88+
Those do not require too much familiarity with the framework and are more novice-friendly.
89+
90+
If you want to contribute a change that is not covered by an existing issue, first open an issue with a description of the change you would like to make and the problem it solves so it can be discussed before a pull request is submitted.
91+
92+
Assign yourself to the issue so others know you are working on it.
93+
94+
### Before writing code
95+
96+
For all but the smallest changes, it's a good idea to create a design document or at least a high-level description of your approach and share it in the issue for feedback before you start coding. This helps ensure that your approach aligns with the project's goals and avoids wasted effort.
97+
98+
### Before submitting the pull request
99+
100+
Before submitting a pull request, make sure that it checks the following requirements:
101+
102+
- The code follows the repository's style guidelines
103+
- Tests are included for new features or bug fixes
104+
- All existing and new tests pass locally
105+
- Appropriate error handling has been added
106+
- Documentation has been updated as needed
107+
108+
When submitting the pull request, provide a clear description of the changes made and reference the issue it addresses.
109+
110+
### During pull request review
111+
112+
A project maintainer will review your pull request and provide feedback.
113+
114+
## License
115+
116+
By contributing, you agree that your contributions will be licensed under the MIT License.

Directory.Packages.props

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
44
<System8Version>8.0.22</System8Version>
55
<System9Version>9.0.11</System9Version>
6-
<System10Version>10.0.0</System10Version>
6+
<System10Version>10.0.1</System10Version>
7+
<MicrosoftExtensionsVersion>10.1.1</MicrosoftExtensionsVersion>
78
</PropertyGroup>
89

910
<!-- Product dependencies shared -->
1011
<ItemGroup>
11-
<PackageVersion Include="Microsoft.Extensions.AI" Version="$(System10Version)" />
12-
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="$(System10Version)" />
12+
<PackageVersion Include="Microsoft.Extensions.AI" Version="$(MicrosoftExtensionsVersion)" />
13+
<PackageVersion Include="Microsoft.Extensions.AI.Abstractions" Version="$(MicrosoftExtensionsVersion)" />
1314
<PackageVersion Include="Microsoft.Extensions.Hosting.Abstractions" Version="$(System10Version)" />
1415
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(System10Version)" />
1516
</ItemGroup>
@@ -59,18 +60,18 @@
5960

6061
<!-- Testing dependencies -->
6162
<ItemGroup>
62-
<PackageVersion Include="Anthropic.SDK" Version="5.8.0" />
63+
<PackageVersion Include="Anthropic" Version="12.0.1" />
6364
<PackageVersion Include="coverlet.collector" Version="6.0.4">
6465
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
6566
<PrivateAssets>all</PrivateAssets>
6667
</PackageVersion>
67-
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="10.0.0-preview.1.25559.3" />
68+
<PackageVersion Include="Microsoft.Extensions.AI.OpenAI" Version="10.1.1-preview.1.25612.2" />
6869
<PackageVersion Include="Microsoft.Extensions.DependencyInjection" Version="$(System10Version)" />
6970
<PackageVersion Include="Microsoft.Extensions.Hosting" Version="$(System10Version)" />
7071
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(System10Version)" />
7172
<PackageVersion Include="Microsoft.Extensions.Logging.Console" Version="$(System10Version)" />
7273
<PackageVersion Include="Microsoft.Extensions.Options" Version="$(System10Version)" />
73-
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="$(System10Version)" />
74+
<PackageVersion Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.1.0" />
7475
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="18.0.1" />
7576
<PackageVersion Include="Moq" Version="4.20.72" />
7677
<PackageVersion Include="OpenTelemetry" Version="1.14.0" />
@@ -89,6 +90,6 @@
8990
<PackageVersion Include="xunit.v3" Version="3.2.1" />
9091
<PackageVersion Include="xunit.runner.visualstudio" Version="3.1.5" />
9192
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
92-
<PackageVersion Include="JsonSchema.Net" Version="7.4.0" />
93+
<PackageVersion Include="JsonSchema.Net" Version="8.0.3" />
9394
</ItemGroup>
9495
</Project>

docs/concepts/elicitation/elicitation.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ uid: elicitation
1010
The **elicitation** feature allows servers to request additional information from users during interactions. This enables more dynamic and interactive AI experiences, making it easier to gather necessary context before executing tasks.
1111

1212
The protocol supports two modes of elicitation:
13-
- **Form (In-Band)**: The server requests structured data (strings, numbers, booleans, enums) which the client collects via a form interface and returns to the server.
14-
- **URL Mode**: The server provides a URL for the user to visit (e.g., for OAuth, payments, or sensitive data entry). The interaction happens outside the MCP client.
13+
14+
- **Form (In-Band)**: The server requests structured data (strings, numbers, Booleans, enums) which the client collects via a form interface and returns to the server.
15+
- **URL Mode**: The server provides a URL for the user to visit (for example, for OAuth, payments, or sensitive data entry). The interaction happens outside the MCP client.
1516

1617
### Server Support for Elicitation
1718

@@ -208,6 +209,7 @@ await using var completionHandler = client.RegisterNotificationHandler(
208209
```
209210

210211
This pattern is particularly useful for:
212+
211213
- **Third-party OAuth flows**: When the MCP server needs to obtain tokens from external services on behalf of the user
212214
- **Payment processing**: When user confirmation is required through a secure payment interface
213215
- **Sensitive credential collection**: When API keys or other secrets must be entered directly on a trusted server page rather than through the MCP client

docs/concepts/httpcontext/httpcontext.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ uid: httpcontext
88
## HTTP Context
99

1010
When using the Streamable HTTP transport, an MCP server might need to access the underlying [HttpContext] for a request.
11-
The [HttpContext] contains request metadata such as the HTTP headers, authorization context, and the actual path and query string for the request.
11+
The [HttpContext] object contains request metadata such as the HTTP headers, authorization context, and the actual path and query string for the request.
1212

1313
To access the [HttpContext], the MCP server should add the [IHttpContextAccessor] service to the application service collection (typically in Program.cs).
1414
Then any classes, for example, a class containing MCP tools, should accept an [IHttpContextAccessor] in their constructor and store this for use by its methods.

0 commit comments

Comments
 (0)