Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 7 additions & 3 deletions exercises/01.advanced-tools/02.solution.structured/src/tools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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),
],
}
Expand Down
Loading