Repository navigation
Commit 019b8ed
authored
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
- Tests/EventKitMCPTests
- Contract
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
75 | | - | |
| 75 | + | |
| 76 | + | |
76 | 77 | | |
77 | 78 | | |
78 | 79 | | |
| |||
0 commit comments