diff --git a/exercises/01.advanced-tools/02.problem.structured/src/tools.ts b/exercises/01.advanced-tools/02.problem.structured/src/tools.ts index 54b701c..c15c9d3 100644 --- a/exercises/01.advanced-tools/02.problem.structured/src/tools.ts +++ b/exercises/01.advanced-tools/02.problem.structured/src/tools.ts @@ -41,6 +41,10 @@ export async function initializeTools(agent: EpicMeMCP) { } } + // 🐨 refetch entry to get updated tags + // 💰 agent.db.getEntry(createdEntry.id) + // 💯 add invariant to check if the entry was found + // 🐨 create a structuredContent here that matches the outputSchema return { // 🐨 add structuredContent here @@ -330,7 +334,7 @@ export async function initializeTools(agent: EpicMeMCP) { openWorldHint: false, } satisfies ToolAnnotations, inputSchema: entryTagIdSchema, - // 🐨 add an outputSchema here with a success boolean and a tagEntry that is an entryTagSchema + // 🐨 add an outputSchema here with a success boolean and an entryTag that is an entryTagSchema }, async ({ entryId, tagId }) => { const tag = await agent.db.getTag(tagId) @@ -382,7 +386,7 @@ export async function initializeTools(agent: EpicMeMCP) { 'If set to > 0, use mock mode and this is the mock wait time in milliseconds', ), }, - // 🐨 add an outputSchema here with a video that includes videoUri (you're on your own here!) + // 🐨 add an outputSchema here with a videoUri field (you're on your own here!) }, async ({ year = new Date().getFullYear(), mockTime }) => { const entries = await agent.db.getEntries() diff --git a/exercises/01.advanced-tools/02.solution.structured/src/tools.ts b/exercises/01.advanced-tools/02.solution.structured/src/tools.ts index 2c2e260..790df8c 100644 --- a/exercises/01.advanced-tools/02.solution.structured/src/tools.ts +++ b/exercises/01.advanced-tools/02.solution.structured/src/tools.ts @@ -41,14 +41,18 @@ export async function initializeTools(agent: EpicMeMCP) { } } - const structuredContent = { entry: createdEntry } + // Refetch entry to get updated tags + const entryWithTags = await agent.db.getEntry(createdEntry.id) + invariant(entryWithTags, `Failed to refetch created entry`) + + const structuredContent = { entry: entryWithTags } return { structuredContent, content: [ createText( - `Entry "${createdEntry.title}" created successfully with ID "${createdEntry.id}"`, + `Entry "${entryWithTags.title}" created successfully with ID "${entryWithTags.id}"`, ), - createEntryResourceLink(createdEntry), + createEntryResourceLink(entryWithTags), createText(structuredContent), ], }