Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
19 changes: 10 additions & 9 deletions .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ This project is an **MCP (Model Context Protocol) server** that integrates with

## Key Technologies

- **.NET 10.0**: The latest version of .NET (LTS - Long Term Support)
- **.NET 10.0 and .NET 11.0 RC3**: Dual-targeted server and tests; source builds use the exact RC3 SDK pinned in `global.json`
- **Model Context Protocol SDK**: Version 2.0.0, with matching `ModelContextProtocol.Extensions.Tasks`
- **Stdio Transport**: Communication via standard input/output
- **Microsoft.Extensions.Hosting**: For application lifecycle management
- **Microsoft.TemplateEngine.\***: Direct integration with .NET Template Engine (v10.0.101)
- **Microsoft.Build.\***: MSBuild integration for framework validation (v18.0.2)
- **Microsoft.TemplateEngine.\***: v10.0.403 for `net10.0`, v11.0.100-rc.3.26522.148 for `net11.0`; keep dependency groups target-specific
- **Microsoft.Build.\***: MSBuild integration for framework validation (v18.9.6)

`NuGet.Config` adds the public `dotnet-tools` feed for RC3's NuGet 8 dependencies. Packaged tools include those dependencies and do not require the feed at installation. Both targets expose the same MCP tools, and project defaults remain .NET 10 LTS. `RollForward=Minor` does not permit backward or cross-major runtime selection. Verify generated runtimeconfigs and packaged tool execution, not just project builds.

## Architecture

Expand Down Expand Up @@ -96,15 +98,14 @@ dotnet build /path/to/dotnet-mcp/DotNetMcp/DotNetMcp.csproj
### Testing Changes

After making code changes:
1. Build with full path: `dotnet build --project [full path to .csproj]`
1. Build both targets with full path: `dotnet build [full path to .csproj]`
2. Check for compilation errors
3. Test the MCP server manually if significant changes were made

When running tests:

- Use `dotnet test --project ...` to run a specific test project.
- Do not pass a `.csproj` as a positional argument; `dotnet test` will warn: `Specifying a project for 'dotnet test' should be via '--project'`.
- Use `dotnet test --solution ...` to run from the solution.
- Run this repository's tests with `dotnet test --solution DotNetMcp.slnx`. The pinned .NET 11 RC3 SDK has a `--project` discovery regression; solution discovery runs both target frameworks without changing test selectors.
- For other projects, MTP supports `--project ...`; do not pass a `.csproj` as a positional argument.
- Use Microsoft Testing Platform filters after `--` (for example `--filter-class ...`).

## SDK Integration Patterns
Expand Down Expand Up @@ -262,8 +263,8 @@ Framework validation and information.
- 703 passing tests covering all 74 MCP tools
- MCP conformance tests validate protocol compliance
- See [doc/testing.md](../doc/testing.md) for details
- **Build the project**: `dotnet build --project [full path to .csproj]`
- **Run the server**: `dotnet run --project [full path to .csproj]`
- **Build the project**: `dotnet build [full path to .csproj]`
- **Run the server**: `dotnet run --framework net11.0 --project [full path to .csproj]` (or `net10.0`)
- **Manual testing**: Test with MCP Inspector or Claude Desktop
- Verify all commands work with various parameter combinations
- **Test SDK integration**: Try the new template and framework info tools
Expand Down
40 changes: 24 additions & 16 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Restore dependencies
run: dotnet restore DotNetMcp.slnx
Expand All @@ -97,7 +98,7 @@ jobs:
run: pwsh -File scripts/validate-server-json.ps1

- name: Run MCP Conformance and Project Analysis Tests
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" --filter-class "*ProjectAnalysisHelperTests"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests" --filter-class "*ProjectAnalysisHelperTests"

pr_scenario:
# Runs only when scenario-specific files (Scenarios/Prompts/Resources) change.
Expand All @@ -119,6 +120,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Restore dependencies
run: dotnet restore DotNetMcp.slnx
Expand All @@ -129,7 +131,7 @@ jobs:
- name: Run MCP Scenario Tests
env:
DOTNET_MCP_SCENARIO_TESTS: "1"
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"

manual_quick_checks:
if: ${{ github.event_name == 'workflow_dispatch' && inputs.runFullValidation != 'true' }}
Expand All @@ -149,6 +151,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Restore dependencies
run: dotnet restore DotNetMcp.slnx
Expand All @@ -160,13 +163,13 @@ jobs:
run: pwsh -File scripts/validate-server-json.ps1

- name: Run MCP Conformance Tests
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests"

- name: Run MCP Scenario Tests
if: ${{ inputs.runScenarioTests == 'true' }}
env:
DOTNET_MCP_SCENARIO_TESTS: "1"
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"

full_validation:
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.runFullValidation == 'true') }}
Expand All @@ -187,6 +190,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Display .NET info
id: dotnet_info
Expand All @@ -206,15 +210,15 @@ jobs:

- name: Run MCP Conformance Tests
id: conformance_tests
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-class "*McpConformanceTests"

