Skip to content

Commit f84b8e6

Browse files
committed
Fixed the usage of DescriptionAttribute for Complex Objects in MCP.
1 parent 0e04504 commit f84b8e6

2 files changed

Lines changed: 77 additions & 25 deletions

File tree

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ public class IoTTools
105105
return "23.5°C";
106106
}
107107

108-
[McpServerTool("control_led", "Controls device LED", "Uutput the statusof the LED")]
108+
[McpServerTool("control_led", "Controls device LED", "Output the status of the LED")]
109109
public static string ControlLed(LedCommand command)
110110
{
111111
// Your LED control code
@@ -115,8 +115,12 @@ public class IoTTools
115115

116116
public class LedCommand
117117
{
118-
[Description("LED state: on, off, or blink")]
119-
public string State { get; set; }
118+
public string State
119+
{
120+
[Description("LED state: on, off, or blink")]
121+
get;
122+
set;
123+
}
120124
}
121125
```
122126

doc/model-context-protocol.md

Lines changed: 70 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Model Context Protocol (MCP) Support
1+
# Model Context Protocol (MCP) Support
22

33
The nanoFramework WebServer provides comprehensive support for the Model Context Protocol (MCP), enabling AI agents and language models to directly interact with your embedded devices. MCP allows AI systems to discover, invoke, and receive responses from tools running on your nanoFramework device.
44

@@ -217,28 +217,56 @@ Use classes to handle multiple parameters or complex data structures:
217217
```csharp
218218
public class DeviceConfig
219219
{
220-
[Description("Device name identifier")]
221-
public string DeviceName { get; set; }
220+
public string DeviceName
221+
{
222+
[Description("Device name identifier")]
223+
get;
224+
set;
225+
}
222226

223-
[Description("Operating mode: auto, manual, or sleep")]
224-
public string Mode { get; set; }
227+
public string Mode
228+
{
229+
[Description("Operating mode: auto, manual, or sleep")]
230+
get;
231+
set;
232+
}
225233

226-
[Description("Update interval in seconds")]
227-
public int UpdateInterval { get; set; } = 60;
234+
public int UpdateInterval
235+
{
236+
[Description("Update interval in seconds")]
237+
get;
238+
set;
239+
} = 60;
228240

229-
public WifiSettings Wifi { get; set; } = new WifiSettings();
241+
public WifiSettings Wifi
242+
{
243+
get;
244+
set;
245+
} = new WifiSettings();
230246
}
231247

232248
public class WifiSettings
233249
{
234-
[Description("WiFi network SSID")]
235-
public string SSID { get; set; }
250+
public string SSID
251+
{
252+
[Description("WiFi network SSID")]
253+
get;
254+
set;
255+
}
236256

237-
[Description("WiFi signal strength in dBm")]
238-
public int SignalStrength { get; set; }
257+
public int SignalStrength
258+
{
259+
[Description("WiFi signal strength in dBm")]
260+
get;
261+
set;
262+
}
239263

240-
[Description("Connection status")]
241-
public bool IsConnected { get; set; }
264+
public bool IsConnected
265+
{
266+
[Description("Connection status")]
267+
get;
268+
set;
269+
}
242270
}
243271
```
244272

@@ -1104,10 +1132,18 @@ public class SecureTools
11041132
public class ResetRequest
11051133
{
11061134
[Description("Confirmation code (must be 'FACTORY_RESET_CONFIRMED')")]
1107-
public string ConfirmationCode { get; set; }
1135+
public string ConfirmationCode
1136+
{
1137+
get;
1138+
set;
1139+
}
11081140

11091141
[Description("Reason for factory reset")]
1110-
public string Reason { get; set; }
1142+
public string Reason
1143+
{
1144+
get;
1145+
set;
1146+
}
11111147
}
11121148
```
11131149

@@ -1125,14 +1161,26 @@ using nanoFramework.WebServer.Mcp;
11251161

11261162
public class ThermostatConfig
11271163
{
1128-
[Description("Target temperature in Celsius")]
1129-
public float TargetTemperature { get; set; } = 22.0f;
1164+
public float TargetTemperature
1165+
{
1166+
[Description("Target temperature in Celsius")]
1167+
get;
1168+
set;
1169+
} = 22.0f;
11301170

1131-
[Description("Operating mode: heat, cool, auto, or off")]
1132-
public string Mode { get; set; } = "auto";
1171+
public string Mode
1172+
{
1173+
[Description("Operating mode: heat, cool, auto, or off")]
1174+
get;
1175+
set;
1176+
} = "auto";
11331177

1134-
[Description("Enable schedule-based operation")]
1135-
public bool ScheduleEnabled { get; set; } = true;
1178+
public bool ScheduleEnabled
1179+
{
1180+
[Description("Enable schedule-based operation")]
1181+
get;
1182+
set;
1183+
} = true;
11361184
}
11371185

11381186
public class ThermostatStatus

0 commit comments

Comments
 (0)