Skip to content

Commit 18ab747

Browse files
committed
Accept string-typed numeric parameters in tool schemas
1 parent 9e06f53 commit 18ab747

5 files changed

Lines changed: 18 additions & 13 deletions

File tree

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## 0.1.2
4+
5+
### Fixed
6+
- Accept string-typed numeric parameters in tool schemas (`"4"` instead of `4`). Some MCP clients serialize all tool arguments as strings, which caused JSON Schema validation errors on `integer` and `number` fields. Affected fields: `handle`, `max_items`, `timeout_s`, `idle_timeout_s`, `k`, `n`.
7+
38
## 0.1.1
49

510
- Add MCP registry metadata (server.json)

ble_mcp_server/handlers_ble.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
5858
"type": "object",
5959
"properties": {
6060
"timeout_s": {
61-
"type": "number",
61+
"type": ["number", "string"],
6262
"description": "Max scan duration in seconds (default 10, max 60). Scan auto-stops after this.",
6363
"default": 10,
6464
},
@@ -123,7 +123,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
123123
"description": "MAC address or platform identifier of the device.",
124124
},
125125
"timeout_s": {
126-
"type": "number",
126+
"type": ["number", "string"],
127127
"description": "Connection timeout in seconds (default 10).",
128128
"default": 10,
129129
},
@@ -239,7 +239,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
239239
"properties": {
240240
"connection_id": {"type": "string"},
241241
"handle": {
242-
"type": "integer",
242+
"type": ["integer", "string"],
243243
"description": "The descriptor handle (integer) from ble.discover.",
244244
},
245245
},
@@ -257,7 +257,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
257257
"properties": {
258258
"connection_id": {"type": "string"},
259259
"handle": {
260-
"type": "integer",
260+
"type": ["integer", "string"],
261261
"description": "The descriptor handle (integer).",
262262
},
263263
"value_b64": {"type": "string", "description": "Base64-encoded value."},
@@ -303,7 +303,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
303303
"connection_id": {"type": "string"},
304304
"subscription_id": {"type": "string"},
305305
"timeout_s": {
306-
"type": "number",
306+
"type": ["number", "string"],
307307
"description": "Max seconds to wait (default 10, max 60).",
308308
"default": 10,
309309
},
@@ -324,7 +324,7 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
324324
"connection_id": {"type": "string"},
325325
"subscription_id": {"type": "string"},
326326
"max_items": {
327-
"type": "integer",
327+
"type": ["integer", "string"],
328328
"description": "Max notifications to return (default 50, max 1000).",
329329
"default": 50,
330330
},
@@ -346,17 +346,17 @@ def _decode_value(args: dict[str, Any]) -> bytes | dict[str, Any]:
346346
"connection_id": {"type": "string"},
347347
"subscription_id": {"type": "string"},
348348
"timeout_s": {
349-
"type": "number",
349+
"type": ["number", "string"],
350350
"description": "Total max wait in seconds (default 2, max 60).",
351351
"default": 2,
352352
},
353353
"idle_timeout_s": {
354-
"type": "number",
354+
"type": ["number", "string"],
355355
"description": "Max idle gap between notifications before stopping (default 0.25, max 10).",
356356
"default": 0.25,
357357
},
358358
"max_items": {
359-
"type": "integer",
359+
"type": ["integer", "string"],
360360
"description": "Max notifications to collect (default 200, max 5000).",
361361
"default": 200,
362362
},

ble_mcp_server/handlers_spec.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@
113113
"spec_id": {"type": "string"},
114114
"query": {"type": "string", "description": "Search terms (space-separated)."},
115115
"k": {
116-
"type": "integer",
116+
"type": ["integer", "string"],
117117
"description": "Max results to return (default 10).",
118118
"default": 10,
119119
},

ble_mcp_server/handlers_trace.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"type": "object",
3232
"properties": {
3333
"n": {
34-
"type": "integer",
34+
"type": ["integer", "string"],
3535
"description": "Number of recent events to return (default 50).",
3636
"default": 50,
3737
},

server.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@
66
"url": "https://github.com/es617/ble-mcp-server.git",
77
"source": "github"
88
},
9-
"version": "0.1.1",
9+
"version": "0.1.2",
1010
"packages": [
1111
{
1212
"registryType": "pypi",
1313
"identifier": "ble-mcp-server",
14-
"version": "0.1.1",
14+
"version": "0.1.2",
1515
"transport": {
1616
"type": "stdio"
1717
},

0 commit comments

Comments
 (0)