|
1 | 1 | --- |
2 | | -status: planned |
3 | | -created: 2025-12-21 |
| 2 | +status: complete |
| 3 | +created: '2025-12-21' |
4 | 4 | priority: medium |
5 | 5 | tags: |
6 | | -- mcp |
7 | | -- dx |
8 | | -- ai-agents |
9 | | -- templates |
10 | | -- documentation |
11 | | -created_at: 2025-12-21T14:53:17.954876Z |
12 | | -updated_at: 2025-12-21T14:53:17.954876Z |
| 6 | + - mcp |
| 7 | + - dx |
| 8 | + - ai-agents |
| 9 | + - templates |
| 10 | + - documentation |
| 11 | +created_at: '2025-12-21T14:53:17.954876Z' |
| 12 | +updated_at: '2025-12-21T15:24:08.504Z' |
| 13 | +transitions: |
| 14 | + - status: in-progress |
| 15 | + at: '2025-12-21T15:07:43.301Z' |
| 16 | + - status: complete |
| 17 | + at: '2025-12-21T15:24:08.504Z' |
| 18 | +completed_at: '2025-12-21T15:24:08.504Z' |
| 19 | +completed: '2025-12-21' |
13 | 20 | --- |
14 | 21 |
|
15 | 22 | # Embed Spec Template in MCP Create Tool Content Field Description |
16 | 23 |
|
17 | | -> **Status**: planned · **Priority**: medium · **Created**: {date} |
| 24 | +> **Status**: ✅ Complete · **Priority**: Medium · **Created**: 2025-12-21 · **Tags**: mcp, dx, ai-agents, templates, documentation |
18 | 25 |
|
19 | 26 | ## Problem & Motivation |
20 | 27 |
|
@@ -164,16 +171,16 @@ Keep specs <2000 tokens optimal, <3500 max. Consider sub-specs (IMPLEMENTATION.m |
164 | 171 |
|
165 | 172 | ## Acceptance Criteria |
166 | 173 |
|
167 | | -- [ ] MCP server loads `.lean-spec/templates/spec-template.md` at startup |
168 | | -- [ ] Template loading uses existing `TemplateLoader` infrastructure |
169 | | -- [ ] Frontmatter (YAML block) is stripped from loaded template |
170 | | -- [ ] Title line (`# {name}` or similar) is stripped from loaded template |
171 | | -- [ ] Template body is embedded into `content` field description |
172 | | -- [ ] Description prepends explanatory text about body-only content |
173 | | -- [ ] If template load fails, falls back to minimal static description |
174 | | -- [ ] Tool schema reflects actual template (test by viewing schema) |
175 | | -- [ ] AI agents can see template structure in MCP tool descriptions |
176 | | -- [ ] Changes to template file automatically reflect in tool schema after MCP restart |
| 174 | +- [x] MCP server loads `.lean-spec/templates/spec-template.md` at startup |
| 175 | +- [x] Template loading uses existing `TemplateLoader` infrastructure |
| 176 | +- [x] Frontmatter (YAML block) is stripped from loaded template |
| 177 | +- [x] Title line (`# {name}` or similar) is stripped from loaded template |
| 178 | +- [x] Template body is embedded into `content` field description |
| 179 | +- [x] Description prepends explanatory text about body-only content |
| 180 | +- [x] If template load fails, falls back to minimal static description |
| 181 | +- [x] Tool schema reflects actual template (test by viewing schema) |
| 182 | +- [x] AI agents can see template structure in MCP tool descriptions |
| 183 | +- [x] Changes to template file automatically reflect in tool schema after MCP restart |
177 | 184 |
|
178 | 185 | ## Out of Scope |
179 | 186 |
|
@@ -232,6 +239,14 @@ Keep specs <2000 tokens optimal, <3500 max. Consider sub-specs (IMPLEMENTATION.m |
232 | 239 | - Verify fallback works if template missing |
233 | 240 | - Confirm template changes reflect after restart |
234 | 241 |
|
| 242 | +### Implementation Notes (2025-12-21) |
| 243 | +- Create tool schema now builds its `content` description by loading the default template via `TemplateLoader`, stripping frontmatter/title/status lines, and caching the processed body with `OnceLock` for reuse. |
| 244 | +- Added a graceful fallback description and warning when template loading fails. |
| 245 | +- Added a regression test asserting the create tool description includes the template body (without frontmatter) so AI agents see the expected structure. |
| 246 | + |
| 247 | +### Testing |
| 248 | +- `RUSTFLAGS="-Awarnings" cargo test -p leanspec-mcp test_create_tool_description_includes_template_body -- --nocapture` |
| 249 | + |
235 | 250 | ## Open Questions |
236 | 251 |
|
237 | 252 | 1. Should we cache the loaded template or reload on every schema request? |
@@ -301,4 +316,4 @@ If LeanSpec adds multiple templates (standard, detailed, minimal), we could: |
301 | 316 | - Show merged/combined structure in description |
302 | 317 | - Or dynamically show template based on `template` parameter |
303 | 318 |
|
304 | | -For now, **YAGNI** - just load the default `spec-template.md`. |
| 319 | +For now, **YAGNI** - just load the default `spec-template.md`. |
0 commit comments