Skip to content

Commit 9a59ff4

Browse files
committed
checkpoint
1 parent abdd723 commit 9a59ff4

File tree

29 files changed

+1542
-1525
lines changed

29 files changed

+1542
-1525
lines changed

exercises/01.advanced-tools/01.problem.annotations/src/tools.ts

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export async function initializeTools(agent: EpicMeMCP) {
3939
createTextContent(
4040
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
4141
),
42-
createEntryResourceLink(createdEntry),
42+
createEntryEmbeddedResource(createdEntry),
4343
],
4444
}
4545
},
@@ -58,7 +58,7 @@ export async function initializeTools(agent: EpicMeMCP) {
5858
const entry = await agent.db.getEntry(id)
5959
invariant(entry, `Entry with ID "${id}" not found`)
6060
return {
61-
content: [createTextContent(entry), createEntryResourceContent(entry)],
61+
content: [createEntryEmbeddedResource(entry)],
6262
}
6363
},
6464
)
@@ -102,7 +102,7 @@ export async function initializeTools(agent: EpicMeMCP) {
102102
createTextContent(
103103
`Entry "${updatedEntry.title}" (ID: ${id}) updated successfully`,
104104
),
105-
createEntryResourceLink(updatedEntry),
105+
createEntryEmbeddedResource(updatedEntry),
106106
],
107107
}
108108
},
@@ -127,7 +127,7 @@ export async function initializeTools(agent: EpicMeMCP) {
127127
createTextContent(
128128
`Entry "${existingEntry.title}" (ID: ${id}) deleted successfully`,
129129
),
130-
createEntryResourceLink(existingEntry),
130+
createEntryEmbeddedResource(existingEntry),
131131
],
132132
}
133133
},
@@ -149,7 +149,7 @@ export async function initializeTools(agent: EpicMeMCP) {
149149
createTextContent(
150150
`Tag "${createdTag.name}" created successfully with ID "${createdTag.id}"`,
151151
),
152-
createTagResourceLink(createdTag),
152+
createTagEmbeddedResource(createdTag),
153153
],
154154
}
155155
},
@@ -168,7 +168,7 @@ export async function initializeTools(agent: EpicMeMCP) {
168168
const tag = await agent.db.getTag(id)
169169
invariant(tag, `Tag ID "${id}" not found`)
170170
return {
171-
content: [createTextContent(tag), createTagResourceContent(tag)],
171+
content: [createTextContent(tag), createTagEmbeddedResource(tag)],
172172
}
173173
},
174174
)
@@ -206,7 +206,7 @@ export async function initializeTools(agent: EpicMeMCP) {
206206
createTextContent(
207207
`Tag "${updatedTag.name}" (ID: ${id}) updated successfully`,
208208
),
209-
createTagResourceLink(updatedTag),
209+
createTagEmbeddedResource(updatedTag),
210210
],
211211
}
212212
},
@@ -230,7 +230,7 @@ export async function initializeTools(agent: EpicMeMCP) {
230230
createTextContent(
231231
`Tag "${existingTag.name}" (ID: ${id}) deleted successfully`,
232232
),
233-
createTagResourceLink(existingTag),
233+
createTagEmbeddedResource(existingTag),
234234
],
235235
}
236236
},
@@ -259,8 +259,8 @@ export async function initializeTools(agent: EpicMeMCP) {
259259
createTextContent(
260260
`Tag "${tag.name}" (ID: ${entryTag.tagId}) added to entry "${entry.title}" (ID: ${entryTag.entryId}) successfully`,
261261
),
262-
createTagResourceLink(tag),
263-
createEntryResourceLink(entry),
262+
createTagEmbeddedResource(tag),
263+
createEntryEmbeddedResource(entry),
264264
],
265265
}
266266
},
@@ -306,9 +306,14 @@ export async function initializeTools(agent: EpicMeMCP) {
306306
})
307307
return {
308308
content: [
309-
createTextContent(
310-
`Video created successfully with URI "${videoUri}"`,
311-
),
309+
createTextContent('Video created successfully'),
310+
{
311+
type: 'resource_link',
312+
uri: videoUri,
313+
name: `wrapped-${year}.mp4`,
314+
description: `Wrapped Video for ${year}`,
315+
mimeType: 'video/mp4',
316+
},
312317
],
313318
}
314319
},
@@ -356,7 +361,7 @@ function createTagResourceLink(tag: {
356361

357362
type ResourceContent = CallToolResult['content'][number]
358363

359-
function createEntryResourceContent(entry: { id: number }): ResourceContent {
364+
function createEntryEmbeddedResource(entry: { id: number }): ResourceContent {
360365
return {
361366
type: 'resource',
362367
resource: {
@@ -367,7 +372,7 @@ function createEntryResourceContent(entry: { id: number }): ResourceContent {
367372
}
368373
}
369374

370-
function createTagResourceContent(tag: { id: number }): ResourceContent {
375+
function createTagEmbeddedResource(tag: { id: number }): ResourceContent {
371376
return {
372377
type: 'resource',
373378
resource: {

exercises/01.advanced-tools/01.solution.annotations/src/tools.ts

Lines changed: 21 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ export async function initializeTools(agent: EpicMeMCP) {
4141
createTextContent(
4242
`Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`,
4343
),
44-
createEntryResourceLink(createdEntry),
44+
createEntryEmbeddedResource(createdEntry),
4545
],
4646
}
4747
},
@@ -62,7 +62,7 @@ export async function initializeTools(agent: EpicMeMCP) {
6262
const entry = await agent.db.getEntry(id)
6363
invariant(entry, `Entry with ID "${id}" not found`)
6464
return {
65-
content: [createTextContent(entry), createEntryResourceContent(entry)],
65+
content: [createEntryEmbeddedResource(entry)],
6666
}
6767
},
6868
)
@@ -111,7 +111,7 @@ export async function initializeTools(agent: EpicMeMCP) {
111111
createTextContent(
112112
`Entry "${updatedEntry.title}" (ID: ${id}) updated successfully`,
113113
),
114-
createEntryResourceLink(updatedEntry),
114+
createEntryEmbeddedResource(updatedEntry),
115115
],
116116
}
117117
},
@@ -138,7 +138,7 @@ export async function initializeTools(agent: EpicMeMCP) {
138138
createTextContent(
139139
`Entry "${existingEntry.title}" (ID: ${id}) deleted successfully`,
140140
),
141-
createEntryResourceLink(existingEntry),
141+
createEntryEmbeddedResource(existingEntry),
142142
],
143143
}
144144
},
@@ -162,7 +162,7 @@ export async function initializeTools(agent: EpicMeMCP) {
162162
createTextContent(
163163
`Tag "${createdTag.name}" created successfully with ID "${createdTag.id}"`,
164164
),
165-
createTagResourceLink(createdTag),
165+
createTagEmbeddedResource(createdTag),
166166
],
167167
}
168168
},
@@ -183,7 +183,7 @@ export async function initializeTools(agent: EpicMeMCP) {
183183
const tag = await agent.db.getTag(id)
184184
invariant(tag, `Tag ID "${id}" not found`)
185185
return {
186-
content: [createTextContent(tag), createTagResourceContent(tag)],
186+
content: [createTextContent(tag), createTagEmbeddedResource(tag)],
187187
}
188188
},
189189
)
@@ -226,7 +226,7 @@ export async function initializeTools(agent: EpicMeMCP) {
226226
createTextContent(
227227
`Tag "${updatedTag.name}" (ID: ${id}) updated successfully`,
228228
),
229-
createTagResourceLink(updatedTag),
229+
createTagEmbeddedResource(updatedTag),
230230
],
231231
}
232232
},
@@ -252,7 +252,7 @@ export async function initializeTools(agent: EpicMeMCP) {
252252
createTextContent(
253253
`Tag "${existingTag.name}" (ID: ${id}) deleted successfully`,
254254
),
255-
createTagResourceLink(existingTag),
255+
createTagEmbeddedResource(existingTag),
256256
],
257257
}
258258
},
@@ -284,8 +284,8 @@ export async function initializeTools(agent: EpicMeMCP) {
284284
createTextContent(
285285
`Tag "${tag.name}" (ID: ${entryTag.tagId}) added to entry "${entry.title}" (ID: ${entryTag.entryId}) successfully`,
286286
),
287-
createTagResourceLink(tag),
288-
createEntryResourceLink(entry),
287+
createTagEmbeddedResource(tag),
288+
createEntryEmbeddedResource(entry),
289289
],
290290
}
291291
},
@@ -316,10 +316,7 @@ export async function initializeTools(agent: EpicMeMCP) {
316316
),
317317
},
318318
},
319-
async (
320-
{ year = new Date().getFullYear(), mockTime },
321-
{ sendNotification, _meta, signal },
322-
) => {
319+
async ({ year = new Date().getFullYear(), mockTime }) => {
323320
const entries = await agent.db.getEntries()
324321
const filteredEntries = entries.filter(
325322
(entry) => new Date(entry.createdAt * 1000).getFullYear() === year,
@@ -333,26 +330,17 @@ export async function initializeTools(agent: EpicMeMCP) {
333330
tags: filteredTags,
334331
year,
335332
mockTime,
336-
signal,
337-
onProgress: (progress) => {
338-
const { progressToken } = _meta ?? {}
339-
if (!progressToken) return
340-
void sendNotification({
341-
method: 'notifications/progress',
342-
params: {
343-
progressToken,
344-
progress,
345-
total: 1,
346-
message: 'Creating video...',
347-
},
348-
})
349-
},
350333
})
351334
return {
352335
content: [
353-
createTextContent(
354-
`Video created successfully with URI "${videoUri}"`,
355-
),
336+
createTextContent('Video created successfully'),
337+
{
338+
type: 'resource_link',
339+
uri: videoUri,
340+
name: `wrapped-${year}.mp4`,
341+
description: `Wrapped Video for ${year}`,
342+
mimeType: 'video/mp4',
343+
},
356344
],
357345
}
358346
},
@@ -400,7 +388,7 @@ function createTagResourceLink(tag: {
400388

401389
type ResourceContent = CallToolResult['content'][number]
402390

403-
function createEntryResourceContent(entry: { id: number }): ResourceContent {
391+
function createEntryEmbeddedResource(entry: { id: number }): ResourceContent {
404392
return {
405393
type: 'resource',
406394
resource: {
@@ -411,7 +399,7 @@ function createEntryResourceContent(entry: { id: number }): ResourceContent {
411399
}
412400
}
413401

414-
function createTagResourceContent(tag: { id: number }): ResourceContent {
402+
function createTagEmbeddedResource(tag: { id: number }): ResourceContent {
415403
return {
416404
type: 'resource',
417405
resource: {

0 commit comments

Comments
 (0)