Files
FsMcp/FsMcp

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-x64
  • win-arm64
  • osx-arm64
  • linux-x64
  • linux-arm64
  • linux-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.json to declare your MCP server's inputs.
  • 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 USERNAME and PASSWORD environment variables to log in and then sends the X-CSRF-Token header.
  • 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)

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 USERNAME and PASSWORD environment variables to log in and then sends the X-CSRF-Token header.
  • 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)

Notes for consumers:

  • cooperationStatus is a numeric enum. Known values from the OpenAPI schema: 0, 1, 2, 4, 5, 6, 7.
  • categoryType is a numeric enum. Known values from the OpenAPI schema: 0, 1, 2.
  • createdAt is delivered as a date string in YYYY-MM-DD format.
  • 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 USERNAME and PASSWORD environment variables to log in and then sends the X-CSRF-Token header.
  • 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)

Notes for consumers:

  • role maps to OpenAPI enum Role with values 0, 1, 2, 3, 4, 5.
  • membershipStatus is a numeric API status code.
  • Timestamp fields are parsed as ISO-8601 (memberSince, hygieneCertificateUntil, lastFetch) and may be null for some users.
  • distanceInKm is numeric distance in kilometers and may be null when 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 format yyyy-MM-ddTHH:mm:ss.fffZ)
    • toDate (required, DateTimeOffset; serialized to UTC path format yyyy-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 USERNAME and PASSWORD environment variables to log in and then sends the X-CSRF-Token header.
  • Output: Array of typed store log entries including:
    • timing fields (performedAt, dateReference)
    • type field (actionType)
    • actor/target profiles (actor, target with id, name, avatar, isSleeping)
    • optional text fields (content, reason)

Notes for consumers:

  • The backend may reject requests beyond the allowed history window (OpenAPI documents 400 for more than 6 months back).
  • fromDate must be less than or equal to toDate.
  • actionType values currently observed/mapped:
    • 1 membership requests made / Beitrittsanfragen stellen
    • 2 membership requests rejected / Beitrittsanfragen ablehnen
    • 3 membership requests accepted / Beitrittsanfragen annehmen
    • 4 members added manually / Foodsaver:innen ohne Anfrage ins Team aufnehmen
    • 5 team members made standby / Foodsaver:innen auf die Springerliste setzen
    • 6 team members moved to active team / Foodsaver:innen ins aktive Team aufnehmen
    • 7 team members removed from team / Foodsaver:innen aus dem Team entfernen
    • 8 team members left team / Team verlassen
    • 9 store coordinators appointed / Betriebsverantwortliche eintragen
    • 10 store coordinators removed / Betriebsverantwortliche austragen
    • 11 signed up for a slot / Eintragen für Slot
    • 12 signed out from a slot / Austragen für Slot
    • 13 removed from a slot / Für Slot ausgetragen werden
    • 14 confirmed a slot / Slot bestätigen
    • 15 wall posts deleted / Pinnwandeintrag löschen
    • 16 team applications withdrawn / Beitrittsanfrage zurückziehen
    • 17 invitations to the team / Foodsaver:innen ins Team einladen
    • 18 withdrawn team invitations / Team-Einladungen zurückziehen
    • 19 accepted team invitations / Team-Einladungen annehmen
    • 20 declined 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

  1. Run dotnet pack -c Release to create the NuGet package
  2. 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.json file
  • Visual Studio: Create a <SOLUTION DIRECTORY>\.mcp.json file

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: