Skip to content

Commit f1f5912

Browse files
committed
satisfaction
1 parent 0c7ff56 commit f1f5912

File tree

22 files changed

+596
-288
lines changed
  • exercises
    • 01.simple
    • 02.consistent
      • 01.problem.remote-dom/worker/mcp
      • 01.solution.remote-dom/worker/mcp
    • 03.complex
    • 04.interactive
    • 05.advanced
      • 01.problem.tool-results/worker/mcp
      • 01.solution.tool-results/worker/mcp
      • 02.problem.render-data/worker/mcp
      • 02.solution.render-data/worker/mcp

22 files changed

+596
-288
lines changed

exercises/01.simple/01.problem.raw-html/worker/mcp/tools.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export async function initializeTools(agent: EpicMeMCP) {
2727
annotations: {
2828
destructiveHint: false,
2929
openWorldHint: false,
30-
},
30+
} satisfies ToolAnnotations,
3131
inputSchema: createEntryInputSchema,
3232
outputSchema: { entry: entryWithTagsSchema },
3333
},
@@ -66,7 +66,7 @@ export async function initializeTools(agent: EpicMeMCP) {
6666
annotations: {
6767
readOnlyHint: true,
6868
openWorldHint: false,
69-
},
69+
} satisfies ToolAnnotations,
7070
inputSchema: entryIdSchema,
7171
outputSchema: { entry: entryWithTagsSchema },
7272
},
@@ -92,7 +92,7 @@ export async function initializeTools(agent: EpicMeMCP) {
9292
annotations: {
9393
readOnlyHint: true,
9494
openWorldHint: false,
95-
},
95+
} satisfies ToolAnnotations,
9696
outputSchema: {
9797
entries: z.array(entryListItemSchema),
9898
},
@@ -122,7 +122,7 @@ export async function initializeTools(agent: EpicMeMCP) {
122122
destructiveHint: false,
123123
idempotentHint: true,
124124
openWorldHint: false,
125-
},
125+
} satisfies ToolAnnotations,
126126
inputSchema: updateEntryInputSchema,
127127
outputSchema: { entry: entryWithTagsSchema },
128128
},
@@ -152,7 +152,7 @@ export async function initializeTools(agent: EpicMeMCP) {
152152
annotations: {
153153
idempotentHint: true,
154154
openWorldHint: false,
155-
},
155+
} satisfies ToolAnnotations,
156156
inputSchema: entryIdSchema,
157157
outputSchema: { success: z.boolean(), entry: entryWithTagsSchema },
158158
},
@@ -203,7 +203,7 @@ export async function initializeTools(agent: EpicMeMCP) {
203203
annotations: {
204204
destructiveHint: false,
205205
openWorldHint: false,
206-
},
206+
} satisfies ToolAnnotations,
207207
inputSchema: createTagInputSchema,
208208
outputSchema: { tag: tagSchema },
209209
},
@@ -231,7 +231,7 @@ export async function initializeTools(agent: EpicMeMCP) {
231231
annotations: {
232232
readOnlyHint: true,
233233
openWorldHint: false,
234-
},
234+
} satisfies ToolAnnotations,
235235
inputSchema: tagIdSchema,
236236
outputSchema: { tag: tagSchema },
237237
},
@@ -254,7 +254,7 @@ export async function initializeTools(agent: EpicMeMCP) {
254254
annotations: {
255255
readOnlyHint: true,
256256
openWorldHint: false,
257-
},
257+
} satisfies ToolAnnotations,
258258
outputSchema: { tags: z.array(tagListItemSchema) },
259259
},
260260
async () => {
@@ -281,7 +281,7 @@ export async function initializeTools(agent: EpicMeMCP) {
281281
destructiveHint: false,
282282
idempotentHint: true,
283283
openWorldHint: false,
284-
},
284+
} satisfies ToolAnnotations,
285285
inputSchema: updateTagInputSchema,
286286
outputSchema: { tag: tagSchema },
287287
},
@@ -309,7 +309,7 @@ export async function initializeTools(agent: EpicMeMCP) {
309309
annotations: {
310310
idempotentHint: true,
311311
openWorldHint: false,
312-
},
312+
} satisfies ToolAnnotations,
313313
inputSchema: tagIdSchema,
314314
outputSchema: { success: z.boolean(), tag: tagSchema },
315315
},
@@ -359,7 +359,7 @@ export async function initializeTools(agent: EpicMeMCP) {
359359
destructiveHint: false,
360360
idempotentHint: true,
361361
openWorldHint: false,
362-
},
362+
} satisfies ToolAnnotations,
363363
inputSchema: entryTagIdSchema,
364364
outputSchema: { success: z.boolean(), entryTag: entryTagSchema },
365365
},
@@ -388,6 +388,20 @@ export async function initializeTools(agent: EpicMeMCP) {
388388
)
389389
}
390390

