Skip to content

Commit 36865fb

Browse files
authored
Update inputSchema example usage (#136)
* Update Tool inputSchema in README example usage * Update inputSchema usage in Tool tests
1 parent 7a76001 commit 36865fb

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

README.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -434,15 +434,19 @@ server.withMethodHandler(ListTools.self) { _ in
434434
name: "weather",
435435
description: "Get current weather for a location",
436436
inputSchema: .object([
437-
"location": .string("City name or coordinates"),
438-
"units": .string("Units of measurement, e.g., metric, imperial")
437+
"properties": .object([
438+
"location": .string("City name or coordinates"),
439+
"units": .string("Units of measurement, e.g., metric, imperial")
440+
])
439441
])
440442
),
441443
Tool(
442444
name: "calculator",
443445
description: "Perform calculations",
444446
inputSchema: .object([
445-
"expression": .string("Mathematical expression to evaluate")
447+
"properties": .object([
448+
"expression": .string("Mathematical expression to evaluate")
449+
])
446450
])
447451
)
448452
]

Tests/MCPTests/ToolTests.swift

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@ struct ToolTests {
1111
name: "test_tool",
1212
description: "A test tool",
1313
inputSchema: .object([
14-
"param1": .string("Test parameter")
14+
"properties": .object([
15+
"param1": .string("Test parameter")
16+
])
1517
])
1618
)
1719

@@ -100,7 +102,9 @@ struct ToolTests {
100102
name: "calculate",
101103
description: "Performs calculations",
102104
inputSchema: .object([
103-
"expression": .string("Mathematical expression to evaluate")
105+
"properties": .object([
106+
"expression": .string("Mathematical expression to evaluate")
107+
])
104108
]),
105109
annotations: annotations
106110
)
@@ -131,23 +135,23 @@ struct ToolTests {
131135

132136
do {
133137
#expect(tool.annotations.isEmpty)
134-
138+
135139
let encoder = JSONEncoder()
136140
let data = try encoder.encode(tool)
137-
141+
138142
// Verify that empty annotations are not included in the JSON
139143
let jsonString = String(data: data, encoding: .utf8)!
140144
#expect(!jsonString.contains("\"annotations\""))
141145
}
142-
146+
143147
do {
144148
tool.annotations.title = "Test"
145149

146150
#expect(!tool.annotations.isEmpty)
147-
151+
148152
let encoder = JSONEncoder()
149153
let data = try encoder.encode(tool)
150-
154+
151155
// Verify that empty annotations are not included in the JSON
152156
let jsonString = String(data: data, encoding: .utf8)!
153157
#expect(jsonString.contains("\"annotations\""))
@@ -179,8 +183,10 @@ struct ToolTests {
179183
name: "test_tool",
180184
description: "Test tool description",
181185
inputSchema: .object([
182-
"param1": .string("String parameter"),
183-
"param2": .int(42),
186+
"properties": .object([
187+
"param1": .string("String parameter"),
188+
"param2": .int(42),
189+
])
184190
])
185191
)
186192

0 commit comments

Comments
 (0)