Skip to content

Commit 6ea1c4a

Browse files
committed
feat: add _meta maxResultSizeChars annotations for Claude Code large results
Upgrade swift-sdk 0.3.0 → 0.12.0 to get _meta support on Tool definitions. Annotate all 293 tools with anthropic/maxResultSizeChars in tools/list response: - 500K for analytics/report tools (TSV data, financials) - 200K for list/search endpoints (reviews, builds, testers) - 100K for single-item CRUD operations Prevents Claude Code from truncating large MCP responses to disk.
1 parent 891f170 commit 6ea1c4a

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

Package.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ let package = Package(
1212
.executable(name: "asc-mcp", targets: ["asc-mcp"])
1313
],
1414
dependencies: [
15-
.package(url: "https://github.com/modelcontextprotocol/swift-sdk.git", from: "0.3.0")
15+
.package(url: "https://github.com/modelcontextprotocol/swift-sdk.git", from: "0.12.0")
1616
],
1717
targets: [
1818
.executableTarget(

Sources/asc-mcp/Workers/MainWorker/WorkerManager.swift

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,31 @@ public actor WorkerManager {
258258
allTools += await self.getReviewAttachmentsTools()
259259
}
260260

261-
return ListTools.Result(tools: allTools)
261+
// Annotate tools with maxResultSizeChars for Claude Code
262+
let analyticsTools: Set<String> = [
263+
"analytics_sales_report", "analytics_financial_report",
264+
"analytics_get_report", "analytics_app_summary"
265+
]
266+
267+
let annotatedTools = allTools.map { tool -> Tool in
268+
var modified = tool
269+
let maxChars: Int
270+
if analyticsTools.contains(tool.name) {
271+
maxChars = 500_000
272+
} else if tool.name.contains("_list") || tool.name.contains("_search") {
273+
maxChars = 200_000
274+
} else {
275+
maxChars = 100_000
276+
}
277+
modified._meta = Metadata(additionalFields: [
278+
"anthropic/maxResultSizeChars": .int(maxChars)
279+
])
280+
return modified
281+
}
282+
283+
return ListTools.Result(tools: annotatedTools)
262284
}
263-
285+
264286
// Handler for all tool calls
265287
await server.withMethodHandler(CallTool.self) { params in
266288
do {

0 commit comments

Comments
 (0)