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
39 changes: 9 additions & 30 deletions exercises/03.resources/03.problem.list/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,38 +149,17 @@ test('Resource List - Entries', async () => {

const list = await client.listResources()

// 🚨 Proactive check: Ensure list callback returns actual entries
// Since entries don't have a list callback, they shouldn't appear in the resources list
const entryResources = list.resources.filter((r) => r.uri.includes('entries'))
invariant(
entryResources.length > 0,
'🚨 No entry resources found in list - the list callback should return actual entries from the database',
)
expect(entryResources).toHaveLength(0)

// Check that we have at least the entries we created
const foundEntries = entryResources.filter(
(r) => r.uri.includes('entries/1') || r.uri.includes('entries/2'),
)
invariant(
foundEntries.length >= 2,
'🚨 List should return the entries that were created',
// Verify that the entries template exists but doesn't have a list callback
const templatesList = await client.listResourceTemplates()
const entriesTemplate = templatesList.resourceTemplates.find(
(rt) => rt.uriTemplate.includes('entries') && rt.uriTemplate.includes('{'),
)

// Validate the structure of listed resources
entryResources.forEach((resource) => {
expect(resource).toEqual(
expect.objectContaining({
name: expect.any(String),
uri: expect.stringMatching(/epicme:\/\/entries\/\d+/),
mimeType: 'application/json',
}),
)

// 🚨 Proactive check: List should not include content (only metadata)
invariant(
!('text' in resource),
'🚨 Resource list should only contain metadata, not the full content - use readResource to get content',
)
})
expect(entriesTemplate).toBeDefined()
expect(entriesTemplate?.list).toBeUndefined()
})

test('Resource List - Tags', async () => {
Expand Down Expand Up @@ -222,7 +201,7 @@ test('Resource List - Tags', async () => {
expect.objectContaining({
name: expect.any(String),
uri: expect.stringMatching(/epicme:\/\/tags\/\d+/),
mimeType: 'application/json',
mimeType: 'text/plain',
}),
)
})
Expand Down
2 changes: 1 addition & 1 deletion exercises/03.resources/03.solution.list/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ test('Resource List - Tags', async () => {
expect.objectContaining({
name: expect.any(String),
uri: expect.stringMatching(/epicme:\/\/tags\/\d+/),
mimeType: 'application/json',
mimeType: 'text/plain',
}),
)
})
Expand Down
2 changes: 1 addition & 1 deletion exercises/03.resources/03.solution.list/src/resources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function initializeResources(agent: EpicMeMCP) {
resources: tags.map((tag) => ({
name: tag.name,
uri: `epicme://tags/${tag.id}`,
mimeType: 'application/json',
mimeType: 'text/plain',
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Resource MimeType Mismatch Causes Client Confusion

The tag resource listing advertises mimeType: 'text/plain', but the actual resource content is application/json when read. This mismatch can lead to client confusion expecting the advertised type.

Fix in Cursor Fix in Web

})),
}
},
Expand Down
Loading