Files
mcpctl/.taskmaster/tasks/task_057.md

51 lines
1.5 KiB
Markdown
Raw Permalink Normal View History

# Task ID: 57
**Title:** Add linkStatus to prompt GET responses
**Status:** done
**Dependencies:** 56 ✓
**Priority:** medium
**Description:** Modify the GET /api/v1/prompts endpoint to include linkStatus (alive/dead/unknown) for linked prompts by checking link health.
**Details:**
1. Update `/src/mcpd/src/routes/prompts.ts` GET endpoint:
```typescript
fastify.get('/api/v1/prompts', async (request, reply) => {
const prompts = await promptService.findAll(filter);
// Check link status for linked prompts
const promptsWithStatus = await Promise.all(
prompts.map(async (p) => {
if (!p.linkTarget) {
return { ...p, linkStatus: null };
}
const status = await linkResolver.checkLinkHealth(p.linkTarget);
return { ...p, linkStatus: status };
})
);
return reply.send(promptsWithStatus);
});
```
2. Consider caching link health to avoid repeated checks
3. Add `linkStatus` field to prompt response schema:
- `null` for non-linked prompts
- `'alive'` for working links
- `'dead'` for broken links
- `'unknown'` for unchecked links
**Test Strategy:**
- Unit test: Non-linked prompt has linkStatus=null
- Unit test: Linked prompt with working link has linkStatus='alive'
- Unit test: Linked prompt with broken link has linkStatus='dead'
- Unit test: Link health cached to avoid repeated checks
- Unit test: All prompts in response have linkStatus field
- Integration test: End-to-end GET with linked prompts