agentleFS
MicrosoftKnown publishermicrosoft/mcp-dotnet-samples/.github/copilot-instructions.md

mcp-dotnet-samples

Copilot instructions198 starsChanged 15 months agoMITView on GitHub

Purpose: Make agents instantly productive. Follow ONLY patterns proven in this repo; don’t invent abstractions.

  • In this repositoryOne other file it gives its agents.

The file

We split this copilot-instructions.md into the rules it gives an agent

7 rules. About 0 are common, 2 are distinctive, and 5 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈2

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 5

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Very specific:

    Always preserve argument delimiter: dotnet run … -- --http <other-switches>.

    line 20
  2. Distinctive:

    Keep Dockerfiles minimal; expose port 8080 internally.

    line 22
  3. Very specific:

    Create public class or method with [McpServerTool] (and [Description] for method + parameters).

    line 25
  4. Very specific:

    When touching awesome-copilot metadata handling, avoid O(n) reload loops—stream or cache.

    line 31
  5. Very specific:

    Run HTTP: append -- --http (plus sample switches after that).

    line 42
  6. Very specific:

    Add Dockerfile.<name> + .vscode/mcp.*.json variants.

    line 49
  7. Distinctive:

    Update root README table with install badges.

    line 50

≈ “Common” is an estimate: at least 1 in 5 of the 1,644 Copilot instructions files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
copilot-instructions.md

Copilot Instructions (Concise) – MCP .NET Samples

Purpose: Make agents instantly productive. Follow ONLY patterns proven in this repo; don’t invent abstractions.

Architecture & Runtime

  • Mono-repo of independent Hybrid MCP servers: awesome-copilot/, markdown-to-html/, todo-list/, outlook-email/ + shared lib shared/McpSamples.Shared/.
  • Hybrid pattern: same Program.cs can run STDIO (default) or stateless HTTP when -- http (or env UseHttp=true). Selection via AppSettings.UseStreamableHttp(...); final wiring through BuildApp(useStreamableHttp).
  • Discovery: Tools / Prompts / Resources auto-registered by assembly scan (With*FromAssembly). New public attributed types in the entry assembly just work—avoid manual registration.
  • HTTP mode: single POST /mcp; some samples add dual OpenAPI docs (swagger 2.0 + openapi 3.0) via McpDocumentTransformer<T>.

Sample-Specific Nuance

  • awesome-copilot: Large metadata.json; reuse IMetadataService (don’t repeatedly load whole file). Tools: search & load instructions.
  • markdown-to-html: Extra switches -tc, -p, --tags only parsed AFTER -- delimiter.
  • todo-list: In‑memory SQLite kept alive by one singleton SqliteConnection; use EF Core set-based ops (ExecuteUpdateAsync/ExecuteDeleteAsync).
  • outlook-email: Supports auth parameters (--tenant-id/-t, --client-id/-c, --client-secret/-s) or user secrets; can also host via Azure Functions (see sample README). Only add auth handling inside this sample—do not leak to shared.

Core Conventions

  • Target: .NET 9; nullable + implicit usings enabled globally.
  • Entry project path pattern: ./<sample>/src/<PascalName>.HybridApp/.
  • Always preserve argument delimiter: dotnet run … -- --http <other-switches>.
  • JSON camelCase & case-insensitive (match existing config); prefer System.Text.Json.
  • Keep Dockerfiles minimal; expose port 8080 internally; local HTTP dev ports: ac=5250, todo=5240, html=5280, outlook=5260.

Adding / Modifying Tools

  • Create public class or method with [McpServerTool] (and [Description] for method + parameters). Return lightweight DTO / primitives; let host format.
  • For prompts use [McpServerPrompt]. No manual DI registration unless you need extra services—then add via builder.Services before BuildApp.

Safe Editing Rules

  • Don’t change signatures of shared extension methods (AddAppSettings<T>, BuildApp) unless updating EVERY sample in one PR.
  • Don’t introduce persistence in other samples without isolating it; never move sample-only concerns into shared casually.
  • When touching awesome-copilot metadata handling, avoid O(n) reload loops—stream or cache.

Frequent Pitfalls (avoid silently breaking)

  • Missing -- causes custom flags ignored.
  • Forgetting singleton SQLite => empty todo DB each request.
  • Adding OpenAPI without mapping json endpoints or AddHttpContextAccessor() => docs missing.
  • Wrong mcp.*.json copied (name/port mismatch) => VS Code cannot start server.
  • Re-loading metadata.json repeatedly => performance hit.

Minimal Workflows

  • Run STDIO: dotnet run --project ./markdown-to-html/src/McpSamples.MarkdownToHtml.HybridApp
  • Run HTTP: append -- --http (plus sample switches after that).
  • Container: docker build -f Dockerfile.todo-list -t todo-list:latest . then docker run -i --rm -p 8080:8080 todo-list:latest [--http].
  • Deploy (per sample): azd auth login then azd up inside sample folder, then read FQDN via azd env get-value AZURE_RESOURCE_<...>_FQDN.

Adding a New Sample (Checklist)

  1. Copy structure from an existing sample; reference McpSamples.Shared.
  2. Implement Program.cs with same pattern (parse settings -> add services -> BuildApp).
  3. Add Dockerfile.<name> + .vscode/mcp.*.json variants; expose 8080.
  4. Update root README table with install badges.

PR Expectations (Essentials)

  • Build passes (.NET 9). Tools/prompts discoverable. No hardcoded secrets. Sample-specific behavior isolated. Conventional commits.

Questions / unclear? Compare with the most similar existing sample before inventing new structure.

Feedback welcome: open a docs PR if a recurring pattern isn’t captured here.

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.