- name: Run MCP Scenario Tests
id: scenario_tests
# For push runs, always run. For manual full runs, allow skipping with input.
if: ${{ github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && inputs.runScenarioTests == 'true') }}
env:
DOTNET_MCP_SCENARIO_TESTS: "1"
run: dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
run: dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"

- name: Test
id: test
Expand All @@ -225,21 +229,25 @@ jobs:
shell: bash
run: |
set -euo pipefail
coverage_file=$(find DotNetMcp.Tests/bin/Release -name '*.cobertura.xml' | head -n 1)
if [[ -z "${coverage_file}" ]]; then
echo "Error: No coverage file found matching '*.cobertura.xml' under 'DotNetMcp.Tests/bin/Release'." >&2
exit 1
fi
echo "Found coverage file: ${coverage_file}"
cp "${coverage_file}" coverage.cobertura.xml
mkdir -p coverage
for tfm in net10.0 net11.0; do
mapfile -t reports < <(find "DotNetMcp.Tests/bin/Release/$tfm" -name '*.cobertura.xml')
if [[ ${#reports[@]} -ne 1 ]]; then
echo "Expected exactly one Cobertura report for $tfm, found ${#reports[@]}." >&2
exit 1
fi
name="$tfm.cobertura.xml"
if [[ "$tfm" == "net10.0" ]]; then name="coverage.cobertura.xml"; fi
cp "${reports[0]}" "coverage/$name"
done

- name: Upload coverage to Codecov
id: upload_codecov
# Upload from any full_validation run (push or workflow_dispatch) targeting the main branch.
if: ${{ github.ref == 'refs/heads/main' }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # pin@v7
with:
files: coverage.cobertura.xml
files: coverage/coverage.cobertura.xml,coverage/net11.0.cobertura.xml
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false

Expand All @@ -248,7 +256,7 @@ jobs:
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7
with:
name: coverage-cobertura
path: coverage.cobertura.xml
path: coverage/*.cobertura.xml

- name: Run Performance Smoke Tests
id: performance_smoke
Expand All @@ -259,7 +267,7 @@ jobs:
run: |
set -uo pipefail
echo "Running performance smoke tests..."
dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj \
dotnet test --solution DotNetMcp.slnx \
--no-build --configuration Release \
--verbosity detailed \
-- --filter-namespace "*Performance*" > performance-results.txt 2>&1 || true
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json
cache: true
cache-dependency-path: |
DotNetMcp.slnx
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Restore dependencies
run: dotnet restore DotNetMcp/DotNetMcp.csproj
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/publish-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json
cache: true
cache-dependency-path: "**/*.csproj"

Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/release-scenarios.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ jobs:
uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
dotnet-version: "10.0.x"
global-json-file: global.json

- name: Display .NET info
id: dotnet_info
Expand All @@ -61,8 +62,8 @@ jobs:
- name: Run Scenario + Release Scenario Tests
id: release_scenarios
run: |
dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
dotnet test --project DotNetMcp.Tests/DotNetMcp.Tests.csproj --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.ReleaseScenarios*"
dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.Scenarios*"
dotnet test --solution DotNetMcp.slnx --no-build --configuration Release --verbosity normal -- --filter-namespace "*DotNetMcp.Tests.ReleaseScenarios*"

- name: Write workflow summary
if: always()
Expand Down
132 changes: 132 additions & 0 deletions .github/workflows/tool-compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
name: Packaged Tool Compatibility

on:
pull_request:
branches: [main]
push:
branches: [main]
workflow_dispatch:
inputs:
rc3_run_id:
description: "For GA-only verification: run ID containing an existing rc3-tool-package artifact (no rebuild)"
required: false
type: string

permissions:
contents: read
actions: read

jobs:
package:
if: ${{ !inputs.rc3_run_id }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v7.0.1
with:
fetch-depth: 0
- uses: actions/setup-dotnet@a98b56852c35b8e3190ac28c8c2271da59106c68 # pin@v6.0.0
with:
global-json-file: global.json
dotnet-version: "10.0.x"
- name: Pack once with RC3
run: dotnet pack "$GITHUB_WORKSPACE/DotNetMcp/DotNetMcp.csproj" --configuration Release --output artifacts/package
- uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7
with:
name: rc3-tool-package
path: artifacts/package/*.nupkg
retention-days: 90

compatibility:
needs: package
if: ${{ always() && (needs.package.result == 'success' || (needs.package.result == 'skipped' && inputs.rc3_run_id)) }}
runs-on: ${{ matrix.os }}
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest]
environment: ${{ inputs.rc3_run_id && fromJSON('["ga"]') || fromJSON('["net10", "rc3", "side-by-side"]') }}
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # pin@v7.0.1
- name: Download current RC3 package
if: ${{ !inputs.rc3_run_id }}
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # pin@v8
with:
name: rc3-tool-package
path: artifacts/package
- name: Download preserved RC3 package without rebuilding
if: ${{ inputs.rc3_run_id }}
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # pin@v8
with:
name: rc3-tool-package
path: artifacts/package
run-id: ${{ inputs.rc3_run_id }}
github-token: ${{ github.token }}
- name: Install isolated SDKs (Linux)
if: runner.os != 'Windows'
shell: bash
env:
CASE: ${{ matrix.environment }}
run: |
set -euo pipefail
curl -fsSL https://dot.net/v1/dotnet-install.sh -o "$RUNNER_TEMP/dotnet-install.sh"
root="$RUNNER_TEMP/compatibility-dotnet"
if [[ "$CASE" == "net10" || "$CASE" == "side-by-side" ]]; then
bash "$RUNNER_TEMP/dotnet-install.sh" --channel 10.0 --quality ga --install-dir "$root" --no-path
fi
if [[ "$CASE" == "rc3" || "$CASE" == "side-by-side" ]]; then
bash "$RUNNER_TEMP/dotnet-install.sh" --version 11.0.100-rc.3.26522.148 --install-dir "$root" --no-path
fi
if [[ "$CASE" == "ga" ]]; then
bash "$RUNNER_TEMP/dotnet-install.sh" --channel 11.0 --quality ga --install-dir "$root" --no-path
fi
- name: Install isolated SDKs (Windows)
if: runner.os == 'Windows'
shell: pwsh
env:
CASE: ${{ matrix.environment }}
run: |
$ErrorActionPreference = 'Stop'
$installer = Join-Path $env:RUNNER_TEMP 'dotnet-install.ps1'
Invoke-WebRequest https://dot.net/v1/dotnet-install.ps1 -OutFile $installer
$root = Join-Path $env:RUNNER_TEMP 'compatibility-dotnet'
if ($env:CASE -in @('net10', 'side-by-side')) {
& $installer -Channel 10.0 -Quality GA -InstallDir $root -NoPath
}
if ($env:CASE -in @('rc3', 'side-by-side')) {
& $installer -Version 11.0.100-rc.3.26522.148 -InstallDir $root -NoPath
}
if ($env:CASE -eq 'ga') {
& $installer -Channel 11.0 -Quality GA -InstallDir $root -NoPath
}
- name: Exercise packaged tool
shell: pwsh
env:
CASE: ${{ matrix.environment }}
run: |
$root = Join-Path $env:RUNNER_TEMP 'compatibility-dotnet'
$sdks = @(Get-ChildItem (Join-Path $root 'sdk') -Directory | Select-Object -ExpandProperty Name)
$major = if ($env:CASE -in @('net10', 'side-by-side')) { '10' } else { '11' }
$sdk = @($sdks | Where-Object { $_ -like "$major.*" })
if ($sdk.Count -ne 1) { throw "Expected one .NET $major SDK: $sdks" }
$runtimeMajor = if ($env:CASE -eq 'net10') { '10' } else { '11' }
$runtime = @(Get-ChildItem (Join-Path $root 'shared/Microsoft.NETCore.App') -Directory |
Where-Object Name -Like "$runtimeMajor.*" | Select-Object -ExpandProperty Name)
if ($runtime.Count -ne 1) { throw 'Expected one server runtime for this case.' }
if ($env:CASE -eq 'ga' -and ($sdks -match '-' -or $runtime -match '-')) {
throw 'GA verification must not contain preview SDKs or runtimes.'
}
$packages = @(Get-ChildItem artifacts/package -Filter '*.nupkg')
if ($packages.Count -ne 1) { throw 'Expected exactly one preserved package.' }
./scripts/test-tool-compatibility.ps1 -PackagePath $packages[0].FullName -DotnetRoot $root `
-ExpectedFramework "net$runtimeMajor.0" -ProjectSdkVersion $sdk[0] `
-ExpectedRuntimeVersion $runtime[0] -OutputDirectory (Join-Path $PWD 'artifacts/compatibility-results')
- name: Preserve selection evidence
if: always()
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # pin@v7
with:
name: compatibility-${{ matrix.os }}-${{ matrix.environment }}
path: |
artifacts/compatibility-results/results.json
artifacts/compatibility-results/*.txt
if-no-files-found: warn
11 changes: 9 additions & 2 deletions DotNetMcp.Tests/DotNetMcp.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<TargetFrameworks>net10.0;net11.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
Expand All @@ -10,7 +10,6 @@

<ItemGroup>
<PackageReference Include="JsonSchema.Net" Version="9.4.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.14" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="10.11.0" />
<PackageReference Include="Microsoft.Testing.Extensions.CodeCoverage" Version="18.12.0" />
<PackageReference Include="ModelContextProtocol" Version="2.3.0" />
Expand All @@ -19,6 +18,14 @@
<PackageReference Include="xunit.v3.mtp-v2" Version="4.0.2" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net10.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="10.0.14" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net11.0'">
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="11.0.0-rc.3.26522.148" />
</ItemGroup>

<ItemGroup>
<Using Include="Xunit" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions DotNetMcp.Tests/Scenarios/McpScenarioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ private async Task StartAsync(CancellationToken cancellationToken)

_client = await McpClient.CreateAsync(
transport,
new() { DiscoverProbeTimeout = TimeSpan.FromSeconds(30) },
loggerFactory: _loggerFactory,
cancellationToken: cancellationToken);

Expand Down
Loading
Loading