391+
type ToolAnnotations = {
392+
// defaults to true, so only allow false
393+
openWorldHint?: false
394+
} & (
395+
| {
396+
// when readOnlyHint is true, none of the other annotations can be changed
397+
readOnlyHint: true
398+
}
399+
| {
400+
destructiveHint?: false // Only allow false (default is true)
401+
idempotentHint?: true // Only allow true (default is false)
402+
}
403+
)
404+
391405
function createText(text: unknown): CallToolResult['content'][number] {
392406
if (typeof text === 'string') {
393407
return { type: 'text', text }

exercises/01.simple/01.solution.raw-html/worker/mcp/tools.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export async function initializeTools(agent: EpicMeMCP) {
2828
annotations: {
2929
destructiveHint: false,
3030
openWorldHint: false,
31-
},
31+
} satisfies ToolAnnotations,
3232
inputSchema: createEntryInputSchema,
3333
outputSchema: { entry: entryWithTagsSchema },
3434
},
@@ -67,7 +67,7 @@ export async function initializeTools(agent: EpicMeMCP) {
6767
annotations: {
6868
readOnlyHint: true,
6969
openWorldHint: false,
70-
},
70+
} satisfies ToolAnnotations,
7171
inputSchema: entryIdSchema,
7272
outputSchema: { entry: entryWithTagsSchema },
7373
},
@@ -93,7 +93,7 @@ export async function initializeTools(agent: EpicMeMCP) {
9393
annotations: {
9494
readOnlyHint: true,
9595
openWorldHint: false,
96-
},
96+
} satisfies ToolAnnotations,
9797
outputSchema: {
9898
entries: z.array(entryListItemSchema),
9999
},
@@ -123,7 +123,7 @@ export async function initializeTools(agent: EpicMeMCP) {
123123
destructiveHint: false,
124124
idempotentHint: true,
125125
openWorldHint: false,
126-
},
126+
} satisfies ToolAnnotations,
127127
inputSchema: updateEntryInputSchema,
128128
outputSchema: { entry: entryWithTagsSchema },
129129
},
@@ -153,7 +153,7 @@ export async function initializeTools(agent: EpicMeMCP) {
153153
annotations: {
154154
idempotentHint: true,
155155
openWorldHint: false,
156-
},
156+
} satisfies ToolAnnotations,
157157
inputSchema: entryIdSchema,
158158
outputSchema: { success: z.boolean(), entry: entryWithTagsSchema },
159159
},
@@ -204,7 +204,7 @@ export async function initializeTools(agent: EpicMeMCP) {
204204
annotations: {
205205
destructiveHint: false,
206206
openWorldHint: false,
207-
},
207+
} satisfies ToolAnnotations,
208208
inputSchema: createTagInputSchema,
209209
outputSchema: { tag: tagSchema },
210210
},
@@ -232,7 +232,7 @@ export async function initializeTools(agent: EpicMeMCP) {
232232
annotations: {
233233
readOnlyHint: true,
234234
openWorldHint: false,
235-
},
235+
} satisfies ToolAnnotations,
236236
inputSchema: tagIdSchema,
237237
},
238238
async ({ id }) => {
@@ -269,7 +269,7 @@ export async function initializeTools(agent: EpicMeMCP) {
269269
annotations: {
270270
readOnlyHint: true,
271271
openWorldHint: false,
272-
},
272+
} satisfies ToolAnnotations,
273273
inputSchema: tagIdSchema,
274274
outputSchema: { tag: tagSchema },
275275
},
@@ -292,7 +292,7 @@ export async function initializeTools(agent: EpicMeMCP) {
292292
annotations: {
293293
readOnlyHint: true,
294294
openWorldHint: false,
295-
},
295+
} satisfies ToolAnnotations,
296296
outputSchema: { tags: z.array(tagListItemSchema) },
297297
},
298298
async () => {
@@ -319,7 +319,7 @@ export async function initializeTools(agent: EpicMeMCP) {
319319
destructiveHint: false,
320320
idempotentHint: true,
321321
openWorldHint: false,
322-
},
322+
} satisfies ToolAnnotations,
323323
inputSchema: updateTagInputSchema,
324324
outputSchema: { tag: tagSchema },
325325
},
@@ -347,7 +347,7 @@ export async function initializeTools(agent: EpicMeMCP) {
347347
annotations: {
348348
idempotentHint: true,
349349
openWorldHint: false,
350-
},
350+
} satisfies ToolAnnotations,
351351
inputSchema: tagIdSchema,
352352
outputSchema: { success: z.boolean(), tag: tagSchema },
353353
},
@@ -397,7 +397,7 @@ export async function initializeTools(agent: EpicMeMCP) {
397397
destructiveHint: false,
398398
idempotentHint: true,
399399
openWorldHint: false,
400-
},
400+
} satisfies ToolAnnotations,
401401
inputSchema: entryTagIdSchema,
402402
outputSchema: { success: z.boolean(), entryTag: entryTagSchema },
403403
},
@@ -426,6 +426,20 @@ export async function initializeTools(agent: EpicMeMCP) {
426426
)
427427
}
428428

