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
11 changes: 11 additions & 0 deletions .github/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
changelog:
categories:
- title: Changes
labels:
- "*"
exclude:
labels:
- dependencies
- title: Dependencies
labels:
- dependencies
52 changes: 27 additions & 25 deletions .github/workflows/build-pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ jobs:
outputs:
name: ${{ steps.initialize.outputs.name }}
docker_tag: ${{ steps.initialize.outputs.docker_tag }}
version: ${{ steps.initialize.outputs.version }}

steps:
- name: Checkout
Expand Down Expand Up @@ -60,6 +61,7 @@ jobs:
echo "version_prefix=$(eval printf "%s" "$VERSION_PREFIX")" >> $GITHUB_OUTPUT
echo "version_suffix=$(eval printf "%s" "$VERSION_SUFFIX")" >> $GITHUB_OUTPUT
echo "docker_tag=$(eval printf "%s" "$DOCKER_TAG")" >> $GITHUB_OUTPUT
echo "version=$(eval printf "%s" "$DOCKER_TAG")" >> $GITHUB_OUTPUT
echo "branch=$(eval printf "%s" "$BRANCH_CURRENT")" >> $GITHUB_OUTPUT
shell: bash

Expand Down Expand Up @@ -111,6 +113,22 @@ jobs:
SUFFIX: ${{ steps.initialize.outputs.version_suffix }}
shell: bash

