Skip to content

Commit 019b8ed

Browse files
test: snapshot the MCP tool contract and exercise registration through an in-memory server (#13)
First of the refactoring series: the instruments that let every later PR prove it changed nothing a client can see. ## Change - `Tests/EventKitMCPTests/Contract/tool-contract.json` is `ToolRegistry.allTools()` encoded with sorted keys. The new `toolContractMatchesSnapshot` test compares against it and names the first differing line; `UPDATE_TOOL_CONTRACT=1 swift test --filter toolContractMatchesSnapshot` regenerates it. A changed snapshot in a diff is the signal that the PR title needs `feat`, `fix` or `!`. - `ServerRegistrationTests` drives `ToolRegistry.registerHandlers` through the SDK's `InMemoryTransport` and a real `Client`. It pins the read-only listing and the read-only call gate end to end, which nothing reached before. - `inputContracts` is deleted. Its substring checks are a strict subset of the snapshot. - `Package.swift` excludes the `Contract` directory from the test target so SwiftPM does not warn about an unhandled file. The snapshot also settles a question for later work: every optional input property is already advertised as `["<type>", "null"]`, so clients may send `null` today. ## Verification - `swift test`: 31 library tests and 141 server tests pass (139 before, +3 new, −1 deleted). - `swift build -c release` is clean. ## Mutation record | Mutation | Failing tests | |---|---| | `time filter` → `time filters` in the query tool description | `toolContractMatchesSnapshot`, reported as `tool-contract.json:8` with both lines | | overview declared `destructiveHint` instead of `readOnlyHint` | `toolContractMatchesSnapshot`, `readOnlyTools`, `readOnlyServer` | Both reverted before commit. ## Release impact None. Tests and a test-target manifest exclude only.
1 parent abcbb4f commit 019b8ed

4 files changed

Lines changed: 1287 additions & 18 deletions

File tree

‎Package.swift‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ let package = Package(
7272
.product(name: "MCP", package: "swift-sdk"),
7373
.product(name: "JSONSchema", package: "swift-json-schema")
7474
],
75-
path: "Tests/EventKitMCPTests"
75+
path: "Tests/EventKitMCPTests",
76+
exclude: ["Contract"]
7677
)
7778
],
7879
swiftLanguageModes: [.v6]

0 commit comments

Comments
 (0)