microsoft/foundry-local-on-windowsserver-samples
C#
Captured source
source ↗microsoft/foundry-local-on-windowsserver-samples
Description: Foundry local on Windows Server samples
Language: C#
License: NOASSERTION
Stars: 11
Forks: 2
Open issues: 1
Created: 2025-10-22T18:24:23Z
Pushed: 2026-06-20T04:23:01Z
Default branch: main
Fork: no
Archived: no
README:
Foundry Local for Windows Server
Table of Contents
- [Overview](#overview)
- [Samples](#samples)
- [ContosoMedical](#contoso-medical)
- [MCP Tool Calling](#mcp-tool-calling)
- [Setup](#setup)
- [Installing Foundry Local on Windows Server 2025](#installing-foundry-local-on-windows-server-2025)
- [Accessing the Foundry Local Service Over the Network](#accessing-the-foundry-local-service-over-the-network)
- [How to Use ContosoMedical App](#how-to-use-contosomedical-app)
- [Architecture](#architecture)
- [System Overview](#system-overview)
- [Main Components](#main-components)
- [Foundry Local Integration](#foundry-local-integration)
- [Connection Configuration](#connection-configuration)
- [HTTP Client Integration](#http-client-integration)
- [OpenAI-Compatible API Usage](#openai-compatible-api-usage)
- [Configuration](#configuration)
- [App.config Settings](#appconfig-settings)
- [Endpoint Configuration](#endpoint-configuration)
- [Language Model Configuration](#language-model-configuration)
- [Local Data Directory](#local-data-directory)
- [Data Generation](#data-generation)
- [Generating Synthetic Patient Data with Synthea](#generating-synthetic-patient-data-with-synthea)
- [Data Pre-processing](#data-pre-processing)
- [Model Selection](#model-selection)
- [Summarization for Long Text Inputs](#summarization-for-long-text-inputs)
- [Translation for Long Text Inputs](#translation-for-long-text-inputs)
- [Limitations](#limitations)
- [Future Work](#future-work)
- [Trademarks](#trademarks)
Overview
The following samples demonstrate how Windows Server can be used to run AI workloads on-premises with Foundry Local, ensuring data privacy and compliance with the strict requirements of regulated industries.
Samples
Contoso Medical
The ContosoMedical application highlights two AI-driven scenarios:
- Medical Record Summarization: Automatically condenses lengthy patient reports into concise medical summaries.
- Medical Record Translation: Translates medical documents from foreign languages into English while preserving medical terminology and formatting.
> Important: The Foundry Local endpoint must be configured by yourself. The provided endpoints in this sample are internal Microsoft endpoints that can only be accessed via VPN and CorpNet. Please see the [Endpoint Configuration](#endpoint-configuration) section for details on how to configure your own endpoints.
MCP Tool Calling
The [MCP-ToolCalling](MCP-ToolCalling/README.md) sample demonstrates how to integrate MCP (Model Context Protocol) servers with Foundry Local and Semantic Kernel using tool calling. A custom Weather MCP server exposes real-time weather data via the National Weather Service API, and a .NET agent uses Semantic Kernel to connect a locally-running Foundry Local model to those tools.
Key components:
- Weather MCP Server (Node.js/TypeScript): Exposes two tools over MCP Streamable HTTP transport —
get_alerts(active weather alerts for a US state) andget_forecast(multi-day forecast for any lat/lon coordinates). - Foundry Local MCP Agent (.NET 9): Starts an embedded Foundry Local instance with the
qwen2.5-7bmodel, connects to the MCP server via a customMcpHttpClient, registers the tools as a Semantic Kernel plugin, and runs an interactive chat loop with automatic tool invocation.
foundry-local-mcp-agent (.NET) ├── Foundry Local (qwen2.5-7b, port 9001) └── Semantic Kernel + WeatherMcpPlugin │ MCP over HTTP Weather MCP Server (Node.js, port 3000) │ National Weather Service API
Prerequisites: Node.js v18+, .NET 9 SDK.
See [MCP-ToolCalling/README.md](MCP-ToolCalling/README.md) for full setup and usage instructions.
Setup
Installing Foundry Local on Windows Server 2025
1. Download Foundry Local
winget install Microsoft.FoundryLocal
2. Start the Foundry Local service
foundry service start
3. Download a Language Model
For example, to download phi-4-mini:
foundry model download phi-4-mini
For additional details on Foundry Local, see Foundry Local documentation.
Accessing the Foundry Local service over the network
By default, Foundry Local listens on 127.0.0.1:, which restricts inference requests to the local machine.
To enable access from other devices on the network (or connected via VPN), use Windows PortProxy to forward external traffic on port 9000 to the Foundry Local service port.
1. Create a port proxy
netsh interface portproxy add v4tov4 listenport=9000 listenaddress=0.0.0.0 connectport= connectaddress=127.0.0.1
2. Allow inbound TCP traffic
netsh advfirewall firewall add rule name="Allow Port 9000 Inbound" dir=in action=allow protocol=TCP localport=9000
3. Verify connectivity
From any host on the same network, confirm that the Foundry Local service is reachable:
curl http://:9000/openai/status
How to use ContosoMedical app
Prerequisites
- .NET Framework 4.8 or later
- Visual Studio 2019 or later
Run the application
Open the solution in Visual Studio and build the project. Run the application by pressing the F5 key or by clicking on the Start button in the toolbar.
Architecture
System Overview
The sample application uses a client–server architecture, where the WPF desktop client processes medical records by leveraging Language Model capabilities hosted on Windows Server instances configured as described above.
┌──────────────────────────────────────────┐ │ ContosoMedical │ │ ┌─────────────────────────────────────┐ │ │ │ WPF Frontend │ │ │ │ ┌─────────────────────────────┐ │ │ │ │ │ Patient Records Interface │ │ │ │ │ │ │ │ │ │ │ └─────────────────────────────┘ │ │ │ └─────────────────────────────────────┘ │ │ ┌─────────────────────────────────────┐ │ │ │ Services │ │ │ │ ┌─────────────┐ ┌─────────────┐ │ │ │ │ │ Summarizer │ │ Translator │ │ │ │ │ │ (Map-Reduce)│ │ (Chunking) │ │ │ │ │ └─────────────┘ └─────────────┘ │ │ │ └─────────────────────────────────────┘ │ └──────────────────────────────────────────┘ │ HTTP/REST │...
Excerpt shown — open the source for the full document.
Notability
notability 1.0/10Sample repo with very low traction.