- name: Verify Template
id: verify-template
run: |
SIZE=$(stat --format=%s packages/*.nupkg)
echo "Template package is $SIZE bytes"
if [ "$SIZE" -gt "$MAX_SIZE" ]; then
echo "::error::Template package is larger than $MAX_SIZE bytes"
exit 1
fi
dotnet new install packages/*.nupkg
dotnet new $(jq -r .shortName .template.config/template.json) --name Template.Verification --output verification
dotnet build verification --configuration Release
env:
MAX_SIZE: 1048576
shell: bash

- name: Upload Coverage
id: upload-coverage
uses: actions/upload-artifact@v7
Expand Down Expand Up @@ -282,40 +300,17 @@ jobs:
needs: [build, coverage, scan, analysis]
if: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}
permissions:
contents: read
contents: write
id-token: write

steps:
- name: Download Image
id: download-image
uses: actions/download-artifact@v8
with:
name: image

- name: Download Template
id: download-template
uses: actions/download-artifact@v8
with:
name: template
path: packages

- name: Load Image
id: load
run: docker load --input image.tar

- name: Docker Login
id: docker-login
uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0
with:
username: ${{ secrets.DOCKER_LOGIN }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Docker Push
id: docker-push
run: docker push $NAME --all-tags
env:
NAME: ${{ needs.build.outputs.name }}

- name: Login to NuGet
id: nuget-login
uses: NuGet/login@8d196754b4036150537f80ac539e15c2f1028841 # v1.2.0
Expand All @@ -324,4 +319,11 @@ jobs:

- name: NuGet Push
id: nuget-push
run: dotnet nuget push packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }}
run: dotnet nuget push packages/*.nupkg --source https://api.nuget.org/v3/index.json --api-key ${{ steps.nuget-login.outputs.NUGET_API_KEY }} --skip-duplicate

- name: GitHub Release
id: github-release
run: gh release create "$VERSION" packages/*.nupkg --repo "$GITHUB_REPOSITORY" --target "$GITHUB_SHA" --title "$VERSION" --generate-notes
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.build.outputs.version }}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"sourceName": "CleanModelContextProtocol",
"preferNameDirectory": true,
"symbols": {
"author": {
"authorName": {
"type": "parameter",
"displayName": "The name of the author of the solution.",
"defaultValue": "Stephen Walsh",
Expand Down
2 changes: 1 addition & 1 deletion NUGET.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ dotnet new install CleanModelContextProtocol.Template
## Usage

``` bash
dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --author "{YOUR_NAME}"
dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --authorName "{YOUR_NAME}"
```

## Documentation
Expand Down
10 changes: 2 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ dotnet new install CleanModelContextProtocol.Template
### Create a solution

``` bash
dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --author "{YOUR_NAME}"
dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --authorName "{YOUR_NAME}"
```

## Running the project
Expand All @@ -57,12 +57,6 @@ The `Dockerfile` has stages for testing, publishing and running, so you can buil
docker build . --target run --tag cleanmodelcontextprotocol:latest --build-arg VERSION_PREFIX={VERSION_NUMBER} --build-arg VERSION_SUFFIX={PRERELEASE_NAME}
```

Every push to `main` publishes an image to Docker Hub.

``` bash
docker pull stphnwlsh/cleanmodelcontextprotocol
```

## Architecture

This solution is loosely based on Clean Architecture. It's by no means perfect, so I prefer to call it "Lean Mean Clean Architecture". Inspiration comes from [Jason Taylor's Clean Architecture Template](https://github.com/jasontaylordev/CleanArchitecture), with some ideas taken further and others scaled back.
Expand All @@ -88,7 +82,7 @@ The one deliberate break from Clean Architecture is that the Presentation projec
- Object mapping using [Mapperly](https://mapperly.riok.app)
- In-memory data using [Entity Framework Core](https://learn.microsoft.com/ef/core/providers/in-memory/) seeded with [Bogus](https://github.com/bchavez/Bogus)
- Testing using [xUnit](https://xunit.net), [Shouldly](https://github.com/shouldly/shouldly) and [NSubstitute](https://github.com/nsubstitute/NSubstitute), with coverage from [Coverlet](https://github.com/coverlet-coverage/coverlet)
- CI with GitHub Actions: build and test, 95% coverage gate, [Trivy](https://trivy.dev) container scan, [CodeQL](https://codeql.github.com) static analysis, then Docker Hub and NuGet publishing from `main` using [trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing)
- CI with GitHub Actions: build and test, 95% coverage gate, [Trivy](https://trivy.dev) container scan, [CodeQL](https://codeql.github.com) static analysis, then NuGet publishing and a GitHub release from `main` using [trusted publishing](https://learn.microsoft.com/nuget/nuget-org/trusted-publishing)
- Monthly grouped dependency updates using [Dependabot](https://docs.github.com/code-security/dependabot)

## Related templates
Expand Down
13 changes: 10 additions & 3 deletions template/template.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,24 @@
<PackageLicenseFile>docs/LICENSE.md</PackageLicenseFile>
<PackageReadmeFile>docs/NUGET.md</PackageReadmeFile>
<PackageIcon>images/icon.png</PackageIcon>
<IncludeContentInPack>true</IncludeContentInPack>
<PackageReleaseNotes>https://github.com/stphnwlsh/CleanModelContextProtocol/releases</PackageReleaseNotes>
<IncludeBuildOutput>false</IncludeBuildOutput>
<ContentTargetFolders>content</ContentTargetFolders>
<NoWarn>$(NoWarn);NU5128;NU5118</NoWarn>
<NoDefaultExcludes>true</NoDefaultExcludes>
<IsTestProject>false</IsTestProject>
<IsPublishable>false</IsPublishable>
</PropertyGroup>

<PropertyGroup>
<TemplateExcludes>../**/bin/**;../**/obj/**;../**/TestResults/**;../**/*.user;../**/.DS_Store</TemplateExcludes>
</PropertyGroup>

<ItemGroup>
<Content Include="../**/*" Exclude="../**/bin/**;../**/obj/**;../**/*.user;../**/*.lock.json;../**/.DS_Store;../**/.git/**;../**/.github/**;../**/.vs/**;../LICENSE.md;../**/*.gitattributes;../NUGET.md;../README.md;../CONTRIBUTING.md;../CODE_OF_CONDUCT.md;../SECURITY.md;../SUPPORT.md;../docs/sponsor.jpg;../**/*.gitignore;../**/nuget.config;../template/**;../**/.dockerignore;../**/.editorconfig;../icon.png;" />
<None Include="../.template.config/**/*" Pack="true" PackagePath="content/.template.config/" />
<None Include="../src/**/*" Exclude="$(TemplateExcludes)" Pack="true" PackagePath="content/src/" />
<None Include="../tests/**/*" Exclude="$(TemplateExcludes)" Pack="true" PackagePath="content/tests/" />
<None Include="../docs/RUN.md" Pack="true" PackagePath="content/docs/" />
<None Include="../*.sln;../Directory.Build.props;../global.json;../NuGet.config;../Dockerfile;../docker-compose.yml;../icon.png;../.*ignore;../.editorconfig;../.gitattributes" Pack="true" PackagePath="content/" />
<None Include="../icon.png" Pack="true" PackagePath="images/" />
<None Include="../LICENSE.md" Pack="true" PackagePath="docs/" />
<None Include="../NUGET.md" Pack="true" PackagePath="docs/" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ namespace CleanModelContextProtocol.Presentation.Tests.Integration;
using Microsoft.AspNetCore.Mvc.Testing;
using Microsoft.Extensions.Hosting;

internal sealed class CleanModelContextProtocolApplication(string environment = "local") : WebApplicationFactory<Program>
internal sealed class ModelContextProtocolApplication(string environment = "local") : WebApplicationFactory<Program>
{
protected override IHost CreateHost(IHostBuilder builder)
{
Expand Down
4 changes: 2 additions & 2 deletions tests/Presentation.Tests.Integration/Tools/BaseToolTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@ namespace CleanModelContextProtocol.Presentation.Tests.Integration;
public abstract class BaseToolTests : IAsyncLifetime, IAsyncDisposable
{
#pragma warning disable CS8618
private CleanModelContextProtocolApplication application;
private ModelContextProtocolApplication application;
private bool disposed;

protected McpClient Client { get; private set; }
#pragma warning restore CS8618

public async Task InitializeAsync()
{
this.application = new CleanModelContextProtocolApplication();
this.application = new ModelContextProtocolApplication();
this.Client = await McpClient.CreateAsync(
new HttpClientTransport(
new HttpClientTransportOptions { Endpoint = new Uri("http://localhost/mcp") },
Expand Down
Loading