Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,28 +8,28 @@ on:

jobs:
build:

runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
fail-fast: false

steps:
- uses: actions/checkout@v4
runs-on: ${{ matrix.os }}

steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Setup .NET

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
dotnet-version: |
9.0.x
8.0.x

# Netfx testing on non-Windows requires mono
# NetFX testing on non-Windows requires mono
- name: Setup Mono
if: runner.os == 'Linux'
run: sudo apt-get install -y mono-devel
Expand All @@ -38,7 +38,7 @@ jobs:
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-everything

Expand All @@ -48,6 +48,9 @@ jobs:
- name: Build
run: dotnet build --configuration ${{ matrix.configuration }}

- name: Pack
run: dotnet pack --configuration ${{ matrix.configuration }}

- name: Test
run: >-
dotnet test
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,11 @@ permissions:
concurrency:
group: "pages"
cancel-in-progress: false

jobs:
publish-docs:
# Only publish from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.repository == 'modelcontextprotocol/csharp-sdk' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand All @@ -42,4 +44,4 @@ jobs:

- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
uses: actions/deploy-pages@v4
37 changes: 37 additions & 0 deletions .github/workflows/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Release Process

The following process is used when publishing new releases to NuGet.org:

1. **Ensure the CI workflow is fully green**
- Some of the integration tests are flaky and require re-running
- Once the state of the branch is known to be good, a release can proceed
- **The release workflow _does not_ run tests**

2. **Create a new Release in GitHub**
- Use the link on the repo home page to [Create a new release](https://github.com/modelcontextprotocol/csharp-sdk/releases/new)
- Click the 'Choose a tag' dropdown button
- Type the name using the `v{major}.{minor}.{patch}-{suffix}` pattern
- Click 'Create new tag: ... on publish'
- Click the 'Target' dropdown button
- Choose the 'Recent Commits' tab
- Select the commit to use for the release, ensuring it's one from above where CI is known to be green
- Click the 'Previous tag' dropdown button
- Choose the previous release to use for generating release notes
- Click the 'Generate release notes button'
- This will add release notes into the Release description
- The generated release notes include what has changed and the list of new contributors
- Verify the Release title
- It will be populated to match the tag name to be created
- This should be retained, using the release title format matching the `v{major}.{minor}.{patch}-{suffix}` format
- Augment the Release description as desired
- This content is presented used on GitHub and is not persisted into any artifacts
- Check the 'Set as a pre-release' button under the release description if appropriate
- Click 'Public release'

3. **Monitor the Release workflow**
- After publishing the release, a workflow will begin for producing the release's build artifacts and publishing the NuGet package to NuGet.org
- If the job fails, troubleshoot and re-run the workflow as needed
- Verify the package version becomes listed on at [https://nuget.org/packages/ModelContextProtocol](https://nuget.org/packages/ModelContextProtocol)

4. **Update the source to increment the version number**
- Immediately after publishing a new release, the [`/src/Directory.Build.Props`](../../src/Directory.Build.props) file needs to be updated to bump the version to the next expected release version
108 changes: 75 additions & 33 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,20 +1,71 @@
# This workflow is triggered by new releases
# It builds, tests, and publishes to the GitHub NuGet package registry
name: Release package
# Publish new package versions of ModelContextProtocol
#
# Daily and Manual Runs
# - Triggered automatically at 07:00 UTC daily
# - Triggered manually using GitHub Actions workflow_dispatch event
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix set to `ci.{github.run_number}`
# - Package published to GitHub package registry
#
# Official Releases
# - Triggered after a GitHub Release is created
# - Version prefix applied from /src/Directory.Build.props
# - Version suffix applied from /src/Directory.Build.props
# - Package published to GitHub package registry
# - Package published to NuGet.org
# - Version prefix and/or suffix should be updated after each release

name: Release Publishing

on:
schedule:
- cron: '0 7 * * *'

workflow_dispatch:
inputs:
version_suffix_override:
description: Version suffix override
type: string

release:
types: [published]

jobs:
build:
build-all-configs:
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
configuration: [Debug, Release]
fail-fast: false

runs-on: ${{ matrix.os }}

steps:
- name: Clone the repo
uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: 9.0.x

- name: Build
run: dotnet build --configuration ${{ matrix.configuration }}

- name: Pack
run: dotnet pack --configuration ${{ matrix.configuration }}

build-package:
runs-on: windows-latest
needs: build-all-configs

env:
version_suffix_args: ${{ github.event_name != 'release' && format('--version-suffix "{0}"', inputs.version_suffix_override || format('ci.{0}', github.run_number)) || '' }}

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis

- name: Setup .NET
uses: actions/setup-dotnet@v2
Expand All @@ -23,25 +74,11 @@ jobs:
9.0.x
8.0.x

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20'

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-everything

- name: Install dependencies for tests
run: npm install @modelcontextprotocol/server-memory

- name: Build
run: dotnet build --configuration Release

- name: Test
run: dotnet test --configuration Release --no-build --filter '(Execution!=Manual)'

- name: Pack
run: dotnet pack --configuration Release --output "${{ github.workspace }}/artifacts/packages"
run: dotnet pack
${{ env.version_suffix_args }}
--configuration Release
--output "${{ github.workspace }}/artifacts/packages"

- name: Upload artifact
uses: actions/upload-artifact@v4
Expand All @@ -50,20 +87,16 @@ jobs:
name: build-artifacts
path: ${{ github.workspace }}/artifacts

publish:
name: Publish Package
needs: build
publish-package:
needs: build-package
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Setup .NET
uses: actions/setup-dotnet@v2
with:
dotnet-version: |
9.0.x
8.0.x
dotnet-version: 9.0.x

- name: Download build artifacts
uses: actions/download-artifact@v4
Expand All @@ -75,7 +108,7 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: NuGet authentication for GitHub
- name: Authenticate to GitHub registry
run: dotnet nuget add source
"https://nuget.pkg.github.com/${{ github.repository_owner }}/index.json"
--name "github"
Expand All @@ -89,3 +122,12 @@ jobs:
--source "github"
--api-key ${{ secrets.GITHUB_TOKEN }}
--skip-duplicate

- name: Publish to NuGet.org (Releases only)
# Only publish to NuGet.org from the modelcontextprotocol/csharp-sdk repository
if: ${{ github.event_name == 'release' && github.repository == 'modelcontextprotocol/csharp-sdk' }}
run: dotnet nuget push
${{github.workspace}}/build-artifacts/packages/*.nupkg
--source https://api.nuget.org/v3/index.json
--api-key ${{ secrets.NUGET_KEY_MODELCONTEXTPROTOCOL }}
--skip-duplicate
29 changes: 23 additions & 6 deletions Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,32 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<PackageVersion>0.1.0-preview</PackageVersion>
<Authors>Microsoft</Authors>
<Copyright>© Microsoft Corporation. All rights reserved.</Copyright>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<VSTestLogger>trx%3bLogFileName=$(MSBuildProjectName).$(TargetFramework).$(OS).trx</VSTestLogger>
<VSTestResultsDirectory>$(RepoRoot)/artifacts/TestResults</VSTestResultsDirectory>
<WarnOnPackingNonPackableProject>false</WarnOnPackingNonPackableProject>
</PropertyGroup>

<PropertyGroup>
<RepoRoot>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)'))</RepoRoot>
<ArtifactsDir Condition="'$(ArtifactsDir)' == ''">$([MSBuild]::NormalizeDirectory('$(RepoRoot)', 'artifacts'))</ArtifactsDir>
<ArtifactsObjDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'obj'))</ArtifactsObjDir>
<ArtifactsBinDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'bin'))</ArtifactsBinDir>
<ArtifactsTestResultsDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'TestResults', '$(Configuration)'))</ArtifactsTestResultsDir>
<ArtifactsPackagesDir>$([MSBuild]::NormalizeDirectory('$(ArtifactsDir)', 'packages', '$(Configuration)'))</ArtifactsPackagesDir>
<OutDirName>$(MSBuildProjectName)</OutDirName>

<BaseIntermediateOutputPath>$([System.IO.Path]::GetFullPath('$(ArtifactsObjDir)$(OutDirName)\'))</BaseIntermediateOutputPath>
<IntermediateOutputPath>$(BaseIntermediateOutputPath)$(Configuration)\</IntermediateOutputPath>

<BaseOutputPath>$([System.IO.Path]::GetFullPath('$(ArtifactsBinDir)$(OutDirName)\'))</BaseOutputPath>
<OutputPath>$(BaseOutputPath)$(Configuration)\</OutputPath>

<PackageOutputPath>$(ArtifactsPackagesDir)</PackageOutputPath>
</PropertyGroup>

<PropertyGroup>
<VSTestLogger Condition="'$(VSTestLogger)' == ''">trx%3bLogFileName=$(MSBuildProjectName).$(TargetFramework).$(OS).trx</VSTestLogger>
<VSTestResultsDirectory Condition="'$(VSTestResultsDirectory)' == ''">$(ArtifactsTestResultsDir)</VSTestResultsDirectory>
</PropertyGroup>

<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">
<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild>
</PropertyGroup>
Expand Down
2 changes: 1 addition & 1 deletion README.MD → README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
The official C# SDK for the [Model Context Protocol](https://modelcontextprotocol.io/), enabling .NET applications, services, and libraries to implement and interact with MCP clients and servers. Please visit our [API documentation](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.html) for more details on available functionality.

> [!NOTE]
> This repo is still in preview, breaking changes can be introduced without prior notice.
> This project is in preview; breaking changes can be introduced without prior notice.

## About MCP

Expand Down
7 changes: 5 additions & 2 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@
<PackageProjectUrl>https://github.com/modelcontextprotocol/csharp-sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/modelcontextprotocol/csharp-sdk</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<VersionPrefix>0.1.0</VersionPrefix>
<VersionSuffix>preview.2</VersionSuffix>
<Authors>ModelContextProtocolOfficial</Authors>
<Copyright>© Anthropic and Contributors.</Copyright>
<PackageTags>ModelContextProtocol;mcp;ai;llm</PackageTags>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageIcon>logo.png</PackageIcon>
<IncludeSymbols>true</IncludeSymbols>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<PackageOutputPath>$(RepoRoot)artifacts/</PackageOutputPath>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<AssemblyOriginatorKeyFile>$(RepoRoot)\Open.snk</AssemblyOriginatorKeyFile>
<SignAssembly>true</SignAssembly>
Expand All @@ -23,4 +26,4 @@
<ItemGroup>
<None Include="$(RepoRoot)\logo.png" Pack="true" PackagePath="\" />
</ItemGroup>
</Project>
</Project>
2 changes: 1 addition & 1 deletion src/ModelContextProtocol/ModelContextProtocol.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</ItemGroup>

<ItemGroup>
<None Include="README.md" pack="true" PackagePath="." />
<None Include="..\..\README.md" pack="true" PackagePath="\" />
</ItemGroup>

</Project>
Loading