nanoFramework.WebServer
1.2.125
Prefix Reserved
dotnet add package nanoFramework.WebServer --version 1.2.125
NuGet\Install-Package nanoFramework.WebServer -Version 1.2.125
<PackageReference Include="nanoFramework.WebServer" Version="1.2.125" />
<PackageVersion Include="nanoFramework.WebServer" Version="1.2.125" />
<PackageReference Include="nanoFramework.WebServer" />
paket add nanoFramework.WebServer --version 1.2.125
#r "nuget: nanoFramework.WebServer, 1.2.125"
#addin nuget:?package=nanoFramework.WebServer&version=1.2.125
#tool nuget:?package=nanoFramework.WebServer&version=1.2.125
.NET nanoFramework WebServer with Model Context Protocol (MCP)
Build status
Component | Build Status | NuGet Package |
---|---|---|
nanoFramework.WebServer | ||
nanoFramework.WebServer.FileSystem | ||
nanoFramework.WebServer.Mcp |
Overview
This library provides a lightweight, multi-threaded HTTP/HTTPS WebServer for .NET nanoFramework with comprehensive Model Context Protocol (MCP) support for AI agent integration.
Key Features
- Multi-threaded request handling
- Static file serving with FileSystem support
- RESTful API support with parameter handling
- Route-based controllers with attribute decoration
- Authentication support (Basic, API Key)
- HTTPS/SSL support with certificates
- Model Context Protocol (MCP) for AI agent integration
- Automatic tool discovery and JSON-RPC 2.0 compliance
Quick Start
Basic Event Based WebServer
Using the Web Server is very straight forward and supports event based calls.
// You need to be connected to a wifi or ethernet connection with a proper IP Address
using (WebServer server = new WebServer(80, HttpProtocol.Http))
{
server.CommandReceived += ServerCommandReceived;
server.Start();
Thread.Sleep(Timeout.Infinite);
}
private static void ServerCommandReceived(object source, WebServerEventArgs e)
{
if (e.Context.Request.RawUrl.ToLower() == "/hello")
{
WebServer.OutPutStream(e.Context.Response, "Hello from nanoFramework!");
}
else
{
WebServer.OutputHttpCode(e.Context.Response, HttpStatusCode.NotFound);
}
}
Controller-Based WebServer
Controllers are supported including with parametarized routes like api/led/{id}/dosomething/{order}
.
using (WebServer server = new WebServer(80, HttpProtocol.Http, new Type[] { typeof(MyController) }))
{
server.Start();
Thread.Sleep(Timeout.Infinite);
}
public class MyController
{
[Route("api/hello")]
[Method("GET")]
public void Hello(WebServerEventArgs e)
{
WebServer.OutPutStream(e.Context.Response, "Hello from Controller!");
}
[Route("api/led/{id}")]
[Method("GET")]
public void LedState(WebServerEventArgs e)
{
string ledId = e.GetRouteParameter("id");
WebServer.OutPutStream(e.Context.Response, $"You selected Led {ledId}!");
}
}
Model Context Protocol (MCP) Support
Enable AI agents to interact with your embedded devices through standardized tools and JSON-RPC 2.0 protocol.
Defining MCP Tools
public class IoTTools
{
[McpServerTool("read_sensor", "Reads temperature from sensor")]
public static string ReadTemperature()
{
// Your sensor reading code
return "23.5°C";
}
[McpServerTool("control_led", "Controls device LED", "Uutput the statusof the LED")]
public static string ControlLed(LedCommand command)
{
// Your LED control code
return $"LED set to {command.State}";
}
}
public class LedCommand
{
[Description("LED state: on, off, or blink")]
public string State { get; set; }
}
Setting Up MCP Server
public static void Main()
{
// Connect to WiFi first
var connected = WifiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true);
// Discover and register MCP tools
McpToolRegistry.DiscoverTools(new Type[] { typeof(IoTTools) });
// Start WebServer with MCP support
using (var server = new WebServer(80, HttpProtocol.Http, new Type[] { typeof(McpServerController) }))
{
// Optional customization
McpServerController.ServerName = "MyIoTDevice";
McpServerController.Instructions = "IoT device with sensor and LED control capabilities.";
server.Start();
Thread.Sleep(Timeout.Infinite);
}
}
AI Agent Integration
Once running, AI agents can discover and invoke your tools:
// Tool discovery
POST /mcp
{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 1
}
// Tool invocation
POST /mcp
{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "control_led",
"arguments": {"State": "on"}
},
"id": 2
}
Documentation
Topic | Description |
---|---|
Controllers and Routing | Learn about route attributes, method decorations, and URL parameters |
Authentication | Configure Basic Auth, API Key, and custom authentication |
HTTPS and Certificates | Set up SSL/TLS encryption with certificates |
File System Support | Serve static files from storage devices |
Model Context Protocol (MCP) | Complete MCP guide for AI agent integration |
REST API Development | Build RESTful APIs with request/response handling |
Event-Driven Programming | Handle requests through events and status monitoring |
Examples and Samples | Working examples and code samples |
Limitations
- No compression support in request/response streams
- MCP implementation supports server features only (no notifications or SSE)
- No or single parameter limitation for MCP tools (use complex objects for multiple parameters)
Installation
Install nanoFramework.WebServer
for the Web Server without File System support. Install nanoFramework.WebServer.FileSystem
for file serving, so with devices supporting File System.
Install nanoFramework.WebServer.Mcp
for MCP support. It does contains the full nanoFramework.WebServer
but does not include native file serving. You can add this feature fairly easilly by reusing the code function serving it.
Contributing
For documentation, feedback, issues and contributions, please refer to the Home repo.
Join our Discord community here.
Credits
The list of contributors to this project can be found at CONTRIBUTORS.
License
Licensed under the MIT license.
Code of Conduct
This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behaviour in our community. For more information see the .NET Foundation Code of Conduct.
.NET Foundation
This project is supported by the .NET Foundation.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET Framework | net is compatible. |
-
- nanoFramework.CoreLibrary (>= 1.17.11)
- nanoFramework.System.Net.Http.Server (>= 1.5.196)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on nanoFramework.WebServer:
Repository | Stars |
---|---|
nanoframework/Samples
🍬 Code samples from the nanoFramework team used in testing, proof of concepts and other explorational endeavours
|
|
nanoframework/nanoFramework.IoT.Device
📦 This repo includes .NET nanoFramework implementations for various sensors, chips, displays, hats and drivers
|
Version | Downloads | Last Updated |
---|---|---|
1.2.125 | 30 | 7/7/2025 |
1.2.124 | 26 | 7/7/2025 |
1.2.123 | 129 | 6/27/2025 |
1.2.122 | 216 | 6/2/2025 |
1.2.121 | 278 | 4/25/2025 |
1.2.118 | 305 | 4/2/2025 |
1.2.117 | 170 | 4/2/2025 |
1.2.116 | 506 | 3/26/2025 |
1.2.115 | 474 | 3/26/2025 |
1.2.114 | 485 | 3/26/2025 |
1.2.112 | 215 | 3/12/2025 |
1.2.111 | 205 | 3/10/2025 |
1.2.110 | 171 | 3/10/2025 |
1.2.109 | 187 | 3/10/2025 |
1.2.108 | 193 | 3/10/2025 |
1.2.107 | 250 | 3/7/2025 |
1.2.106 | 164 | 3/3/2025 |
1.2.105 | 233 | 2/27/2025 |
1.2.104 | 110 | 2/27/2025 |
1.2.101 | 156 | 2/25/2025 |
1.2.97 | 131 | 2/25/2025 |
1.2.95 | 113 | 2/25/2025 |
1.2.93 | 303 | 2/5/2025 |
1.2.92 | 131 | 2/5/2025 |
1.2.89 | 158 | 2/4/2025 |
1.2.88 | 137 | 2/4/2025 |
1.2.87 | 150 | 1/31/2025 |
1.2.86 | 137 | 1/30/2025 |
1.2.85 | 117 | 1/30/2025 |
1.2.84 | 115 | 1/30/2025 |
1.2.83 | 103 | 1/30/2025 |
1.2.77 | 132 | 1/29/2025 |
1.2.74 | 252 | 1/10/2025 |
1.2.73 | 141 | 1/6/2025 |
1.2.72 | 152 | 1/2/2025 |
1.2.70 | 278 | 12/11/2024 |
1.2.69 | 107 | 12/11/2024 |
1.2.63 | 529 | 10/8/2024 |
1.2.60 | 209 | 9/26/2024 |
1.2.56 | 262 | 7/30/2024 |
1.2.55 | 186 | 7/24/2024 |
1.2.52 | 301 | 6/3/2024 |
1.2.48 | 198 | 5/17/2024 |
1.2.45 | 136 | 5/13/2024 |
1.2.43 | 214 | 5/10/2024 |
1.2.40 | 264 | 4/12/2024 |
1.2.38 | 153 | 4/9/2024 |
1.2.36 | 142 | 4/8/2024 |
1.2.34 | 158 | 4/5/2024 |
1.2.32 | 146 | 4/3/2024 |
1.2.30 | 144 | 4/3/2024 |
1.2.27 | 371 | 2/14/2024 |
1.2.25 | 153 | 2/12/2024 |
1.2.23 | 245 | 1/26/2024 |
1.2.21 | 129 | 1/26/2024 |
1.2.19 | 133 | 1/26/2024 |
1.2.17 | 176 | 1/24/2024 |
1.2.14 | 467 | 11/17/2023 |
1.2.12 | 178 | 11/10/2023 |
1.2.9 | 165 | 11/9/2023 |
1.2.7 | 197 | 11/8/2023 |
1.2.6 | 149 | 11/8/2023 |
1.2.3 | 281 | 10/27/2023 |
1.2.1 | 195 | 10/25/2023 |
1.1.79 | 237 | 10/10/2023 |
1.1.77 | 228 | 10/4/2023 |
1.1.75 | 454 | 8/8/2023 |
1.1.73 | 295 | 7/27/2023 |
1.1.71 | 180 | 7/27/2023 |
1.1.65 | 723 | 2/17/2023 |
1.1.63 | 430 | 1/24/2023 |
1.1.61 | 327 | 1/24/2023 |
1.1.59 | 366 | 1/24/2023 |
1.1.56 | 455 | 12/30/2022 |
1.1.54 | 364 | 12/28/2022 |
1.1.51 | 385 | 12/27/2022 |
1.1.47 | 760 | 10/26/2022 |
1.1.44 | 436 | 10/25/2022 |
1.1.41 | 431 | 10/24/2022 |
1.1.39 | 470 | 10/23/2022 |
1.1.36 | 477 | 10/10/2022 |
1.1.32 | 464 | 10/8/2022 |
1.1.29 | 513 | 9/22/2022 |
1.1.27 | 491 | 9/22/2022 |
1.1.25 | 494 | 9/22/2022 |
1.1.23 | 552 | 9/16/2022 |
1.1.21 | 532 | 9/15/2022 |
1.1.19 | 565 | 8/29/2022 |
1.1.17 | 592 | 8/6/2022 |
1.1.14 | 495 | 8/4/2022 |
1.1.12 | 462 | 8/3/2022 |
1.1.10 | 500 | 8/3/2022 |
1.1.8 | 467 | 8/3/2022 |
1.1.6 | 663 | 6/13/2022 |
1.1.4 | 536 | 6/8/2022 |
1.1.2 | 491 | 6/8/2022 |
1.1.1 | 527 | 5/30/2022 |
1.0.0 | 764 | 3/30/2022 |
1.0.0-preview.260 | 202 | 3/29/2022 |
1.0.0-preview.258 | 181 | 3/28/2022 |
1.0.0-preview.256 | 185 | 3/28/2022 |
1.0.0-preview.254 | 195 | 3/28/2022 |
1.0.0-preview.252 | 184 | 3/28/2022 |
1.0.0-preview.250 | 181 | 3/28/2022 |
1.0.0-preview.248 | 204 | 3/17/2022 |
1.0.0-preview.246 | 199 | 3/14/2022 |
1.0.0-preview.244 | 190 | 3/14/2022 |
1.0.0-preview.242 | 184 | 3/14/2022 |
1.0.0-preview.240 | 190 | 3/14/2022 |
1.0.0-preview.238 | 187 | 3/8/2022 |
1.0.0-preview.236 | 191 | 3/8/2022 |
1.0.0-preview.234 | 181 | 3/4/2022 |
1.0.0-preview.232 | 183 | 3/3/2022 |
1.0.0-preview.230 | 194 | 3/2/2022 |
1.0.0-preview.228 | 186 | 2/28/2022 |
1.0.0-preview.226 | 225 | 2/24/2022 |
1.0.0-preview.222 | 197 | 2/17/2022 |
1.0.0-preview.220 | 193 | 2/17/2022 |
1.0.0-preview.218 | 233 | 2/6/2022 |
1.0.0-preview.216 | 191 | 2/4/2022 |
1.0.0-preview.214 | 207 | 2/4/2022 |
1.0.0-preview.212 | 215 | 1/28/2022 |
1.0.0-preview.210 | 208 | 1/28/2022 |
1.0.0-preview.208 | 213 | 1/28/2022 |
1.0.0-preview.206 | 197 | 1/25/2022 |
1.0.0-preview.204 | 197 | 1/21/2022 |
1.0.0-preview.202 | 189 | 1/21/2022 |
1.0.0-preview.200 | 199 | 1/21/2022 |
1.0.0-preview.198 | 195 | 1/21/2022 |
1.0.0-preview.196 | 197 | 1/21/2022 |
1.0.0-preview.194 | 213 | 1/13/2022 |
1.0.0-preview.192 | 217 | 1/12/2022 |
1.0.0-preview.190 | 204 | 1/12/2022 |
1.0.0-preview.188 | 197 | 1/11/2022 |
1.0.0-preview.186 | 209 | 1/11/2022 |
1.0.0-preview.183 | 211 | 1/6/2022 |
1.0.0-preview.181 | 210 | 1/5/2022 |
1.0.0-preview.180 | 207 | 1/3/2022 |
1.0.0-preview.179 | 200 | 1/3/2022 |
1.0.0-preview.178 | 204 | 1/3/2022 |
1.0.0-preview.177 | 201 | 12/30/2021 |
1.0.0-preview.176 | 219 | 12/28/2021 |
1.0.0-preview.174 | 250 | 12/3/2021 |
1.0.0-preview.172 | 220 | 12/3/2021 |
1.0.0-preview.170 | 206 | 12/3/2021 |
1.0.0-preview.168 | 214 | 12/3/2021 |
1.0.0-preview.166 | 215 | 12/3/2021 |
1.0.0-preview.164 | 216 | 12/2/2021 |
1.0.0-preview.162 | 221 | 12/2/2021 |
1.0.0-preview.160 | 206 | 12/2/2021 |
1.0.0-preview.158 | 205 | 12/2/2021 |
1.0.0-preview.156 | 216 | 12/2/2021 |
1.0.0-preview.154 | 203 | 12/2/2021 |
1.0.0-preview.152 | 220 | 12/1/2021 |
1.0.0-preview.150 | 199 | 12/1/2021 |
1.0.0-preview.148 | 216 | 12/1/2021 |
1.0.0-preview.145 | 256 | 11/11/2021 |
1.0.0-preview.143 | 253 | 10/22/2021 |
1.0.0-preview.141 | 237 | 10/18/2021 |
1.0.0-preview.138 | 260 | 10/18/2021 |
1.0.0-preview.136 | 352 | 7/17/2021 |
1.0.0-preview.134 | 224 | 7/16/2021 |
1.0.0-preview.132 | 225 | 7/16/2021 |
1.0.0-preview.130 | 239 | 7/15/2021 |
1.0.0-preview.128 | 239 | 7/14/2021 |
1.0.0-preview.126 | 333 | 6/19/2021 |
1.0.0-preview.124 | 317 | 6/19/2021 |
1.0.0-preview.122 | 234 | 6/17/2021 |
1.0.0-preview.119 | 228 | 6/7/2021 |
1.0.0-preview.117 | 223 | 6/7/2021 |
1.0.0-preview.115 | 255 | 6/7/2021 |
1.0.0-preview.113 | 260 | 6/7/2021 |
1.0.0-preview.111 | 271 | 6/6/2021 |
1.0.0-preview.109 | 972 | 6/5/2021 |
1.0.0-preview.107 | 231 | 6/3/2021 |
1.0.0-preview.105 | 224 | 6/2/2021 |
1.0.0-preview.103 | 227 | 6/2/2021 |
1.0.0-preview.101 | 240 | 6/1/2021 |
1.0.0-preview.99 | 248 | 6/1/2021 |
1.0.0-preview.96 | 251 | 6/1/2021 |
1.0.0-preview.94 | 254 | 5/31/2021 |
1.0.0-preview.92 | 260 | 5/30/2021 |
1.0.0-preview.90 | 239 | 5/27/2021 |
1.0.0-preview.88 | 235 | 5/26/2021 |
1.0.0-preview.86 | 343 | 5/23/2021 |
1.0.0-preview.84 | 251 | 5/22/2021 |
1.0.0-preview.82 | 292 | 5/21/2021 |
1.0.0-preview.80 | 241 | 5/19/2021 |
1.0.0-preview.78 | 228 | 5/19/2021 |
1.0.0-preview.76 | 247 | 5/19/2021 |
1.0.0-preview.71 | 242 | 5/15/2021 |
1.0.0-preview.69 | 214 | 5/14/2021 |
1.0.0-preview.66 | 238 | 5/13/2021 |
1.0.0-preview.64 | 243 | 5/11/2021 |
1.0.0-preview.62 | 235 | 5/11/2021 |
1.0.0-preview.59 | 297 | 5/6/2021 |
1.0.0-preview.57 | 226 | 5/5/2021 |
1.0.0-preview.51 | 241 | 4/12/2021 |
1.0.0-preview.49 | 243 | 4/12/2021 |
1.0.0-preview.47 | 259 | 4/10/2021 |
1.0.0-preview.44 | 251 | 4/6/2021 |
1.0.0-preview.41 | 233 | 4/5/2021 |
1.0.0-preview.32 | 265 | 3/21/2021 |
1.0.0-preview.30 | 292 | 3/20/2021 |
1.0.0-preview.28 | 271 | 3/19/2021 |
1.0.0-preview.26 | 267 | 3/18/2021 |
1.0.0-preview.24 | 234 | 3/17/2021 |
1.0.0-preview.22 | 230 | 3/17/2021 |
1.0.0-preview.20 | 265 | 3/5/2021 |
1.0.0-preview.18 | 238 | 3/2/2021 |
1.0.0-preview.15 | 483 | 1/19/2021 |
1.0.0-preview.13 | 245 | 1/19/2021 |
1.0.0-preview.11 | 318 | 1/7/2021 |
1.0.0-preview.10 | 274 | 12/22/2020 |
1.0.0-preview.6 | 339 | 12/1/2020 |
1.0.0-preview.3 | 339 | 11/6/2020 |