Make it yours
Sooner or later you’ll want to evict Deep Space Gardeners and move your own domain in. The tempting move is to delete Movies, Authors and Reviews first. Don’t. Half the tests stop compiling, and the shared plumbing (paging, validation, logging, the error filters, resource links, completions and telemetry) suddenly has nothing to exercise it, so coverage falls through the floor.
Go the other way round. Build your first slice beside the sample domain, prove it works end to end, then take the movies out. This guide adds cinemas, with a cinemas_search tool to list and search them, a cinemas_add tool to add one, a cinemas://{id} resource to read one and a describe_cinema prompt to write a blurb for one, and finishes with a solution that has no movies left in it. We ran every step on a fresh solution: it ends with 112 passing tests and 99.8% line coverage.
The code below assumes you named the solution WorksOnMyMachine.Movies. Swap in your own name wherever you see it.
Build the new slice
Section titled “Build the new slice”-
Add the entity and use cases to
src/Application(add-a-use-case).The entity, the repository interface, two queries and one command, each with a validator. An MCP server needs the second query,
GetCinemaById, more than an API does: every cinema a tool returns comes with a link to acinemas://{id}resource, and something has to answer when a client opens it. Handlers and validators arepublic, like the samples, so Mediator’s source generator and the tests can see them.Directorysrc/Application/Cinemas/
- Entities/Cinema.cs
- ICinemasRepository.cs
DirectoryQueries/GetCinemas/
- GetCinemasQuery.cs
- GetCinemasHandler.cs
- GetCinemasValidator.cs
DirectoryQueries/GetCinemaById/
- GetCinemaByIdQuery.cs
- GetCinemaByIdHandler.cs
- GetCinemaByIdValidator.cs
DirectoryCommands/CreateCinema/
- CreateCinemaCommand.cs
- CreateCinemaHandler.cs
- CreateCinemaValidator.cs
src/Application/Cinemas/Entities/Cinema.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Entities;/// <summary>/// A cinema that shows movies./// </summary>/// <param name="Id">The unique identifier of the cinema.</param>/// <param name="Name">The name of the cinema.</param>public record Cinema(Guid Id, string Name);src/Application/Cinemas/ICinemasRepository.cs namespace WorksOnMyMachine.Movies.Application.Cinemas;using Common.Paging;using Entities;public interface ICinemasRepository{public Task<Page<Cinema>> GetCinemas(string? query,PageRequest page,CancellationToken cancellationToken);public Task<Cinema?> GetCinemaById(Guid id, CancellationToken cancellationToken);public Task<Cinema> CreateCinema(string name, CancellationToken cancellationToken);}The query reuses the shared paging and search rules, so
Common/Pagingstays covered once the sample queries are gone.src/Application/Cinemas/Queries/GetCinemas/GetCinemasQuery.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemas;using Common.Paging;using Entities;using Mediator;/// <summary>/// Lists cinemas one page at a time, optionally only those whose name contains a search term./// </summary>public class GetCinemasQuery : IRequest<Page<Cinema>>{/// <summary>The words to look for in the name, ignoring case. Leave empty to list every cinema.</summary>public string? Query { get; init; }/// <summary>The number of results to skip, 0 for the first page.</summary>public int Offset { get; init; }/// <summary>The largest number of results to return, from 1 to 50.</summary>public int Limit { get; init; } = Paging.DefaultLimit;}src/Application/Cinemas/Queries/GetCinemas/GetCinemasHandler.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemas;using Common.Paging;using Entities;using Mediator;public class GetCinemasHandler(ICinemasRepository repository) : IRequestHandler<GetCinemasQuery, Page<Cinema>>{public async ValueTask<Page<Cinema>> Handle(GetCinemasQuery request, CancellationToken cancellationToken){return await repository.GetCinemas(request.Query, new PageRequest(request.Offset, request.Limit), cancellationToken);}}src/Application/Cinemas/Queries/GetCinemas/GetCinemasValidator.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemas;using Common.Paging;using FluentValidation;public class GetCinemasValidator : AbstractValidator<GetCinemasQuery>{public GetCinemasValidator(){_ = this.RuleFor(r => r.Query).ValidSearchTerm();_ = this.RuleFor(r => r.Offset).ValidOffset();_ = this.RuleFor(r => r.Limit).ValidLimit();}}src/Application/Cinemas/Queries/GetCinemaById/GetCinemaByIdQuery.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemaById;using Entities;using Mediator;public class GetCinemaByIdQuery : IRequest<Cinema>{public Guid Id { get; init; }}src/Application/Cinemas/Queries/GetCinemaById/GetCinemaByIdHandler.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemaById;using Common.Enums;using Common.Exceptions;using Entities;using Mediator;public class GetCinemaByIdHandler(ICinemasRepository repository) : IRequestHandler<GetCinemaByIdQuery, Cinema>{public async ValueTask<Cinema> Handle(GetCinemaByIdQuery request, CancellationToken cancellationToken){var result = await repository.GetCinemaById(request.Id, cancellationToken);NotFoundException.ThrowIfNull(result, EntityType.Cinema);return result;}}src/Application/Cinemas/Queries/GetCinemaById/GetCinemaByIdValidator.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Queries.GetCinemaById;using FluentValidation;public class GetCinemaByIdValidator : AbstractValidator<GetCinemaByIdQuery>{public GetCinemaByIdValidator(){_ = this.RuleFor(r => r.Id).NotEqual(Guid.Empty).WithMessage("A Cinema Id was not supplied.");}}Add
CinematoCommon/Enums/EntityType.cstoo, soNotFoundExceptioncan name what it didn’t find.src/Application/Cinemas/Commands/CreateCinema/CreateCinemaCommand.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Commands.CreateCinema;using Entities;using Mediator;public class CreateCinemaCommand : IRequest<Cinema>{public string Name { get; init; } = string.Empty;}src/Application/Cinemas/Commands/CreateCinema/CreateCinemaHandler.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Commands.CreateCinema;using Entities;using Mediator;public class CreateCinemaHandler(ICinemasRepository repository) : IRequestHandler<CreateCinemaCommand, Cinema>{public async ValueTask<Cinema> Handle(CreateCinemaCommand request, CancellationToken cancellationToken){return await repository.CreateCinema(request.Name, cancellationToken);}}src/Application/Cinemas/Commands/CreateCinema/CreateCinemaValidator.cs namespace WorksOnMyMachine.Movies.Application.Cinemas.Commands.CreateCinema;using FluentValidation;public class CreateCinemaValidator : AbstractValidator<CreateCinemaCommand>{public CreateCinemaValidator(){_ = this.RuleFor(r => r.Name).NotEmpty().WithMessage("A cinema needs a name.");_ = this.RuleFor(r => r.Name).MaximumLength(100).WithMessage("A cinema name can't be longer than 100 characters.");}} -
Store and map it in
src/Infrastructure(data-access-ef-coreandmapping-with-mapperly).Add the database model and its configuration beside the sample ones. Every model inherits
Entity, which brings the id and the created and modified dates, and every configuration inheritsEntityConfiguration<T>, which sets them up.src/Infrastructure/Databases/MovieReviews/Models/Cinema.cs namespace WorksOnMyMachine.Movies.Infrastructure.Databases.MovieReviews.Models;using System.Diagnostics.CodeAnalysis;[ExcludeFromCodeCoverage]internal record Cinema : Entity{public required string Name { get; init; }}src/Infrastructure/Databases/MovieReviews/Configuration/CinemaConfiguration.cs namespace WorksOnMyMachine.Movies.Infrastructure.Databases.MovieReviews.Configuration;using Microsoft.EntityFrameworkCore;using Microsoft.EntityFrameworkCore.Metadata.Builders;using Models;internal class CinemaConfiguration : EntityConfiguration<Cinema>{public override void Configure(EntityTypeBuilder<Cinema> builder){base.Configure(builder);_ = builder.Property(c => c.Name).HasMaxLength(100).UseCollation(Collations.NoCase);_ = builder.HasIndex(c => c.Name);}}Then wire it in:
-
MovieReviewsDbContext.cs: addpublic DbSet<Cinema> Cinemas => this.Set<Cinema>();beside the other sets. -
Mapping/MovieReviewsMapper.cs: addusing AppCinema = Application.Cinemas.Entities.Cinema;andusing InfraCinema = Models.Cinema;with the other aliases, and this method:[MapperIgnoreSource(nameof(InfraCinema.DateCreated))][MapperIgnoreSource(nameof(InfraCinema.DateModified))]public partial AppCinema ToDomain(InfraCinema cinema); -
EntityFrameworkMovieReviewsRepository.cs: addusing Application.Cinemas;andusing ApplicationCinema = Application.Cinemas.Entities.Cinema;, addICinemasRepositoryto the interfaces the class implements, and add aCinemasregion. The search reuses the repository’s ownContainsPatternandEscapeCharacter, so a%or_in a search term matches itself, the same as for movies.#region Cinemaspublic async Task<Page<ApplicationCinema>> GetCinemas(string? query,PageRequest page,CancellationToken cancellationToken){var cinemas = this.context.Cinemas.AsQueryable();if (!string.IsNullOrWhiteSpace(query)){var pattern = ContainsPattern(query);cinemas = cinemas.Where(c => EF.Functions.Like(c.Name, pattern, EscapeCharacter));}var totalCount = await cinemas.CountAsync(cancellationToken);var result = await cinemas.OrderBy(c => c.Name).ThenBy(c => c.Id).Skip(page.Offset).Take(page.Limit).ToListAsync(cancellationToken);return new([.. result.Select(this.mapper.ToDomain)], page.Offset, page.Limit, totalCount);}public async Task<ApplicationCinema?> GetCinemaById(Guid id, CancellationToken cancellationToken){var result = await this.context.Cinemas.FirstOrDefaultAsync(c => c.Id == id, cancellationToken);return result is null ? null : this.mapper.ToDomain(result);}public async Task<ApplicationCinema> CreateCinema(string name, CancellationToken cancellationToken){var now = this.timeProvider.GetUtcNow().UtcDateTime;var cinema = new Cinema{Name = name,DateCreated = now,DateModified = now};_ = this.context.Add(cinema);_ = await this.context.SaveChangesAsync(cancellationToken);return this.mapper.ToDomain(cinema);}#endregion Cinemas -
src/Infrastructure/DependencyInjection.cs: addusing Application.Cinemas;and register the interface against the same repository, like the others:_ = services.AddScoped<ICinemasRepository>(x =>x.GetRequiredService<EntityFrameworkMovieReviewsRepository>()); -
Extensions/MovieReviewsDbContextExtensions.cs(sample-data): givelocalanddockersome cinemas to look at. Add this toAddDatabeforeSaveChanges:var cinemas = new Faker<Cinema>().UseSeed(Seed).RuleFor(c => c.Id, f => f.Random.Guid()).RuleFor(c => c.Name, f => $"{f.Address.City()} Picture House").RuleFor(c => c.DateCreated, f => f.Date.Past(refDate: ReferenceDate)).RuleFor(c => c.DateModified, f => f.Date.Past(refDate: ReferenceDate)).Generate(5);context.AddRange(cinemas);
-
-
Add a migration (
database-migrations).Terminal window dotnet tool install --global dotnet-efdotnet ef migrations add AddCinemas \--project ./src/Infrastructure \--output-dir Databases/MovieReviews/Migrations \--namespace WorksOnMyMachine.Movies.Infrastructure.Databases.MovieReviews.Migrationssed -i '1s/^\xEF\xBB\xBF//' src/Infrastructure/Databases/MovieReviews/Migrations/*.csWithout
--namespacethe migration lands in a namespace of its own. Thesedstrips the byte order mark the tool adds. On macOS, usesed -i ''. Then make// <auto-generated />the first line of the new<timestamp>_AddCinemas.cs, as it is in the other migrations, so the analysers leave generated code alone.
Expose and test it
Section titled “Expose and test it”-
Put it on tools, a resource and a prompt in
src/Presentation(expose-a-use-case,api-conventionsandjson-serialization).This is where an MCP server earns its keep. A model reads the tool names, titles, annotations and descriptions to decide what to call, so they’re written for a model to read, the same way the sample’s are. Tools return a result model rather than the Application entity, so the server decides exactly what a client sees.
src/Presentation/Models/CinemaResult.cs namespace WorksOnMyMachine.Movies.Presentation.Models;using System.ComponentModel;/// <summary>/// A cinema that shows movies./// </summary>/// <param name="Id">The cinema's id.</param>/// <param name="Name">The cinema's name.</param>public record CinemaResult([property: Description("The cinema's id.")] Guid Id,[property: Description("The cinema's name.")] string Name);src/Presentation/Tools/CinemaTools.cs namespace WorksOnMyMachine.Movies.Presentation.Tools;using Mediator;using ModelContextProtocol.Server;using Presentation.Models;using Commands = Application.Cinemas.Commands;using Queries = Application.Cinemas.Queries;[McpServerToolType]public static partial class CinemaTools{/// <summary>/// Find cinemas by name, ignoring case, in name order. Each result has the cinema's id and name. Leave the query/// empty to browse every cinema a page at a time. Use this to check a cinema isn't already there before calling/// cinemas_add./// </summary>/// <param name="query">Part of the cinema's name, such as 'astor'. Leave empty to list every cinema.</param>/// <param name="offset">The number of results to skip, 0 for the first page. Pass the nextOffset from a previous call to get the next page.</param>/// <param name="limit">The most results to return, from 1 to 50.</param>[McpServerTool(Name = "cinemas_search", Title = "Search cinemas", ReadOnly = true, Idempotent = true, OpenWorld = false, UseStructuredContent = true, IconSource = ItemIcons.Cinema)]public static async partial Task<ResultPage<CinemaResult>> SearchCinemas(ISender sender,CancellationToken cancellationToken,string? query = null,int offset = 0,int limit = 10){var page = await sender.Send(new Queries.GetCinemas.GetCinemasQuery{Query = query,Offset = offset,Limit = limit}, cancellationToken);return page.ToResult(c => c.ToResult());}/// <summary>/// Add a cinema and return it with its new id. Calling it twice adds two cinemas, so search first with/// cinemas_search if you're not sure it's already there./// </summary>/// <param name="name">The cinema's name, up to 100 characters, such as 'The Astor'.</param>[McpServerTool(Name = "cinemas_add", Title = "Add cinema", ReadOnly = false, Destructive = false, Idempotent = false, OpenWorld = false, UseStructuredContent = true, IconSource = ItemIcons.Cinema)]public static async partial Task<CinemaResult> AddCinema(ISender sender,string name,CancellationToken cancellationToken){var cinema = await sender.Send(new Commands.CreateCinema.CreateCinemaCommand{Name = name}, cancellationToken);return cinema.ToResult();}}The annotations tell the client how careful to be.
cinemas_searchis read-only and safe to repeat.cinemas_addchanges data, so it isn’t read-only, but it doesn’t destroy anything, and it isn’t idempotent, because calling it twice adds two cinemas. The description says so, and points the model atcinemas_searchfirst.Every cinema a tool returns gets a resource link to
cinemas://{id}, because the scheme is the start of the tool’s name. That link has to open, so add the resource:src/Presentation/Resources/CinemaResources.cs namespace WorksOnMyMachine.Movies.Presentation.Resources;using Mediator;using ModelContextProtocol.Server;using Presentation.Models;using Presentation.Serialization;using Presentation.Tools;using Queries = Application.Cinemas.Queries;[McpServerResourceType]public static partial class CinemaResources{/// <summary>A cinema, by its id.</summary>/// <param name="cinemaId">The cinema's id (a GUID).</param>[McpServerResource(UriTemplate = "cinemas://{cinemaId}", Name = "cinema", Title = "Cinema", MimeType = "application/json", IconSource = ItemIcons.Cinema)]public static async partial Task<string> GetCinema(ISender sender,Guid cinemaId,CancellationToken cancellationToken){var cinema = await sender.Send(new Queries.GetCinemaById.GetCinemaByIdQuery{Id = cinemaId}, cancellationToken);return McpSerializer.Serialize(cinema.ToResult());}}And a prompt, so a client has something to offer the user for cinemas, not just the model:
src/Presentation/Prompts/CinemaPrompts.cs namespace WorksOnMyMachine.Movies.Presentation.Prompts;using Mediator;using ModelContextProtocol.Protocol;using ModelContextProtocol.Server;using Presentation.Models;using Presentation.Serialization;using Presentation.Tools;using Queries = Application.Cinemas.Queries;[McpServerPromptType]public static partial class CinemaPrompts{/// <summary>Write a short, friendly blurb for a cinema's listing, from the cinema's details.</summary>/// <param name="cinemaId">The cinema's id (a GUID).</param>[McpServerPrompt(Name = "describe_cinema", Title = "Describe a cinema", IconSource = ItemIcons.Cinema)]public static async partial Task<GetPromptResult> DescribeCinema(ISender sender,Guid cinemaId,CancellationToken cancellationToken){var cinema = (await sender.Send(new Queries.GetCinemaById.GetCinemaByIdQuery { Id = cinemaId }, cancellationToken)).ToResult();return new GetPromptResult{Description = $"Describe {cinema.Name}",Messages =[PromptContent.Text($"Write a short, friendly blurb for the listing of {cinema.Name}, using the cinema below. Keep it to two sentences."),PromptContent.Embed($"cinemas://{cinema.Id}", McpSerializer.Serialize(cinema))]};}}Then wire it in:
-
Models/ResultMapper.cs: addusing Application.Cinemas.Entities;and the mapping.public static CinemaResult ToResult(this Cinema cinema){return new CinemaResult(cinema.Id, cinema.Name);} -
Tools/ItemIcons.cs: addpublic const string Cinema = Source + "movie-64.png";. Every tool, resource and prompt needs an icon, and a test checks. The movie icon will do until you have your own: pointCinemaat its URL when you do. -
Serialization/AppJsonSerializerContext.cs: add[JsonSerializable(typeof(CinemaResult))]and[JsonSerializable(typeof(ResultPage<CinemaResult>))]. -
Completions/CompletionHandler.cs: addusing CinemaQueries = Application.Cinemas.Queries;and a case toCompleteResourceId, so a client can find a cinema’s id by its name or its first few characters:case "cinemaId":{var page = await sender.Send(new CinemaQueries.GetCinemas.GetCinemasQuery{Query = argument.Value,Limit = Paging.MaxLimit}, cancellationToken);if (page.Items.Count > 0){return Result([.. page.Items.Select(c => c.Id.ToString())], page.TotalCount);}var cinemas = await GetAll(offset => sender.Send(new CinemaQueries.GetCinemas.GetCinemasQuery{Offset = offset,Limit = Paging.MaxLimit}, cancellationToken));return IdsStartingWith(cinemas.Select(c => c.Id), argument.Value);} -
Extensions/WebApplicationBuilderExtensions.cs: mention the cinema tools inServerInstructions. The model reads them before it reads anything else.
There’s nothing else to register: the server finds tools, resources and prompts in the assembly by themselves, and with
--include-auththe whole/mcpendpoint already needs a token. -
-
Test the new slice (
test-design,unit-tests,integration-testsandpresentation-integration-tests).Each new test has a sample test that already does the same job for movies or reviews. Copy it and rename it, and you have the shape, the names and the house style without having to think about them.
tests/Application.Tests.Unit/Cinemas/Queries/GetCinemas/GetCinemasHandlerTests.cs, copied fromMovies/Queries/GetMovies/GetMoviesHandlerTests.cs.tests/Application.Tests.Unit/Cinemas/Queries/GetCinemas/GetCinemasValidatorTests.cs, copied fromMovies/Queries/GetMovies/GetMoviesValidatorTests.cs.tests/Application.Tests.Unit/Cinemas/Queries/GetCinemaById/GetCinemaByIdHandlerTests.csandGetCinemaByIdValidatorTests.cs, copied from the tests inMovies/Queries/GetMovieById/.tests/Application.Tests.Unit/Cinemas/Commands/CreateCinema/CreateCinemaHandlerTests.cs, copied fromReviews/Commands/CreateReview/CreateReviewHandlerTests.cs.tests/Application.Tests.Unit/Cinemas/Commands/CreateCinema/CreateCinemaValidatorTests.cs, copied fromReviews/Commands/CreateReview/CreateReviewValidatorTests.cs.- A
Cinemasregion intests/Infrastructure.Tests.Integration/Databases/MovieReviews/EntityFrameworkMovieReviewsRepositoryTests.cs, copied from theMoviesregion: search, paging, get by id and create. tests/Presentation.Tests.Unit/Tools/CinemaToolTests.cs, copied fromMovieToolTests.csandReviewToolTests.cs.tests/Presentation.Tests.Integration/Tools/CinemaToolTests.cs, copied fromMovieToolTests.csandReviewToolTests.cs.
The repository tests need some cinemas. Add three to
AddTestDataintests/Infrastructure.Tests.Integration/Databases/MovieReviews/Extensions/MovieReviewsCollectionData.cs, named the same way as the sample rows:List<Cinema> cinemas =[new() { Id = Guid.NewGuid(), Name = "One" },new() { Id = Guid.NewGuid(), Name = "Two" },new() { Id = Guid.NewGuid(), Name = "Three" }];context.Cinemas.AddRange(cinemas);A few integration tests list everything the server offers, so they fail until they know about cinemas. They’re doing their job: they pin down exactly what a client sees.
Tools/ToolListTests.cs: add{ "cinemas_search", "Search cinemas", true, false, true }and{ "cinemas_add", "Add cinema", false, false, false }to the expected tools and their annotations.Resources/ResourceTests.cs: add"cinemas://{cinemaId}"to the expected templates, and read a cinema, an unknown id and an empty id, as the movie tests do.Prompts/PromptTests.cs: add"describe_cinema"to the expected prompts.Tools/ResourceLinkTests.csandCompletions/CompletionTests.cs: add a test thatcinemas_addlinks the new cinema, and one that completes acinemaIdby name and by its first eight characters.
Terminal window dotnet builddotnet testdotnet format --verify-no-changesBoth domains now run side by side. Stop here if you’re keeping the sample for reference, which is a perfectly respectable choice.
Take out the sample
Section titled “Take out the sample”-
Take out the sample movies, authors and reviews (
sample-dataanddatabase-migrations).This step is mostly deleting, but the template’s own tests use the sample as their test subject, so a few of them change instead of going. Work through it layer by layer and build as you go. The compiler finds what’s left faster than any list.
-
Application: delete
src/Application/Authors/,Movies/andReviews/. InCommon/Enums/EntityType.cs, removeAuthor,MovieandReview, which leavesCinema. -
Infrastructure: delete
Author.cs,Movie.csandReview.csfromModels/, and the matching*Configuration.csfiles. Then remove from:MovieReviewsDbContext.cs: their threeDbSetproperties.MovieReviewsMapper.cs: their aliases and mapping methods.EntityFrameworkMovieReviewsRepository.cs: theAuthors,Movies,ReviewsandHelpersregions, theirusinglines and aliases, and their three interfaces.DependencyInjection.cs: their three registrations andusinglines.MovieReviewsDbContextExtensions.cs: the titles, the review texts and the author, movie and review fakers. Change the guard at the top ofAddDatatocontext.Cinemas.Any().
-
Presentation: delete the author, movie and review files in
Tools/,Resources/andPrompts/, andAuthorResult.cs,MovieResult.cs,ReviewResult.csandDeletedReview.csfromModels/. Then change:-
ResultMapper.cs: keep the cinema mapping and the pagingToResult. -
AppJsonSerializerContext.cs: remove their[JsonSerializable]lines. -
ItemIcons.cs: removeMovie,AuthorandReview. -
CompletionHandler.cs: keep only thecinemaIdcase, and send every request to it. The prompt branch only existed for the sample prompts’ title and name arguments, anddescribe_cinema’scinemaIdcompletes the same way as the resource’s. -
ToolErrorFilter.csandProtocolErrorFilter.cs: the not found hint names the sample tools. Point it atcinemas_searchinstead. -
ResourceLinkFilter.cs:GetNamefalls back to a review’s movie and author. Make the fallback the item’s id:GetText(item, "title") ?? GetText(item, "name") ?? GetText(item, "id")!. -
WebApplicationBuilderExtensions.cs: rewriteServerInstructionsfor what’s left.options.ServerInstructions = """This server holds a list of cinemas.Search first: cinemas_search finds cinemas by name and returns their ids, one page at a time, so passnextOffset back as the offset to continue rather than raising the limit.cinemas_add adds a cinema. Calling it twice adds two, so search before you add.Each cinema can also be read as a resource at cinemas://{id}, the describe_cinema prompt writes ablurb for one, and server://version gives this server's version.""";
Keep at least one prompt. With none, the server stops offering
prompts/listat all, and the icon test fails trying to list them. -
-
Migrations: replace the history with one migration for your schema. With the old snapshot gone, the tool files the new one under a folder named after the namespace, so move it back beside the migration. Then add
// <auto-generated />to the first line of<timestamp>_InitialCreate.cs, as in step 3.Terminal window rm src/Infrastructure/Databases/MovieReviews/Migrations/*.csdotnet ef migrations add InitialCreate \--project ./src/Infrastructure \--output-dir Databases/MovieReviews/Migrations \--namespace WorksOnMyMachine.Movies.Infrastructure.Databases.MovieReviews.Migrationsmv src/Infrastructure/WorksOnMyMachine/Movies/Infrastructure/Databases/MovieReviews/Migrations/MovieReviewsDbContextModelSnapshot.cs \src/Infrastructure/Databases/MovieReviews/Migrations/rm -r src/Infrastructure/WorksOnMyMachinesed -i '1s/^\xEF\xBB\xBF//' src/Infrastructure/Databases/MovieReviews/Migrations/*.csDelete
src/Presentation/movie-reviews.dbtoo, if you’ve run the API. It still holds the old tables, and the new migration history won’t recognise it. -
Tests to delete:
tests/Application.Tests.Unit/: theAuthors/,Movies/andReviews/folders.tests/Presentation.Tests.Unit/Tools/andtests/Presentation.Tests.Integration/Tools/:AuthorToolTests.cs,MovieToolTests.csandReviewToolTests.cs.EntityFrameworkMovieReviewsRepositoryTests.cs: theAuthors,MoviesandReviewsregions.MovieReviewsCollectionData.cs: the author, movie and review rows.
-
Tests to change: these test the template’s plumbing, and they used the sample as their subject. Point them at cinemas.
Common/Behaviours/LoggingBehaviourTests.csandValidationBehaviourTests.cs: UseCreateCinemaCommand,CreateCinemaValidatorandCinemain place ofGetAuthorByIdQuery, its validator andAuthor. The invalid case is an emptyName, so the expected property isName. The logged message namesCreateCinemaCommand.Common/Exceptions/NotFoundExceptionTests.cs: UseEntityType.Cinemaand aCinema. The message becomes “The Cinema with the supplied id was not found.”MovieReviewsConfigurationTests.cs: Check a cinema loads, ignoring case: look up"one"and expect"One".DependencyInjectionTests.cs: ExpectICinemasRepository, 5 seeded cinemas and none when seeding is off. UseGetCinemasfor the concurrency and same-sample-data checks.Completions/CompletionHandlerTests.cs: Use acinemas://{cinemaId}reference, and check a value too long to search returns nothing without sending a query.Errors/ToolErrorFilterTests.csandProtocolErrorFilterTests.cs: Expect the new not found hint.Models/ResultMapperTests.cs: Map a cinema, and keep the paging test, using cinemas.Tools/ToolListTests.csandPrompts/PromptTests.cs: Expect only the cinema tools anddescribe_cinema.Resources/ResourceTests.cs: Expect onlycinemas://{cinemaId}and the version resource.Tools/ResourceLinkTests.csandCompletions/CompletionTests.cs: Use cinemas for every case: links fromcinemas_searchandcinemas_add, no link for a failed call, and completion by name, by id prefix, with an empty value and with no match.Telemetry/TelemetryTests.cs: Callcinemas_searchand expect aGetCinemasQueryspan.
-
-
Check it the way CI will (
coverage).Terminal window dotnet builddotnet format --verify-no-changesdotnet test -m:1 \-p:CollectCoverage=true -p:CoverletOutput=../results/ -p:MergeWith="../results/coverage.json" \-p:CoverletOutputFormat=opencover%2cjson \-p:ExcludeByFile="**/Program.cs%2c**/Migrations/*.cs%2c**/obj/**/*.cs" \-p:ExcludeByAttribute="GeneratedCodeAttribute"The last table it prints is the merged total. Ours came out at 99.8%. If yours is under 95%,
coveragesays what to do about it, and it isn’t “lower the number”.
What’s still called “movie reviews”
Section titled “What’s still called “movie reviews””The database plumbing keeps its sample name: the Databases/MovieReviews folder, MovieReviewsDbContext, EntityFrameworkMovieReviewsRepository, the MovieReviews connection string and the movie-reviews.db file. They all work as they are. Everything in src/Infrastructure apart from DependencyInjection is internal, so renaming them later is a refactor that never reaches Application or Presentation. Do it when the name starts to bother you, and change the connection string in every appsettings.*.json and in docker-compose.yml at the same time.