From eb64d019cddebf4dacd3ac73d0a412a35807de44 Mon Sep 17 00:00:00 2001
From: Stephen Walsh <868017+stphnwlsh@users.noreply.github.com>
Date: Tue, 27 Oct 2026 15:34:50 +0000
Subject: [PATCH] chore: align repository docs, templates and local run setup
Unify README, NUGET.md, CONTRIBUTING, CODE_OF_CONDUCT and SUPPORT across
all five templates, move to GitHub issue forms, refresh the PR template,
point all sponsorship at GitHub Sponsors, and fix docker-compose, Seq and
template packaging drift.
---
.github/FUNDING.yml | 2 -
.github/ISSUE_TEMPLATE/bug_report.md | 41 ------
.github/ISSUE_TEMPLATE/bug_report.yml | 84 +++++++++++++
.github/ISSUE_TEMPLATE/config.yml | 11 ++
.github/ISSUE_TEMPLATE/feature_request.md | 20 ---
.github/ISSUE_TEMPLATE/feature_request.yml | 61 +++++++++
.github/pull_request_template.md | 23 +++-
CODE_OF_CONDUCT.md | 137 +++++++++++++++++++--
CONTRIBUTING.md | 61 +++++++--
Directory.Build.props | 3 +-
Dockerfile | 2 +-
NUGET.md | 18 +--
README.md | 126 +++++++++++++------
SUPPORT.md | 14 +++
docker-compose.yml | 49 ++++----
docs/RUN.md | 30 ++---
src/Presentation/appsettings.docker.json | 2 +-
template/template.csproj | 6 +-
18 files changed, 507 insertions(+), 183 deletions(-)
delete mode 100644 .github/ISSUE_TEMPLATE/bug_report.md
create mode 100644 .github/ISSUE_TEMPLATE/bug_report.yml
create mode 100644 .github/ISSUE_TEMPLATE/config.yml
delete mode 100644 .github/ISSUE_TEMPLATE/feature_request.md
create mode 100644 .github/ISSUE_TEMPLATE/feature_request.yml
create mode 100644 SUPPORT.md
diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml
index 88abf77..c5508ec 100644
--- a/.github/FUNDING.yml
+++ b/.github/FUNDING.yml
@@ -1,3 +1 @@
-# These are supported funding model platforms
-
github: [stphnwlsh]
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 3205926..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,41 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-
-1. Go to '...'
-2. Click on '....'
-3. Scroll down to '....'
-4. See error
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**Screenshots**
-If applicable, add screenshots to help explain your problem.
-
-**Desktop (please complete the following information):**
-
-- OS: [e.g. iOS]
-- Browser [e.g. chrome, safari]
-- Version [e.g. 22]
-
-**Smartphone (please complete the following information):**
-
-- Device: [e.g. iPhone6]
-- OS: [e.g. iOS8.1]
-- Browser [e.g. stock browser, safari]
-- Version [e.g. 22]
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/bug_report.yml b/.github/ISSUE_TEMPLATE/bug_report.yml
new file mode 100644
index 0000000..bb0663e
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/bug_report.yml
@@ -0,0 +1,84 @@
+name: Bug report
+description: Something in the template or the generated solution doesn't work as expected.
+title: "[Bug]: "
+labels: ["bug"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks for taking the time to report a bug. Please search the [existing issues](https://github.com/stphnwlsh/CleanModelContextProtocol/issues) first, and report security vulnerabilities through the [security policy](https://github.com/stphnwlsh/CleanModelContextProtocol/security/policy) instead.
+ - type: textarea
+ id: description
+ attributes:
+ label: What happened?
+ description: A clear description of the bug.
+ validations:
+ required: true
+ - type: textarea
+ id: reproduce
+ attributes:
+ label: Steps to reproduce
+ description: The commands you ran and the steps that trigger the bug.
+ placeholder: |
+ 1. dotnet new install CleanModelContextProtocol.Template
+ 2. dotnet new cleanmodelcontextprotocol --name Sample
+ 3. ...
+ validations:
+ required: true
+ - type: textarea
+ id: expected
+ attributes:
+ label: Expected behaviour
+ description: What you expected to happen instead.
+ validations:
+ required: true
+ - type: input
+ id: template-version
+ attributes:
+ label: Template version
+ description: Run `dotnet new list cleanmodelcontextprotocol` or check NuGet.
+ placeholder: "2026.10.27.1"
+ validations:
+ required: true
+ - type: input
+ id: sdk-version
+ attributes:
+ label: .NET SDK version
+ description: Run `dotnet --version`.
+ placeholder: "10.0.100"
+ validations:
+ required: true
+ - type: dropdown
+ id: environment
+ attributes:
+ label: Where does it happen?
+ multiple: true
+ options:
+ - Running with the .NET CLI
+ - Running in Docker
+ - Running the tests
+ - Installing or creating from the template
+ - The GitHub Actions pipeline
+ - Somewhere else
+ validations:
+ required: true
+ - type: input
+ id: os
+ attributes:
+ label: Operating system
+ placeholder: "Windows 11, macOS 15, Ubuntu 24.04"
+ - type: textarea
+ id: logs
+ attributes:
+ label: Relevant logs or output
+ description: Paste any error messages or stack traces. This is rendered as code, so no backticks are needed.
+ render: shell
+ - type: checkboxes
+ id: checks
+ attributes:
+ label: Before submitting
+ options:
+ - label: I searched the existing issues and this hasn't been reported yet.
+ required: true
+ - label: I agree to follow this project's [code of conduct](https://github.com/stphnwlsh/CleanModelContextProtocol/blob/main/CODE_OF_CONDUCT.md).
+ required: true
diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml
new file mode 100644
index 0000000..2550774
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/config.yml
@@ -0,0 +1,11 @@
+blank_issues_enabled: false
+contact_links:
+ - name: Report a security vulnerability
+ url: https://github.com/stphnwlsh/CleanModelContextProtocol/security/advisories/new
+ about: Please report security vulnerabilities privately, not in a public issue.
+ - name: Get help using the template
+ url: https://github.com/stphnwlsh/CleanModelContextProtocol/blob/main/SUPPORT.md
+ about: Where to look for help before opening an issue.
+ - name: Sponsor the project
+ url: https://github.com/sponsors/stphnwlsh
+ about: Support ongoing work on all five Clean templates.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index bbcbbe7..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: ''
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml
new file mode 100644
index 0000000..0ae184d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/feature_request.yml
@@ -0,0 +1,61 @@
+name: Feature request
+description: Suggest an improvement to the template.
+title: "[Feature]: "
+labels: ["enhancement"]
+body:
+ - type: markdown
+ attributes:
+ value: |
+ Thanks for the suggestion. This template is one of five that share their Application and Infrastructure layers, so it helps to know whether your idea is specific to this template or would apply to all of them.
+ - type: textarea
+ id: problem
+ attributes:
+ label: Problem
+ description: What problem would this solve? For example, "I'm always frustrated when ..."
+ validations:
+ required: true
+ - type: textarea
+ id: solution
+ attributes:
+ label: Proposed solution
+ description: What would you like to happen?
+ validations:
+ required: true
+ - type: textarea
+ id: alternatives
+ attributes:
+ label: Alternatives considered
+ description: Any other approaches or workarounds you've thought about.
+ - type: dropdown
+ id: scope
+ attributes:
+ label: Which layers does it affect?
+ multiple: true
+ options:
+ - Presentation (this template only)
+ - Application (all five templates)
+ - Infrastructure (all five templates)
+ - Tests
+ - Build pipeline or repository setup
+ - Documentation
+ - Not sure
+ validations:
+ required: true
+ - type: dropdown
+ id: contribute
+ attributes:
+ label: Would you like to work on it?
+ options:
+ - "Yes, I'd like to open a pull request"
+ - "No, I'm just suggesting it"
+ validations:
+ required: true
+ - type: checkboxes
+ id: checks
+ attributes:
+ label: Before submitting
+ options:
+ - label: I searched the existing issues and this hasn't been suggested yet.
+ required: true
+ - label: I agree to follow this project's [code of conduct](https://github.com/stphnwlsh/CleanModelContextProtocol/blob/main/CODE_OF_CONDUCT.md).
+ required: true
diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md
index 7bd586c..d07e515 100644
--- a/.github/pull_request_template.md
+++ b/.github/pull_request_template.md
@@ -4,4 +4,25 @@
## Related issues
-
+
+
+## Type of change
+
+- [ ] Bug fix
+- [ ] New feature
+- [ ] Breaking change (the generated solution or template parameters change in a way existing users will notice)
+- [ ] Refactoring or clean-up
+- [ ] Documentation
+- [ ] Build, pipeline or dependency update
+
+## Shared layers
+
+- [ ] This only touches the Presentation layer of this template.
+- [ ] This touches the Application or Infrastructure layers, tests, pipeline or repository setup, so it needs to be carried across all five templates.
+
+## Checklist
+
+- [ ] `dotnet build` and `dotnet test` pass locally with no warnings.
+- [ ] I added or updated tests, and coverage stays at or above 95%.
+- [ ] I updated the README or docs where behaviour changed.
+- [ ] I checked the template still installs and creates a working solution (see CONTRIBUTING.md).
diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md
index c14e269..1b22a20 100644
--- a/CODE_OF_CONDUCT.md
+++ b/CODE_OF_CONDUCT.md
@@ -1,19 +1,134 @@
-# Code of Conduct
+# Contributor Covenant Code of Conduct
-We want Clean Model Context Protocol to be a welcoming project for everyone, whatever their background or experience.
+## Our Pledge
-## Expected behaviour
+We as members, contributors, and leaders pledge to make participation in our
+community a harassment-free experience for everyone, regardless of age, body
+size, visible or invisible disability, ethnicity, sex characteristics, gender
+identity and expression, level of experience, education, socio-economic status,
+nationality, personal appearance, race, caste, color, religion, or sexual
+identity and orientation.
-- Be respectful and considerate in issues, pull requests and discussions.
-- Give and accept constructive feedback gracefully.
-- Assume good intent and keep the focus on what is best for the project.
+We pledge to act and interact in ways that contribute to an open, welcoming,
+diverse, inclusive, and healthy community.
-## Unacceptable behaviour
+## Our Standards
-- Harassment, discrimination, insults or personal attacks.
-- Publishing other people's private information without their permission.
-- Any other conduct that would reasonably be seen as inappropriate in a professional setting.
+Examples of behavior that contributes to a positive environment for our
+community include:
+
+* Demonstrating empathy and kindness toward other people
+* Being respectful of differing opinions, viewpoints, and experiences
+* Giving and gracefully accepting constructive feedback
+* Accepting responsibility and apologizing to those affected by our mistakes,
+ and learning from the experience
+* Focusing on what is best not just for us as individuals, but for the overall
+ community
+
+Examples of unacceptable behavior include:
+
+* The use of sexualized language or imagery, and sexual attention or advances of
+ any kind
+* Trolling, insulting or derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or email address,
+ without their explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+## Enforcement Responsibilities
+
+Community leaders are responsible for clarifying and enforcing our standards of
+acceptable behavior and will take appropriate and fair corrective action in
+response to any behavior that they deem inappropriate, threatening, offensive,
+or harmful.
+
+Community leaders have the right and responsibility to remove, edit, or reject
+comments, commits, code, wiki edits, issues, and other contributions that are
+not aligned to this Code of Conduct, and will communicate reasons for moderation
+decisions when appropriate.
+
+## Scope
+
+This Code of Conduct applies within all community spaces, and also applies when
+an individual is officially representing the community in public spaces.
+Examples of representing our community include using an official e-mail address,
+posting via an official social media account, or acting as an appointed
+representative at an online or offline event.
## Enforcement
-Report concerns privately through the repository's [security advisories](https://github.com/stphnwlsh/CleanModelContextProtocol/security/advisories/new) or by contacting the maintainer, [@stphnwlsh](https://github.com/stphnwlsh). The maintainer will review reports and may remove comments, close issues or pull requests, or block accounts that break these expectations.
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported to the community leaders responsible for enforcement by contacting the
+maintainer, [@stphnwlsh](https://github.com/stphnwlsh), privately through
+[private vulnerability reporting](https://github.com/stphnwlsh/CleanModelContextProtocol/security/advisories/new)
+or through any contact details on the maintainer's GitHub profile.
+All complaints will be reviewed and investigated promptly and fairly.
+
+All community leaders are obligated to respect the privacy and security of the
+reporter of any incident.
+
+## Enforcement Guidelines
+
+Community leaders will follow these Community Impact Guidelines in determining
+the consequences for any action they deem in violation of this Code of Conduct:
+
+### 1. Correction
+
+**Community Impact**: Use of inappropriate language or other behavior deemed
+unprofessional or unwelcome in the community.
+
+**Consequence**: A private, written warning from community leaders, providing
+clarity around the nature of the violation and an explanation of why the
+behavior was inappropriate. A public apology may be requested.
+
+### 2. Warning
+
+**Community Impact**: A violation through a single incident or series of
+actions.
+
+**Consequence**: A warning with consequences for continued behavior. No
+interaction with the people involved, including unsolicited interaction with
+those enforcing the Code of Conduct, for a specified period of time. This
+includes avoiding interactions in community spaces as well as external channels
+like social media. Violating these terms may lead to a temporary or permanent
+ban.
+
+### 3. Temporary Ban
+
+**Community Impact**: A serious violation of community standards, including
+sustained inappropriate behavior.
+
+**Consequence**: A temporary ban from any sort of interaction or public
+communication with the community for a specified period of time. No public or
+private interaction with the people involved, including unsolicited interaction
+with those enforcing the Code of Conduct, is allowed during this period.
+Violating these terms may lead to a permanent ban.
+
+### 4. Permanent Ban
+
+**Community Impact**: Demonstrating a pattern of violation of community
+standards, including sustained inappropriate behavior, harassment of an
+individual, or aggression toward or disparagement of classes of individuals.
+
+**Consequence**: A permanent ban from any sort of public interaction within the
+community.
+
+## Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage],
+version 2.1, available at
+[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
+
+Community Impact Guidelines were inspired by
+[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
+
+For answers to common questions about this code of conduct, see the FAQ at
+[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
+[https://www.contributor-covenant.org/translations][translations].
+
+[homepage]: https://www.contributor-covenant.org
+[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
+[Mozilla CoC]: https://github.com/mozilla/diversity
+[FAQ]: https://www.contributor-covenant.org/faq
+[translations]: https://www.contributor-covenant.org/translations
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index d25a742..4af00c4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -1,28 +1,65 @@
# Contributing to Clean Model Context Protocol
-Thanks for taking the time to contribute. Bug reports, ideas and pull requests are all welcome.
+Thanks for taking the time to contribute. Bug reports, ideas, documentation fixes and pull requests are all welcome.
-## Reporting problems and ideas
+## Before you start
-Open an [issue](https://github.com/stphnwlsh/CleanModelContextProtocol/issues/new/choose) using the bug report or feature request template. For security problems, follow [SECURITY.md](SECURITY.md) instead of opening a public issue.
+- Read and follow the [code of conduct](CODE_OF_CONDUCT.md).
+- Search the [existing issues](https://github.com/stphnwlsh/CleanModelContextProtocol/issues) to see if your bug or idea is already being discussed.
+- For anything larger than a small fix, open an issue first so we can agree on the approach before you write the code.
+- Report security vulnerabilities privately, as described in the [security policy](SECURITY.md), not in a public issue.
-## Making a change
+## One template in a family of five
+
+This repository is one of five templates that share everything except the Presentation layer:
+
+- [Clean Minimal API](https://github.com/stphnwlsh/CleanMinimalApi)
+- [Clean Model Context Protocol](https://github.com/stphnwlsh/CleanModelContextProtocol)
+- [Clean Web API](https://github.com/stphnwlsh/CleanWebApi)
+- [Clean GraphQL API](https://github.com/stphnwlsh/CleanGraphQLApi)
+- [Clean Lambda Function](https://github.com/stphnwlsh/CleanLamdaFunction)
-1. Fork the repository and create a branch from `main`. Name it `feature/`, `fix/` or `chore/` followed by a short description.
-2. Make your change and add or update tests. The project enforces 95% code coverage.
-3. Run the build and tests locally.
+If your change touches the Application or Infrastructure layers, their tests, the build pipeline or the repository setup, it needs to be made in all five. Mention that in your pull request and the maintainer will carry it across.
+
+## Development setup
+
+1. Install the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0). Docker is optional but needed to build the container image.
+1. Fork the repository and clone your fork.
+1. Build and run the tests.
``` bash
dotnet build
dotnet test
```
-4. Open a pull request against `main` and fill in the template. The build, CodeQL and coverage checks must pass before it can be merged.
+1. Run the project as described in [docs/RUN.md](docs/RUN.md).
+
+### Testing the template itself
+
+To check that the template still installs and produces a working solution, install it from your local clone and create a solution from it.
+
+``` bash
+dotnet new install ./ --force
+dotnet new cleanmodelcontextprotocol --name Sample --output ../Sample
+dotnet build ../Sample
+dotnet new uninstall ./
+```
+
+## Making a change
+
+1. Create a branch from `main` named `feature/`, `fix/` or `chore/` followed by a short description, for example `fix/review-validation`.
+1. Keep the change focused. Unrelated refactors are easier to review as separate pull requests.
+1. Add or update tests. The pipeline fails if line coverage drops below 95%.
+1. Follow the style in `.editorconfig` and `Directory.Build.props`. Warnings are treated as errors, so the build must be clean.
+1. Update the README or docs if behaviour changes.
-## Code style
+## Pull requests
-Formatting and analyzer rules live in `.editorconfig` and `Directory.Build.props`. Please follow the surrounding code and keep changes focused.
+1. Open the pull request against `main` and fill in the template.
+1. Link the issue it resolves, for example `Closes #123`.
+1. Every check must pass: Build and Test, Code Coverage, Container Scan and Static Analysis.
+1. Pull requests are squash-merged once they're approved and green.
-## Code of conduct
+## Getting help
-Everyone taking part is expected to follow the [code of conduct](CODE_OF_CONDUCT.md).
+See [SUPPORT.md](SUPPORT.md).
diff --git a/Directory.Build.props b/Directory.Build.props
index a13491f..8db3048 100644
--- a/Directory.Build.props
+++ b/Directory.Build.props
@@ -5,9 +5,8 @@
CleanModelContextProtocol.$(AssemblyName)
AnyCPU
enable
- latest
true
- false
+ latest
diff --git a/Dockerfile b/Dockerfile
index 7b2fef5..f48f40e 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -52,6 +52,6 @@ RUN dotnet publish ./src/**/Presentation.csproj --no-restore -c Release -v quiet
# Runtime Image
FROM ${BASE_IMAGE_REPO}/${BASE_IMAGE_RUNTIME}:${BASE_IMAGE_RUNTIME_TAG} AS run
WORKDIR /
-EXPOSE 80
+EXPOSE 8080
COPY --from=publish /sln/app .
ENTRYPOINT ["dotnet", "Presentation.dll"]
diff --git a/NUGET.md b/NUGET.md
index 4f243bb..8d4feb1 100644
--- a/NUGET.md
+++ b/NUGET.md
@@ -1,25 +1,25 @@
# Clean Model Context Protocol
-This is a template API using a streamlined version of [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) alongside .NET's [Model Context Protocol](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/).
+A `dotnet new` template for a [Model Context Protocol](https://modelcontextprotocol.io) server built with a streamlined version of Clean Architecture and the [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk).
-The MCP NuGet packagages [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) and [ModelContextProtocol.AspNetCore](https://www.nuget.org/packages/ModelContextProtocol.AspNetCore) are in preview and are bound to change. The implmentation will remain fairly basic here until they are officially released.
+It shares its Application and Infrastructure layers with four sibling templates for Minimal APIs, Web API controllers, GraphQL, Model Context Protocol and AWS Lambda.
## Installation
-This is a template and you can install it using the [dotnet new cli](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new). To install the lastest version of the template run the following command.
-
``` bash
dotnet new install CleanModelContextProtocol.Template
```
-To create a new solution using this template run the following command
+## Usage
``` bash
-dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --au "{YOU_AUTHORS_NAME}"
+dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --author "{YOUR_NAME}"
```
-## Connect and Support
+## Documentation
+
+The [README on GitHub](https://github.com/stphnwlsh/CleanModelContextProtocol#readme) covers the architecture, features and how to run the generated solution. Report bugs and ideas in [GitHub issues](https://github.com/stphnwlsh/CleanModelContextProtocol/issues).
-If you like this, or want to checkout my other work, please connect with me on [LinkedIn](https://www.linkedin.com/in/stphnwlsh), and/or follow me on [Medium](https://stphnwlsh.medium.com) or [GitHub](https://github.com/stphnwlsh).
+## Support
-If you want to see more updates or more projects then please support me at [GitHub Sponsors](https://github.com/stphnwlsh) or [Buy Me A Coffee](https://www.buymeacoffee.com/stphnwlsh)
+If this template saves you time, please consider [sponsoring me on GitHub](https://github.com/sponsors/stphnwlsh).
diff --git a/README.md b/README.md
index 4491a43..09cb0da 100644
--- a/README.md
+++ b/README.md
@@ -1,43 +1,63 @@
# Clean Model Context Protocol
-[](https://github.com/stphnwlsh/CleanModelContextProtocol/actions/workflows/build-pipeline.yml)
-[](https://codecov.io/gh/stphnwlsh/CleanModelContextProtocol)
+[](https://github.com/stphnwlsh/CleanModelContextProtocol/actions/workflows/build-pipeline.yml)
+[](https://codecov.io/gh/stphnwlsh/CleanModelContextProtocol)
[](https://scorecard.dev/viewer/?uri=github.com/stphnwlsh/CleanModelContextProtocol)
-[](https://www.nuget.org/packages/CleanModelContextProtocol.Template/)
-[](https://github.com/sponsors/stphnwlsh/sponsorships?sponsor=stphnwlsh&tier_id=333950)
-[](https://www.buymeacoffee.com/stphnwlsh)
+[](https://www.nuget.org/packages/CleanModelContextProtocol.Template)
+[](https://www.nuget.org/packages/CleanModelContextProtocol.Template)
+[](LICENSE.md)
+[](https://github.com/sponsors/stphnwlsh)
-This is a template API using a streamlined version of [Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html) alongside .NET's [Model Context Protocol](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp/).
+A `dotnet new` template for a [Model Context Protocol](https://modelcontextprotocol.io) server built with a streamlined version of Clean Architecture and the [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk).
-The MCP NuGet packagages [ModelContextProtocol](https://www.nuget.org/packages/ModelContextProtocol) and [ModelContextProtocol.AspNetCore](https://www.nuget.org/packages/ModelContextProtocol.AspNetCore) are in preview and are bound to change. The implmentation will remain fairly basic here until they are officially released.
+It's one of five templates that share the same Application and Infrastructure layers and differ only in how they present them. See [Related templates](#related-templates).
-## Prerequisites
+## Contents
-This solution in built on the [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0), you need to install that before it will work for you. If you want to build the Dockerfile you will need to install [Docker](https://www.docker.com/products/docker-desktop) as well.
+- [Getting started](#getting-started)
+- [Running the project](#running-the-project)
+- [Architecture](#architecture)
+- [Features](#features)
+- [Related templates](#related-templates)
+- [Resources](#resources)
+- [Contributing](#contributing)
+- [Support](#support)
+- [License](#license)
-## Installation
+## Getting started
-This is a template and you can install it using the [dotnet new cli](https://docs.microsoft.com/en-us/dotnet/core/tools/dotnet-new). To install the lastest version of the template run the following command.
+### Prerequisites
+
+- [.NET 10 SDK](https://dotnet.microsoft.com/download/dotnet/10.0)
+- [Docker](https://www.docker.com/products/docker-desktop) (optional, to build and run the container image)
+
+### Install the template
``` bash
dotnet new install CleanModelContextProtocol.Template
```
-To create a new solution using this template run the following command
+### Create a solution
-```bash
-dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --au "{YOU_AUTHORS_NAME}"
+``` bash
+dotnet new cleanmodelcontextprotocol --name {YOUR_SOLUTION_NAMESPACE} --author "{YOUR_NAME}"
```
-## Docker
+## Running the project
+
+``` bash
+docker compose up -d
+```
-There's a dockerfile included in the build folder and serves the purpose of restoring, building, testing, publishing and then creating a runtime image of the API. Works on my machine.....you can add a version prefix and suffix to version the service in the assembly. The Dockerfile does have stages so you can just run the tests or publish the solution depending on your needs. Review the `build-pipeline.yml` in the github folder for more detailed usage.
+Then open the MCP endpoint (connect with an MCP client such as the [MCP Inspector](https://github.com/modelcontextprotocol/inspector)) at . See [docs/RUN.md](docs/RUN.md) for every way to run it.
+
+The `Dockerfile` has stages for testing, publishing and running, so you can build just the part you need. You can also stamp a version into the assembly.
``` bash
-docker build . -t cleanmodelcontextprotocol:latest --build-arg VERSION_PREFIX {VERSION_NUMBER} -- build-arg VERSION_SUFFIX {PRERELEASE_NAME}
+docker build . --target run --tag cleanmodelcontextprotocol:latest --build-arg VERSION_PREFIX={VERSION_NUMBER} --build-arg VERSION_SUFFIX={PRERELEASE_NAME}
```
-The Github Action does publish an image of this API and you check it out for yourself by runnning this command in docker.
+Every push to `main` publishes an image to Docker Hub.
``` bash
docker pull stphnwlsh/cleanmodelcontextprotocol
@@ -45,45 +65,69 @@ docker pull stphnwlsh/cleanmodelcontextprotocol
## Architecture
-This solution is loosely based on Clean Architecture patterns, it's by no means perfect. I prefer to call it "Lean Mean Clean Architecture". Inspiration has been taken from [Jason Taylor's Clean Architecture Template](https://github.com/jasontaylordev/CleanArchitecture), but I have made some structural decisions to take some things further and scaled back others.
-
-There's a little CQRS type stuff going on here but it's more in style than real separated functions for reading and writing as under the covers they are the same data source.
+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.
-Breaking the Clean Architecture pattern is the fact that the Infrastructure project is referenced by the Presentation project. This is for **Dependency Injection** purposes, so to protect this a little further, all classes in the Infrastructure project are `internal`. This stops them being accidentally used in the Presentation project.
+There's a little CQRS in the style of the commands and queries, but reads and writes use the same data source underneath.
-### Project Structure
+The one deliberate break from Clean Architecture is that the Presentation project references the Infrastructure project, so it can wire up dependency injection. To protect that boundary, every class in Infrastructure is `internal`, so it can't be used from Presentation by accident.
-It's streamlined into 3 functional projects. All serve their own purpose and segregate aspects of the application to allow easier replacement and updating.
+### Project structure
-1. **Presentation** - Setting up the interactions between the Application layer and the consumer. In the project that's via Model Context Protocol but it could be many other things. The Model Context Protocol uses tools to funnel the actions to the layer that owns the domain.
-1. **Application** - This project owns the domain and business logic. There's validation of the Commands and Queries and handling of domain entities in their own separated structures. Each domain type has it's own interface to a datasource downstream, this project doesn't care what fulfills this contract, as long as someone does.
-1. **Infrastructure** - Here's where the database comes into play. Infra owns the data objects and works with the repository interfaces to fetch, create, update and remove object from the source. There's some entity mapping here to allow specific models with attributes to remain in this layer and not bleed through to the **Application** layer.
+1. **Presentation** - Exposes the Application layer to AI clients as an MCP server over HTTP. Tools are grouped by feature, validate their input and hand the work to MediatR.
+1. **Application** - Owns the domain and business logic. Commands and queries are validated and handled here, and each domain type has its own repository interface. This layer doesn't care what fulfils those contracts, as long as something does.
+1. **Infrastructure** - Owns the data. It implements the repository interfaces to fetch, create, update and remove data, and maps its own data models onto the Application entities so persistence details don't leak upwards.
## Features
-There are plenty of handy implementations of features throughout this solution, in no particular order here are some that might interest you.
-
-- Logging using [Serilog](https://github.com/serilog/serilog)
-- Mediator Pattern using [Mediatr](https://github.com/jbogard/MediatR)
+- MCP server using the [MCP C# SDK](https://github.com/modelcontextprotocol/csharp-sdk)
+- Logging using [Serilog](https://github.com/serilog/serilog), with [Seq](https://datalust.co/seq) when running in Docker
+- Mediator pattern using [MediatR](https://github.com/jbogard/MediatR)
- Validation using [FluentValidation](https://github.com/FluentValidation/FluentValidation)
-- Testing using [Shouldly](https://github.com/shouldly/shouldly) and [NSubstitute](https://github.com/nsubstitute/NSubstitute)
-- OpenApi using [Swashbuckle](https://github.com/domaindrivendev/Swashbuckle.AspNetCore)
-- Object Mapping using [Mapperly](https://mapperly.riok.app)
+- 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)
+- Monthly grouped dependency updates using [Dependabot](https://docs.github.com/code-security/dependabot)
+
+## Related templates
+
+All five templates share the same Application and Infrastructure layers, tests, CI pipeline and repository setup.
+
+| Template | Presentation | Package |
+| --- | --- | --- |
+| [Clean Minimal API](https://github.com/stphnwlsh/CleanMinimalApi) | ASP.NET Core Minimal APIs | [CleanMinimalApi.Template](https://www.nuget.org/packages/CleanMinimalApi.Template) |
+| [Clean Web API](https://github.com/stphnwlsh/CleanWebApi) | ASP.NET Core controllers | [CleanWebApi.Template](https://www.nuget.org/packages/CleanWebApi.Template) |
+| [Clean GraphQL API](https://github.com/stphnwlsh/CleanGraphQLApi) | GraphQL | [CleanGraphQLApi.Template](https://www.nuget.org/packages/CleanGraphQLApi.Template) |
+| **Clean Model Context Protocol** (this repo) | Model Context Protocol server | [CleanModelContextProtocol.Template](https://www.nuget.org/packages/CleanModelContextProtocol.Template) |
+| [Clean Lambda Function](https://github.com/stphnwlsh/CleanLamdaFunction) | AWS Lambda function | [CleanLambdaFunction.Template](https://www.nuget.org/packages/CleanLambdaFunction.Template) |
## Resources
-This sample would not have been possible without gaining inspiration from the following resources. If you are on your own learning adventure please read the following blogs and documentation.
+This template wouldn't exist without these resources. If you're on your own learning adventure, they're well worth a read.
-- [Sam Basu - Build & Leverage MCP Servers in C# for AI-Driven Development](https://platform.uno/blog/build-leverage-mcp-servers-in-c-for-ai-driven-development)
+- [What is the Model Context Protocol (MCP)?](https://modelcontextprotocol.io/docs/getting-started/intro)
+- [MCP C# SDK documentation](https://modelcontextprotocol.github.io/csharp-sdk/)
- [James Montemagno - Build a Model Context Protocol (MCP) server in C#](https://devblogs.microsoft.com/dotnet/build-a-model-context-protocol-mcp-server-in-csharp)
+- [Sam Basu - Build & Leverage MCP Servers in C# for AI-Driven Development](https://platform.uno/blog/build-leverage-mcp-servers-in-c-for-ai-driven-development)
- [Laurent Kempé - SSE-Powered MCP Server with C# and .NET in 15.7MB executable](https://laurentkempe.com/2025/04/05/sse-powered-mcp-server-with-csharp-and-dotnet-in-157mb-executable)
- [Will Velida - Building a Sports-Themed MCP Server Using .NET](https://dev.to/willvelida/building-a-sports-themed-mcp-server-using-net-22ln)
- [Jose Maria Flores Zazo - From API to MCP: How to Expose Your Endpoints Securely to AI](https://medium.com/@jmfloreszazo/from-api-to-mcp-how-to-expose-your-endpoints-securely-to-ai-4aecc84cee28)
-- [MCP C# SDK](https://modelcontextprotocol.github.io/csharp-sdk/api/ModelContextProtocol.html)
-- [What is the Model Context Protocol (MCP)?](https://modelcontextprotocol.io/docs/getting-started/intro)
+- [Andrew Lock - Reducing log verbosity with Serilog RequestLogging](https://andrewlock.net/using-serilog-aspnetcore-in-asp-net-core-3-reducing-log-verbosity/)
+- [Jason Taylor - Clean Architecture Solution Template](https://github.com/jasontaylordev/CleanArchitecture)
+- [Robert C. Martin - The Clean Architecture](https://blog.cleancoder.com/uncle-bob/2012/08/13/the-clean-architecture.html)
+
+## Contributing
+
+Bug reports, ideas and pull requests are welcome. Please read the [contributing guide](CONTRIBUTING.md) and the [code of conduct](CODE_OF_CONDUCT.md) first. To report a security vulnerability, follow the [security policy](SECURITY.md) instead of opening an issue.
+
+## Support
+
+If this template saves you time, please consider [sponsoring me on GitHub](https://github.com/sponsors/stphnwlsh). It helps me keep all five templates up to date.
+
+[](https://github.com/sponsors/stphnwlsh)
-## Connect and Support
+You can also connect with me on [LinkedIn](https://www.linkedin.com/in/stphnwlsh), follow me on [Medium](https://stphnwlsh.medium.com) or [GitHub](https://github.com/stphnwlsh). For help using the template, see [SUPPORT.md](SUPPORT.md).
-If you like this, or want to checkout my other work, please connect with me on [LinkedIn](https://www.linkedin.com/in/stphnwlsh), and/or follow me on [Medium](https://stphnwlsh.medium.com) or [GitHub](https://github.com/stphnwlsh).
+## License
-If you want to see more updates or more projects then please support me at [GitHub Sponsors](https://github.com/stphnwlsh) or [Buy Me A Coffee](https://www.buymeacoffee.com/stphnwlsh)
+Released under the [MIT License](LICENSE.md).
diff --git a/SUPPORT.md b/SUPPORT.md
new file mode 100644
index 0000000..f05af74
--- /dev/null
+++ b/SUPPORT.md
@@ -0,0 +1,14 @@
+# Support
+
+## Getting help
+
+- **Using the template:** start with the [README](README.md) and [docs/RUN.md](docs/RUN.md).
+- **Found a bug?** Open a [bug report](https://github.com/stphnwlsh/CleanModelContextProtocol/issues/new?template=bug_report.yml).
+- **Have an idea?** Open a [feature request](https://github.com/stphnwlsh/CleanModelContextProtocol/issues/new?template=feature_request.yml).
+- **Found a security vulnerability?** Don't open an issue. Follow the [security policy](SECURITY.md).
+
+This is a personal open source project maintained in my spare time, so responses are best effort.
+
+## Supporting the project
+
+If this template is useful to you, please consider [sponsoring me on GitHub](https://github.com/sponsors/stphnwlsh). Sponsorship helps me keep all five templates current with each .NET release.
diff --git a/docker-compose.yml b/docker-compose.yml
index df64981..14946d5 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,29 +1,28 @@
-version: "3.9"
services:
- api:
- build:
- context: .
- target: run
- args:
- VERSION_PREFIX: 1.0.0.0
- VERSION_SUFFIX: docker
- ports:
- - "8080:80"
- - "8081:443"
- environment:
- DOTNET_ENVIRONMENT: docker
- networks:
- - cleanmodelcontextprotocol_network
- depends_on:
- - seq
- seq:
- image: datalust/seq:latest
- ports:
- - "5341:80"
- environment:
- ACCEPT_EULA: Y
- networks:
- - cleanmodelcontextprotocol_network
+ api:
+ build:
+ context: .
+ target: run
+ args:
+ VERSION_PREFIX: 1.0.0.0
+ VERSION_SUFFIX: docker
+ ports:
+ - "8080:8080"
+ environment:
+ DOTNET_ENVIRONMENT: docker
+ networks:
+ - cleanmodelcontextprotocol_network
+ depends_on:
+ - seq
+ seq:
+ image: datalust/seq:latest
+ ports:
+ - "5341:80"
+ environment:
+ ACCEPT_EULA: "Y"
+ SEQ_FIRSTRUN_NOAUTHENTICATION: "true"
+ networks:
+ - cleanmodelcontextprotocol_network
networks:
cleanmodelcontextprotocol_network:
driver: bridge
diff --git a/docs/RUN.md b/docs/RUN.md
index 88d10fe..bece1f6 100644
--- a/docs/RUN.md
+++ b/docs/RUN.md
@@ -1,32 +1,34 @@
-# Clean Model Context Protocol
+# Running Clean Model Context Protocol
-## How to Run Project
+There are two pre-configured environments, `local` and `docker`. The matching `appsettings.*.json` files decide where logs go: the console when running locally, and a [Seq](https://datalust.co/seq) container when running in Docker.
-There are multiple ways to run this project using two pre-configured environments `local` and `docker`. The `appsettings.json` files are configured to run the projects in different ways and connect different application logging mechanisms. When running locally the application logs to the console window, when running in docker it spins up [Seq](https://datalust.co/seq) in a separate container and logs there instead.
+## .NET CLI
-### DOTNET CLI
-
-The CLI makes everything easier in .NET engineering. Running this application is no different. This task is aided by the launchsettings.json file that sets all the parameters required to run the API on your local machine. Ports, environments and logging are all configured in the settings, so the only command required is the following single line statement.
+`launchSettings.json` sets the ports, environment and logging, so one command is enough.
``` bash
dotnet run --project ./src/Presentation
```
-### DOCKER COMPOSE
+## Docker Compose
+
+`docker-compose.yml` starts the app and a Seq container for logs.
-Docker compose makes it easier to start multiple containers at one time and manage their configuration from one file (`docker-compose.yml`). This project will run the application and a [Seq](https://datalust.co/seq) containter for application logging.
+``` bash
+docker compose up -d --build
+```
-- App - http://localhost:8080/swagger
-- Seq - http://localhost:5341
+- App: (MCP endpoint (connect with an MCP client such as the [MCP Inspector](https://github.com/modelcontextprotocol/inspector)))
+- Seq:
-To start the Containers
+To shut the containers down:
``` bash
-docker-compose up -d
+docker compose down
```
-To shut down the containers
+## Tests
``` bash
-docker-compose down
+dotnet test
```
diff --git a/src/Presentation/appsettings.docker.json b/src/Presentation/appsettings.docker.json
index 6cd90cf..0087bf4 100644
--- a/src/Presentation/appsettings.docker.json
+++ b/src/Presentation/appsettings.docker.json
@@ -4,7 +4,7 @@
{
"Name": "Seq",
"Args": {
- "serverUrl": "http://localhost:5341"
+ "serverUrl": "http://seq:5341"
}
}
],
diff --git a/template/template.csproj b/template/template.csproj
index fa65783..07c40a1 100644
--- a/template/template.csproj
+++ b/template/template.csproj
@@ -1,13 +1,13 @@
+ net10.0
Template
- true
CleanModelContextProtocol.Template
Clean Model Context Protocol Template
Stephen Walsh
A template for an API using a streamlined version of Clean Architecture and .NET Model Context Protocol.
- dotnet;api;csharp;template;clean;clean-architecture;model-context-protocol;modelcontextprotocol;mcp;
+ dotnet;api;csharp;template;clean;clean-architecture;model-context-protocol;modelcontextprotocol;mcp
https://github.com/stphnwlsh/CleanModelContextProtocol
https://github.com/stphnwlsh/CleanModelContextProtocol
git
@@ -24,7 +24,7 @@
-
+