Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -434,15 +434,19 @@ server.withMethodHandler(ListTools.self) { _ in
name: "weather",
description: "Get current weather for a location",
inputSchema: .object([
"location": .string("City name or coordinates"),
"units": .string("Units of measurement, e.g., metric, imperial")
"properties": .object([
"location": .string("City name or coordinates"),
"units": .string("Units of measurement, e.g., metric, imperial")
])
])
),
Tool(
name: "calculator",
description: "Perform calculations",
inputSchema: .object([
"expression": .string("Mathematical expression to evaluate")
"properties": .object([
"expression": .string("Mathematical expression to evaluate")
])
])
)
]
Expand Down
24 changes: 15 additions & 9 deletions Tests/MCPTests/ToolTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ struct ToolTests {
name: "test_tool",
description: "A test tool",
inputSchema: .object([
"param1": .string("Test parameter")
"properties": .object([
"param1": .string("Test parameter")
])
])
)

Expand Down Expand Up @@ -100,7 +102,9 @@ struct ToolTests {
name: "calculate",
description: "Performs calculations",
inputSchema: .object([
"expression": .string("Mathematical expression to evaluate")
"properties": .object([
"expression": .string("Mathematical expression to evaluate")
])
]),
annotations: annotations
)
Expand Down Expand Up @@ -131,23 +135,23 @@ struct ToolTests {

do {
#expect(tool.annotations.isEmpty)

let encoder = JSONEncoder()
let data = try encoder.encode(tool)

// Verify that empty annotations are not included in the JSON
let jsonString = String(data: data, encoding: .utf8)!
#expect(!jsonString.contains("\"annotations\""))
}

do {
tool.annotations.title = "Test"

#expect(!tool.annotations.isEmpty)

let encoder = JSONEncoder()
let data = try encoder.encode(tool)

// Verify that empty annotations are not included in the JSON
let jsonString = String(data: data, encoding: .utf8)!
#expect(jsonString.contains("\"annotations\""))
Expand Down Expand Up @@ -179,8 +183,10 @@ struct ToolTests {
name: "test_tool",
description: "Test tool description",
inputSchema: .object([
"param1": .string("String parameter"),
"param2": .int(42),
"properties": .object([
"param1": .string("String parameter"),
"param2": .int(42),
])
])
)

Expand Down