Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 24, 2025

Per discussion in #931, samples should demonstrate MCP capabilities rather than .NET SDK features. File-based projects are now applied where applicable, and the dedicated FileBasedMcpServer sample is removed since its purpose is fulfilled by converting an existing sample.

Changes

  • QuickstartWeatherServer: Converted to file-based project (single .cs file)

    • Merged WeatherTools.cs and HttpClientExt.cs into Program.cs using file-scoped classes
    • Added shebang and #:package/#:project directives
    • Removed .csproj and Tools/ directory
  • FileBasedMcpServer: Deleted sample directory

  • Other samples: Retained traditional project structure

    • ASP.NET Core samples (AspNetCoreMcpServer, ProtectedMcpServer, etc.) require appsettings.json and multi-file structure
    • Client samples (QuickstartClient, ChatWithTools) use user secrets and complex configurations
    • InMemoryTransport is a simple demo that doesn't benefit from file-based structure

Example

The QuickstartWeatherServer can now be run directly:

# Traditional approach
dotnet run Program.cs

# Or as executable (Unix)
chmod +x Program.cs
./Program.cs

File structure:

#!/usr/bin/env -S dotnet run --
#:package Microsoft.Extensions.Hosting
#:project ../../src/ModelContextProtocol/ModelContextProtocol.csproj

using Microsoft.Extensions.DependencyInjection;
// ... setup code ...

await builder.Build().RunAsync();

[McpServerToolType]
file sealed class WeatherTools { /* ... */ }

file static class HttpClientExt { /* ... */ }

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.weather.gov
    • Triggering command: /home/REDACTED/work/csharp-sdk/csharp-sdk/artifacts/bin/Program/Debug/Program /home/REDACTED/work/csharp-sdk/csharp-sdk/artifacts/bin/Program/Debug/Program (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

This section details on the original issue you should resolve

<issue_title>Use file-based projects in MCP server samples where applicable</issue_title>
<issue_description>My only misgiving is that the point of the samples folder is to demo MCP capabilities and not .NET SDK capabilities. The name of the sample should reflect what the sample is doing and not what build infrastructure it happens to rely on.

If we think file-based projects are a good fit for sample projects (I think that they are) we should just convert them all wholesale rather than doing this.

Thoughts? cc @stephentoub @mikekistler

Originally posted by @eiriktsarpalis in #931 (comment)
</issue_description>

<agent_instructions>Apply file-based project structure in the samples folder where applicable using the changes from #931 as a guide. Then delete the FileBaseMcpServer sample.</agent_instructions>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Apply file-based project structure in MCP server samples Convert QuickstartWeatherServer to file-based project and remove FileBasedMcpServer sample Nov 24, 2025
Copilot AI requested a review from eiriktsarpalis November 24, 2025 09:25
Copilot finished work on behalf of eiriktsarpalis November 24, 2025 09:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Use file-based projects in MCP server samples where applicable

2 participants