Skip to content

Commit 59d72e8

Browse files
committed
also generate callTool public
1 parent 3b9a126 commit 59d72e8

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Sources/SwiftMCPMacros/MCPServerMacro.swift

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -149,20 +149,20 @@ public struct MCPServerMacro: MemberMacro, ExtensionMacro {
149149
/// - arguments: A dictionary of arguments to pass to the tool
150150
/// - Returns: The result of the tool call
151151
/// - Throws: MCPToolError if the tool doesn't exist or cannot be called
152-
func callTool(_ name: String, arguments: [String: Any]) throws -> Codable {
153-
// Find the tool by name
154-
guard let tool = mcpTools.first(where: { $0.name == name }) else {
155-
throw MCPToolError.unknownTool(name: name)
156-
}
152+
public func callTool(_ name: String, arguments: [String: Any]) throws -> Codable {
153+
// Find the tool by name
154+
guard let tool = mcpTools.first(where: { $0.name == name }) else {
155+
throw MCPToolError.unknownTool(name: name)
156+
}
157157
158-
// Enrich arguments with default values
159-
let enrichedArguments = try tool.enrichArguments(arguments, forObject: self)
158+
// Enrich arguments with default values
159+
let enrichedArguments = try tool.enrichArguments(arguments, forObject: self)
160160
161-
// Call the appropriate wrapper method based on the tool name
162-
switch name {
163-
\(switchCases.joined(separator: "\n"))
164-
default: throw MCPToolError.unknownTool(name: name)
165-
}
161+
// Call the appropriate wrapper method based on the tool name
162+
switch name {
163+
\(switchCases.joined(separator: "\n"))
164+
default: throw MCPToolError.unknownTool(name: name)
165+
}
166166
}
167167
"""
168168

0 commit comments

Comments
 (0)