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
65
```csharp
66
66
using (WebServerserver=newWebServer(80, HttpProtocol.Http, newType[] { typeof(MyController) }))
@@ -119,6 +119,30 @@ public class LedCommand
119
119
}
120
120
```
121
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
+
}
142
+
```
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.
using (varserver=newWebServer(80, HttpProtocol.Http, newType[] { typeof(McpServerController) }))
@@ -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