429+
type ToolAnnotations = {
430+
// defaults to true, so only allow false
431+
openWorldHint?: false
432+
} & (
433+
| {
434+
// when readOnlyHint is true, none of the other annotations can be changed
435+
readOnlyHint: true
436+
}
437+
| {
438+
destructiveHint?: false // Only allow false (default is true)
439+
idempotentHint?: true // Only allow true (default is false)
440+
}
441+
)
442+
429443
function createText(text: unknown): CallToolResult['content'][number] {
430444
if (typeof text === 'string') {
431445
return { type: 'text', text }

exercises/02.consistent/01.problem.remote-dom/worker/mcp/tools.ts

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export async function initializeTools(agent: EpicMeMCP) {
2929
annotations: {
3030
destructiveHint: false,
3131
openWorldHint: false,
32-
},
32+
} satisfies ToolAnnotations,
3333
inputSchema: createEntryInputSchema,
3434
outputSchema: { entry: entryWithTagsSchema },
3535
},
@@ -68,7 +68,7 @@ export async function initializeTools(agent: EpicMeMCP) {
6868
annotations: {
6969
readOnlyHint: true,
7070
openWorldHint: false,
71-
},
71+
} satisfies ToolAnnotations,
7272
inputSchema: entryIdSchema,
7373
outputSchema: { entry: entryWithTagsSchema },
7474
},
@@ -94,7 +94,7 @@ export async function initializeTools(agent: EpicMeMCP) {
9494
annotations: {
9595
readOnlyHint: true,
9696
openWorldHint: false,
97-
},
97+
} satisfies ToolAnnotations,
9898
outputSchema: {
9999
entries: z.array(entryListItemSchema),
100100
},
@@ -124,7 +124,7 @@ export async function initializeTools(agent: EpicMeMCP) {
124124
destructiveHint: false,
125125
idempotentHint: true,
126126
openWorldHint: false,
127-
},
127+
} satisfies ToolAnnotations,
128128
inputSchema: updateEntryInputSchema,
129129
outputSchema: { entry: entryWithTagsSchema },
130130
},
@@ -154,7 +154,7 @@ export async function initializeTools(agent: EpicMeMCP) {
154154
annotations: {
155155
idempotentHint: true,
156156
openWorldHint: false,
157-
},
157+
} satisfies ToolAnnotations,
158158
inputSchema: entryIdSchema,
159159
outputSchema: { success: z.boolean(), entry: entryWithTagsSchema },
160160
},
@@ -205,7 +205,7 @@ export async function initializeTools(agent: EpicMeMCP) {
205205
annotations: {
206206
destructiveHint: false,
207207
openWorldHint: false,
208-
},
208+
} satisfies ToolAnnotations,
209209
inputSchema: createTagInputSchema,
210210
outputSchema: { tag: tagSchema },
211211
},
@@ -233,7 +233,7 @@ export async function initializeTools(agent: EpicMeMCP) {
233233
annotations: {
234234
readOnlyHint: true,
235235
openWorldHint: false,
236-
},
236+
} satisfies ToolAnnotations,
237237
inputSchema: tagIdSchema,
238238
},
239239
async ({ id }) => {
@@ -260,7 +260,7 @@ export async function initializeTools(agent: EpicMeMCP) {
260260
annotations: {
261261
readOnlyHint: true,
262262
openWorldHint: false,
263-
},
263+
} satisfies ToolAnnotations,
264264
inputSchema: tagIdSchema,
265265
outputSchema: { tag: tagSchema },
266266
},
@@ -283,7 +283,7 @@ export async function initializeTools(agent: EpicMeMCP) {
283283
annotations: {
284284
readOnlyHint: true,
285285
openWorldHint: false,
286-
},
286+
} satisfies ToolAnnotations,
287287
outputSchema: { tags: z.array(tagListItemSchema) },
288288
},
289289
async () => {
@@ -310,7 +310,7 @@ export async function initializeTools(agent: EpicMeMCP) {
310310
destructiveHint: false,
311311
idempotentHint: true,
312312
openWorldHint: false,
313-
},
313+
} satisfies ToolAnnotations,
314314
inputSchema: updateTagInputSchema,
315315
outputSchema: { tag: tagSchema },
316316
},
@@ -338,7 +338,7 @@ export async function initializeTools(agent: EpicMeMCP) {
338338
annotations: {
339339
idempotentHint: true,
340340
openWorldHint: false,
341-
},
341+
} satisfies ToolAnnotations,
342342
inputSchema: tagIdSchema,
343343
outputSchema: { success: z.boolean(), tag: tagSchema },
344344
},
@@ -388,7 +388,7 @@ export async function initializeTools(agent: EpicMeMCP) {
388388
destructiveHint: false,
389389
idempotentHint: true,
390390
openWorldHint: false,
391-
},
391+
} satisfies ToolAnnotations,
392392
inputSchema: entryTagIdSchema,
393393
outputSchema: { success: z.boolean(), entryTag: entryTagSchema },
394394
},
@@ -417,6 +417,20 @@ export async function initializeTools(agent: EpicMeMCP) {
417417
)
418418
}
419419

420+
type ToolAnnotations = {
421+
// defaults to true, so only allow false
422+
openWorldHint?: false
423+
} & (
424+
| {
425+
// when readOnlyHint is true, none of the other annotations can be changed
426+
readOnlyHint: true
427+
}
428+
| {
429+
destructiveHint?: false // Only allow false (default is true)
430+
idempotentHint?: true // Only allow true (default is false)
431+
}
432+
)
433+
420434
function createText(text: unknown): CallToolResult['content'][number] {
421435
if (typeof text === 'string') {
422436
return { type: 'text', text }

0 commit comments

Comments
 (0)