You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Controllers are supported including with parametarized routes like `api/led/{id}/dosomething/{order}`.
63
+
Controllers are supported including with parametarized routes like 'api/led/{id}/dosomething/{order}'.
64
64
65
-
```csharp
65
+
'''csharp
66
66
using (WebServer server = new WebServer(80, HttpProtocol.Http, new Type[] { typeof(MyController) }))
67
67
{
68
68
server.Start();
@@ -86,15 +86,15 @@ public class MyController
86
86
WebServer.OutPutStream(e.Context.Response, $"You selected Led {ledId}!");
87
87
}
88
88
}
89
-
```
89
+
'''
90
90
91
91
## Model Context Protocol (MCP) Support
92
92
93
93
Enable AI agents to interact with your embedded devices through standardized tools and JSON-RPC 2.0 protocol.
94
94
95
95
### Defining MCP Tools
96
96
97
-
```csharp
97
+
'''csharp
98
98
public class IoTTools
99
99
{
100
100
[McpServerTool("read_sensor", "Reads temperature from sensor")]
@@ -117,18 +117,45 @@ public class LedCommand
117
117
[Description("LED state: on, off, or blink")]
118
118
public string State { get; set; }
119
119
}
120
+
'''
121
+
122
+
### Defining MCP Prompts
123
+
124
+
You can define reusable, high-level prompts for AI agents using the `McpServerPrompt` attribute. Prompts encapsulate multi-step instructions or workflows that can be invoked by agents.
125
+
126
+
Here's a simple example:
127
+
128
+
```csharp
129
+
usingnanoFramework.WebServer.Mcp;
130
+
131
+
publicclassMcpPrompts
132
+
{
133
+
[McpServerPrompt("echo_sanity_check", "Echo test prompt")]
134
+
publicstaticPromptMessage[] EchoSanityCheck()
135
+
{
136
+
returnnewPromptMessage[]
137
+
{
138
+
newPromptMessage("Call Echo with the string 'Hello MCP world!' and return the response.")
139
+
};
140
+
}
141
+
}
120
142
```
121
143
144
+
Prompts can be discovered and invoked by AI agents in the same way as tools. You can also define prompts with parameters using the `McpPromptParameter` attribute.
145
+
122
146
### Setting Up MCP Server
123
147
124
-
```csharp
148
+
'''csharp
125
149
public static void Main()
126
150
{
127
151
// Connect to WiFi first
128
152
var connected = WifiNetworkHelper.ConnectDhcp(Ssid, Password, requiresDateTime: true);
using (var server = new WebServer(80, HttpProtocol.Http, new Type[] { typeof(McpServerController) }))
@@ -141,13 +168,13 @@ public static void Main()
141
168
Thread.Sleep(Timeout.Infinite);
142
169
}
143
170
}
144
-
```
171
+
'''
145
172
146
173
### AI Agent Integration
147
174
148
175
Once running, AI agents can discover and invoke your tools:
149
176
150
-
```json
177
+
'''json
151
178
// Tool discovery
152
179
POST /mcp
153
180
{
@@ -167,7 +194,7 @@ POST /mcp
167
194
},
168
195
"id": 2
169
196
}
170
-
```
197
+
'''
171
198
172
199
## Documentation
173
200
@@ -187,11 +214,12 @@ POST /mcp
187
214
- No compression support in request/response streams
188
215
- MCP implementation supports server features only (no notifications or SSE)
189
216
- No or single parameter limitation for MCP tools (use complex objects for multiple parameters)
217
+
- Prompt parameters, when declared, are always mandatory.
190
218
191
219
## Installation
192
220
193
-
Install `nanoFramework.WebServer` for the Web Server without File System support. Install `nanoFramework.WebServer.FileSystem` for file serving, so with devices supporting File System.
194
-
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.
221
+
Install 'nanoFramework.WebServer' for the Web Server without File System support. Install 'nanoFramework.WebServer.FileSystem' for file serving, so with devices supporting File System.
222
+
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.
-**Type-safe parameter handling** with automatic deserialization from JSON to .NET objects
33
34
-**Flexible authentication** options (none, basic auth, API key)
34
35
-**Complex object support** for both input parameters and return values
35
36
-**Robust error handling** and validation
36
37
-**Memory efficient** implementation optimized for embedded devices
37
38
-**HTTPS support** with SSL/TLS encryption
39
+
## Defining MCP Prompts
40
+
41
+
MCP Prompts allow you to define reusable, multi-step instructions or workflows that can be invoked by AI agents. Prompts are discovered and registered similarly to tools, using the `[McpServerPrompt]` attribute on static methods that return an array of `PromptMessage`.
42
+
43
+
Prompts can encapsulate complex logic, multi-step flows, or provide high-level instructions for agents. You can also define parameters for prompts using the `[McpPromptParameter]` attribute. **All parameters defined for a prompt are mandatory.**
44
+
45
+
### Example: Defining a Prompt
46
+
47
+
```csharp
48
+
usingnanoFramework.WebServer.Mcp;
49
+
50
+
publicclassMcpPrompts
51
+
{
52
+
[McpServerPrompt("echo_sanity_check", "Echo test prompt")]
53
+
publicstaticPromptMessage[] EchoSanityCheck()
54
+
{
55
+
returnnewPromptMessage[]
56
+
{
57
+
newPromptMessage("Call Echo with the string 'Hello MCP world!' and return the response.")
58
+
};
59
+
}
60
+
61
+
[McpServerPrompt("summarize_person", "Summarize a person with age threshold")]
62
+
[McpPromptParameter("ageThreshold", "The age threshold to determine if the person is a senior or junior.")]
0 commit comments