MCP Server
This README was created using the C# MCP server project template. It demonstrates how you can easily create an MCP server using C# and publish it as a NuGet package.
The MCP server is built as a self-contained application and does not require the .NET runtime to be installed on the target machine. However, since it is self-contained, it must be built for each target platform separately. By default, the template is configured to build for:
win-x64win-arm64osx-arm64linux-x64linux-arm64linux-musl-x64
If your users require more platforms to be supported, update the list of runtime identifiers in the project's <RuntimeIdentifiers /> element.
See aka.ms/nuget/mcp/guide for the full guide.
Please note that this template is currently in an early preview stage. If you have feedback, please take a brief survey.
Checklist before publishing to NuGet.org
- Test the MCP server locally using the steps below.
- Update the package metadata in the .csproj file, in particular the
<PackageId>. - Update
.mcp/server.jsonto declare your MCP server's inputs.- See configuring inputs for more details.
- Pack the project using
dotnet pack.
The bin/Release directory will contain the package file (.nupkg), which can be published to NuGet.org.
Developing locally
To test this MCP server from source code (locally) without using a built MCP server package, you can configure your IDE to run the project directly using dotnet run.
{
"servers": {
"FsMcp": {
"type": "stdio",
"command": "dotnet",
"args": [
"run",
"--project",
"<PATH TO PROJECT DIRECTORY>"
]
}
}
}
Refer to the VS Code or Visual Studio documentation for more information on configuring and using MCP servers:
Testing the MCP Server
Once configured, you can ask Copilot Chat for a random number, for example, Give me 3 random numbers. It should prompt you to use the get_random_number tool on the FsMcp MCP server and show you the results.
Current user profile tool
This server also exposes get_current_user_details.
- Purpose: Returns full details for the currently authenticated user from
GET /api/users/current/details. - Auth: Uses
USERNAMEandPASSWORDenvironment variables to log in and then sends theX-CSRF-Tokenheader. - Output: Structured profile object including:
- identity and account status (
id,foodsaver,isVerified,role,isSleeping) - primary region data (
regionId,regionName) and all memberships (regions,groups) - profile/contact fields (
firstname,lastname,email,address,postcode,city,landline,mobile,birthday,photo) - activity/pass data (
stats.weight,stats.count,lastPassDate,lastPassUntilValid,lastPassUntilValidInDays) - permission flags (
permissions.*) - coordinates (
coordinates.lat,coordinates.lon)
- identity and account status (
The tool is strongly typed in Tools/CurrentUserTools.cs, where each field is documented with Description attributes so MCP clients can surface schema-aware help.
Region stores tool
This server also exposes get_region_stores.
- Purpose: Returns all stores for a region from
GET /api/regions/{regionId}/stores. - Input:
regionId(required, positive integer; OpenAPI path pattern:[1-9][0-9]*)
- Auth: Uses
USERNAMEandPASSWORDenvironment variables to log in and then sends theX-CSRF-Tokenheader. - Output: Array of typed store list entries including:
- identity (
id,name) - region info (
region.id,region.name) - geolocation (
location.lat,location.lon) - address fields (
street,city,zipCode) - operational fields (
cooperationStatus,categoryType,createdAt)
- identity (
Notes for consumers:
cooperationStatusis a numeric enum. Known values from the OpenAPI schema:0, 1, 2, 4, 5, 6, 7.categoryTypeis a numeric enum. Known values from the OpenAPI schema:0, 1, 2.createdAtis delivered as a date string inYYYY-MM-DDformat.- Some raw API values may contain trailing spaces or empty strings in address fields; this tool returns the original API data unchanged.
The tool is strongly typed in Tools/RegionStoresTools.cs, with per-field Description attributes so MCP clients can surface schema-aware guidance directly in tool UIs.
Store members tool
This server also exposes get_store_members.
- Purpose: Returns all members of a store team from
GET /api/stores/{storeId}/members. - Input:
storeId(required, positive integer; OpenAPI path pattern:[1-9][0-9]*)
- Auth: Uses
USERNAMEandPASSWORDenvironment variables to log in and then sends theX-CSRF-Tokenheader. - Output: Array of typed member entries including:
- identity/profile fields (
id,name,avatar,firstName,isVerified,isSleeping) - team/role fields (
role,membershipStatus,isResponsible,memberSince) - activity/certificate fields (
fetchCount,hygieneCertificateUntil) - live-response compatibility fields (
handy,telefon,lastFetch,distanceInKm)
- identity/profile fields (
Notes for consumers:
rolemaps to OpenAPI enumRolewith values0, 1, 2, 3, 4, 5.membershipStatusis a numeric API status code.- Timestamp fields are parsed as ISO-8601 (
memberSince,hygieneCertificateUntil,lastFetch) and may benullfor some users. distanceInKmis numeric distance in kilometers and may benullwhen unavailable.- Some fields present in live responses (for example
handy,telefon,lastFetch,distanceInKm) are included to preserve practical API payload shape for consumers.
The tool is strongly typed in Tools/StoreMembersTools.cs, with per-field Description attributes so MCP clients can surface schema-aware guidance directly in tool UIs.
Store log entries tool
This server also exposes get_store_log_entries.
- Purpose: Returns store log entries from
GET /api/stores/{storeId}/log/{fromDate}/{toDate}/actions/{storeLogActionIds}for auditing team and slot activity. - Input:
storeId(required, positive integer; OpenAPI path pattern:[1-9][0-9]*)fromDate(required,DateTimeOffset; serialized to UTC path formatyyyy-MM-ddTHH:mm:ss.fffZ)toDate(required,DateTimeOffset; serialized to UTC path formatyyyy-MM-ddTHH:mm:ss.fffZ)storeLogActionIds(required, non-empty list of positive integers; serialized as comma-separated path segment matching\d+(,\d+)*)limit(optional, query parameter, must be> 0)offset(optional, query parameter, must be>= 0)
- Auth: Uses
USERNAMEandPASSWORDenvironment variables to log in and then sends theX-CSRF-Tokenheader. - Output: Array of typed store log entries including:
- timing fields (
performedAt,dateReference) - type field (
actionType) - actor/target profiles (
actor,targetwithid,name,avatar,isSleeping) - optional text fields (
content,reason)
- timing fields (
Notes for consumers:
- The backend may reject requests beyond the allowed history window (OpenAPI documents
400for more than 6 months back). fromDatemust be less than or equal totoDate.actionTypevalues currently observed/mapped:1membership requests made /Beitrittsanfragen stellen2membership requests rejected /Beitrittsanfragen ablehnen3membership requests accepted /Beitrittsanfragen annehmen4members added manually /Foodsaver:innen ohne Anfrage ins Team aufnehmen5team members made standby /Foodsaver:innen auf die Springerliste setzen6team members moved to active team /Foodsaver:innen ins aktive Team aufnehmen7team members removed from team /Foodsaver:innen aus dem Team entfernen8team members left team /Team verlassen9store coordinators appointed /Betriebsverantwortliche eintragen10store coordinators removed /Betriebsverantwortliche austragen11signed up for a slot /Eintragen für Slot12signed out from a slot /Austragen für Slot13removed from a slot /Für Slot ausgetragen werden14confirmed a slot /Slot bestätigen15wall posts deleted /Pinnwandeintrag löschen16team applications withdrawn /Beitrittsanfrage zurückziehen17invitations to the team /Foodsaver:innen ins Team einladen18withdrawn team invitations /Team-Einladungen zurückziehen19accepted team invitations /Team-Einladungen annehmen20declined team invitations /Team-Einladungen ablehnen
The tool is strongly typed in Tools/StoreLogTools.cs, with per-field Description attributes so MCP clients can surface schema-aware guidance directly in tool UIs.
Publishing to NuGet.org
- Run
dotnet pack -c Releaseto create the NuGet package - Publish to NuGet.org with
dotnet nuget push bin/Release/*.nupkg --api-key <your-api-key> --source https://api.nuget.org/v3/index.json
Using the MCP Server from NuGet.org
Once the MCP server package is published to NuGet.org, you can configure it in your preferred IDE. Both VS Code and Visual Studio use the dnx command to download and install the MCP server package from NuGet.org.
- VS Code: Create a
<WORKSPACE DIRECTORY>/.vscode/mcp.jsonfile - Visual Studio: Create a
<SOLUTION DIRECTORY>\.mcp.jsonfile
For both VS Code and Visual Studio, the configuration file uses the following server definition:
{
"servers": {
"FsMcp": {
"type": "stdio",
"command": "dnx",
"args": [
"<your package ID here>",
"--version",
"<your package version here>",
"--yes"
]
}
}
}
More information
.NET MCP servers use the ModelContextProtocol C# SDK. For more information about MCP: