Skip to content

Commit 727f804

Browse files
authored
Merge pull request #13 from jpicklyk/feature/58eaf20d-ai-markdown-guidance
Feature/58eaf20d ai markdown guidance
2 parents cdf857d + abfeaa6 commit 727f804

File tree

15 files changed

+1859
-8
lines changed

15 files changed

+1859
-8
lines changed

CHANGELOG.md

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,26 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
- Markdown transformation tools for exporting entities to markdown format with YAML frontmatter
12+
- `task_to_markdown` - Transform tasks to markdown documents
13+
- `feature_to_markdown` - Transform features to markdown documents
14+
- `project_to_markdown` - Transform projects to markdown documents
15+
- Markdown resource provider with usage guide for markdown transformation capabilities
16+
- Clear separation between inspection tools (get_*) and transformation tools (*_to_markdown)
17+
18+
### Changed
19+
- Removed `includeMarkdownView` parameter from get_task, get_feature, and get_project tools
20+
- Updated API reference documentation to reflect 40 total tools (was 37)
21+
- Updated tool category counts: Task Management (7 tools), Feature Management (6 tools), Project Management (6 tools)
22+
23+
### Technical Details
24+
- Markdown transformation uses existing MarkdownRenderer from domain layer
25+
- Dedicated tools avoid content duplication in responses
26+
- Better use case clarity for AI agents: JSON for inspection, markdown for export/rendering
27+
828
## [1.1.0-alpha-01]
929

1030
### Dependencies
@@ -18,7 +38,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1838
- Output schemas for all 5 Project Management tools (create_project, get_project, update_project, delete_project, search_projects)
1939
- Output schemas for all 10 Section Management tools (add_section, get_sections, update_section, delete_section, update_section_text, update_section_metadata, bulk_create_sections, bulk_update_sections, bulk_delete_sections, reorder_sections)
2040
- Output schemas for all 9 Template Management tools (create_template, get_template, list_templates, apply_template, update_template_metadata, delete_template, add_template_section, enable_template, disable_template)
21-
- Tool titles for all 39 MCP tools for better discoverability in clients
41+
- Tool titles for all MCP tools for better discoverability in clients
2242
- ToolDefinition interface enhancements: optional `title` and `outputSchema` properties
2343
- ToolRegistry now registers tool titles and output schemas with MCP server
2444
- Installation Guide (`docs/installation-guide.md`) - comprehensive setup guide for all platforms and installation methods

CLAUDE.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,61 @@
2929
- Include acceptance criteria in summaries when helpful
3030
- Reference related tasks, features, or projects when applicable
3131

32+
### Section Content Formatting Guidelines
33+
34+
When creating or updating sections with `contentFormat=MARKDOWN`, use proper markdown syntax:
35+
36+
**Structure Content with Headings**:
37+
- Use `##` for section titles (will render as H2 in markdown view)
38+
- Use `###` for subsections
39+
- Use `####` for detailed breakdowns
40+
41+
**Organize with Lists**:
42+
- Use `-` or `*` for unordered lists
43+
- Use `1.` for ordered steps or sequences
44+
- Indent with 2 spaces for nested items
45+
46+
**Emphasize Important Content**:
47+
- Use `**text**` for bold (important points, requirements)
48+
- Use `*text*` for italic (slight emphasis)
49+
- Use `> ` for blockquotes (warnings, notes)
50+
51+
**Include Code Examples**:
52+
- Use \`code\` for inline code references
53+
- Use \`\`\`language for code blocks with syntax highlighting
54+
- Specify language: kotlin, java, json, yaml, bash, sql
55+
56+
**Add References**:
57+
- Use `[text](url)` for external links
58+
- Link to relevant documentation or specs
59+
60+
**Example Task Section**:
61+
````markdown
62+
## Implementation Approach
63+
64+
### Phase 1: Core Infrastructure
65+
- Create `MarkdownRenderer` class
66+
- Implement **YAML frontmatter** generation
67+
- Handle all `ContentFormat` types
68+
69+
### Key Decisions
70+
> **Note**: Using YAML frontmatter for metadata follows CommonMark best practices
71+
72+
```kotlin
73+
class MarkdownRenderer {
74+
fun render(task: Task): String { ... }
75+
}
76+
```
77+
78+
See [CommonMark Spec](https://commonmark.org/) for details.
79+
````
80+
81+
**Why Markdown Matters**:
82+
- Content is directly readable without AI translation
83+
- Exports cleanly to documentation tools
84+
- Renders properly in markdown viewers
85+
- Supports markdown-based MCP resource views
86+
3287
### Template Usage Protocol
3388

3489
**Always Check and Use Available Templates:**

docs/api-reference.md

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: API Reference
55

66
# MCP Tools API Reference
77

8-
The MCP Task Orchestrator provides **37 MCP tools** for AI-driven project management. This reference focuses on **when and why** AI uses each tool, not exhaustive parameter documentation (AI agents have access to complete MCP schemas).
8+
The MCP Task Orchestrator provides **40 MCP tools** for AI-driven project management. This reference focuses on **when and why** AI uses each tool, not exhaustive parameter documentation (AI agents have access to complete MCP schemas).
99

1010
## Table of Contents
1111

@@ -173,7 +173,7 @@ AI chooses tools based on:
173173

174174
## Tool Categories
175175

176-
### Task Management (6 tools)
176+
### Task Management (7 tools)
177177

178178
**Core Workflow**:
179179
- `create_task` - Create tasks with templates
@@ -182,36 +182,39 @@ AI chooses tools based on:
182182
- `search_tasks` - Filter and find tasks
183183
- `get_overview` - Hierarchical project view
184184
- `delete_task` - Remove tasks with cleanup
185+
- `task_to_markdown` - Transform task to markdown format
185186

186187
**When AI Uses**: Most frequently - tasks are primary work units
187188

188189
**Key Feature**: Progressive loading (`includeSections`, `includeDependencies`, `includeFeature`)
189190

190191
---
191192

192-
### Feature Management (5 tools)
193+
### Feature Management (6 tools)
193194

194195
**Core Workflow**:
195196
- `create_feature` - Group related tasks
196197
- `update_feature` - Feature status and metadata
197198
- `get_feature` - Feature details with task statistics
198199
- `search_features` - Find features by criteria
199200
- `delete_feature` - Remove with cascade or orphan options
201+
- `feature_to_markdown` - Transform feature to markdown format
200202

201203
**When AI Uses**: Organizing 3+ related tasks, major functional areas
202204

203205
**Key Feature**: Task aggregation and organizational hierarchy
204206

205207
---
206208

207-
### Project Management (5 tools)
209+
### Project Management (6 tools)
208210

209211
**Core Workflow**:
210212
- `create_project` - Top-level organizational containers
211213
- `update_project` - Project metadata and status
212214
- `get_project` - Project details with features and tasks
213215
- `search_projects` - Find projects by criteria
214216
- `delete_project` - Remove with cascade options
217+
- `project_to_markdown` - Transform project to markdown format
215218

216219
**When AI Uses**: Large initiatives, multi-feature work, organizational hierarchy
217220

@@ -280,6 +283,34 @@ AI chooses tools based on:
280283
281284
---
282285

286+
### Markdown Transformation (3 tools)
287+
288+
**Core Workflow**:
289+
- `task_to_markdown` - Transform task to markdown with YAML frontmatter
290+
- `feature_to_markdown` - Transform feature to markdown with YAML frontmatter
291+
- `project_to_markdown` - Transform project to markdown with YAML frontmatter
292+
293+
**When AI Uses**:
294+
- File export and documentation generation
295+
- Systems that can render markdown directly
296+
- Version control and diff-friendly storage
297+
- Human-readable archives
298+
299+
**Key Feature**: Separate transformation tools for clear use case distinction
300+
301+
**Important Pattern**:
302+
- Use `get_*` tools (get_task, get_feature, get_project) for JSON inspection
303+
- Use `*_to_markdown` tools for markdown export/rendering
304+
- Avoids content duplication in responses
305+
306+
**Use Cases**:
307+
- "Export this task to markdown" → `task_to_markdown`
308+
- "Create a markdown document for this feature" → `feature_to_markdown`
309+
- "Generate project documentation" → `project_to_markdown`
310+
- For terminal inspection, use `get_*` tools instead
311+
312+
---
313+
283314
## Core Workflow Tools
284315

285316
### Most Frequently Used Tools
Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
package io.github.jpicklyk.mcptask.application.tools.feature
2+
3+
import io.github.jpicklyk.mcptask.application.tools.ToolCategory
4+
import io.github.jpicklyk.mcptask.application.tools.ToolExecutionContext
5+
import io.github.jpicklyk.mcptask.application.tools.ToolValidationException
6+
import io.github.jpicklyk.mcptask.application.tools.base.BaseToolDefinition
7+
import io.github.jpicklyk.mcptask.domain.model.EntityType
8+
import io.github.jpicklyk.mcptask.domain.rendering.MarkdownRenderer
9+
import io.github.jpicklyk.mcptask.domain.repository.RepositoryError
10+
import io.github.jpicklyk.mcptask.domain.repository.Result
11+
import io.github.jpicklyk.mcptask.infrastructure.util.ErrorCodes
12+
import io.modelcontextprotocol.kotlin.sdk.Tool
13+
import kotlinx.serialization.json.*
14+
import java.util.*
15+
16+
/**
17+
* MCP tool for transforming a feature into markdown format with YAML frontmatter.
18+
*
19+
* This tool retrieves a feature and its sections, then renders them as a markdown document
20+
* with YAML frontmatter metadata. The markdown output is suitable for file export,
21+
* documentation generation, and systems that can render markdown directly.
22+
*
23+
* Use this tool when you need a markdown-formatted view of a feature rather than JSON data.
24+
* For inspecting feature details in structured format, use get_feature instead.
25+
*
26+
* Related tools:
27+
* - get_feature: To retrieve feature details in JSON format for inspection
28+
* - task_to_markdown: To transform a task into markdown
29+
* - project_to_markdown: To transform a project into markdown
30+
*/
31+
class FeatureToMarkdownTool : BaseToolDefinition() {
32+
override val category: ToolCategory = ToolCategory.FEATURE_MANAGEMENT
33+
34+
override val name: String = "feature_to_markdown"
35+
36+
override val title: String = "Transform Feature to Markdown"
37+
38+
override val outputSchema: Tool.Output = Tool.Output(
39+
properties = JsonObject(
40+
mapOf(
41+
"success" to JsonObject(mapOf("type" to JsonPrimitive("boolean"))),
42+
"message" to JsonObject(mapOf("type" to JsonPrimitive("string"))),
43+
"data" to JsonObject(
44+
mapOf(
45+
"type" to JsonPrimitive("object"),
46+
"description" to JsonPrimitive("The feature rendered as markdown"),
47+
"properties" to JsonObject(
48+
mapOf(
49+
"markdown" to JsonObject(
50+
mapOf(
51+
"type" to JsonPrimitive("string"),
52+
"description" to JsonPrimitive("Markdown-formatted feature with YAML frontmatter")
53+
)
54+
),
55+
"featureId" to JsonObject(
56+
mapOf(
57+
"type" to JsonPrimitive("string"),
58+
"format" to JsonPrimitive("uuid")
59+
)
60+
)
61+
)
62+
)
63+
)
64+
),
65+
"error" to JsonObject(mapOf("type" to JsonArray(listOf(JsonPrimitive("object"), JsonPrimitive("null"))))),
66+
"metadata" to JsonObject(mapOf("type" to JsonPrimitive("object")))
67+
)
68+
)
69+
)
70+
71+
override val description: String = """Transforms a feature into markdown format with YAML frontmatter.
72+
73+
This tool retrieves a feature and all its sections, then renders them as a markdown document
74+
with YAML frontmatter containing feature metadata. The output is suitable for:
75+
- File export and documentation generation
76+
- Systems that can render markdown directly
77+
- Version control and diff-friendly storage
78+
- Human-readable feature archives
79+
80+
The markdown output includes:
81+
- YAML frontmatter with feature metadata (id, name, status, priority, tags, dates)
82+
- Feature summary as the first content paragraph
83+
- All sections rendered according to their content format (markdown, code, JSON, plain text)
84+
85+
For inspecting feature details in structured JSON format, use get_feature instead.
86+
"""
87+
88+
override val parameterSchema: Tool.Input = Tool.Input(
89+
properties = JsonObject(
90+
mapOf(
91+
"id" to JsonObject(
92+
mapOf(
93+
"type" to JsonPrimitive("string"),
94+
"description" to JsonPrimitive("The unique ID (UUID) of the feature to transform to markdown (e.g., '550e8400-e29b-41d4-a716-446655440000')")
95+
)
96+
)
97+
)
98+
),
99+
required = listOf("id")
100+
)
101+
102+
override fun validateParams(params: JsonElement) {
103+
// Validate required parameters
104+
val idStr = requireString(params, "id")
105+
try {
106+
UUID.fromString(idStr)
107+
} catch (_: IllegalArgumentException) {
108+
throw ToolValidationException("Invalid id format. Must be a valid UUID")
109+
}
110+
}
111+
112+
override suspend fun execute(params: JsonElement, context: ToolExecutionContext): JsonElement {
113+
logger.info("Executing feature_to_markdown tool")
114+
115+
try {
116+
// Extract parameters
117+
val idStr = requireString(params, "id")
118+
val featureId = UUID.fromString(idStr)
119+
120+
// Get the feature
121+
val featureResult = context.featureRepository().getById(featureId)
122+
123+
return when (featureResult) {
124+
is Result.Success -> {
125+
val feature = featureResult.data
126+
127+
// Get sections for the feature
128+
val sectionsResult = context.sectionRepository().getSectionsForEntity(EntityType.FEATURE, featureId)
129+
val sections = if (sectionsResult is Result.Success) sectionsResult.data else emptyList()
130+
131+
// Render to markdown
132+
val renderer = MarkdownRenderer()
133+
val markdown = renderer.renderFeature(feature, sections)
134+
135+
val data = buildJsonObject {
136+
put("markdown", markdown)
137+
put("featureId", featureId.toString())
138+
}
139+
140+
successResponse(data, "Feature transformed to markdown successfully")
141+
}
142+
143+
is Result.Error -> {
144+
if (featureResult.error is RepositoryError.NotFound) {
145+
errorResponse(
146+
message = "Feature not found",
147+
code = ErrorCodes.RESOURCE_NOT_FOUND,
148+
details = "No feature exists with ID $featureId"
149+
)
150+
} else {
151+
errorResponse(
152+
message = "Failed to retrieve feature",
153+
code = ErrorCodes.DATABASE_ERROR,
154+
details = featureResult.error.toString()
155+
)
156+
}
157+
}
158+
}
159+
} catch (e: ToolValidationException) {
160+
logger.warn("Validation error in feature_to_markdown: ${e.message}")
161+
return errorResponse(
162+
message = e.message ?: "Validation error",
163+
code = ErrorCodes.VALIDATION_ERROR
164+
)
165+
} catch (e: Exception) {
166+
logger.error("Error transforming feature to markdown", e)
167+
return errorResponse(
168+
message = "Failed to transform feature to markdown",
169+
code = ErrorCodes.INTERNAL_ERROR,
170+
details = e.message ?: "Unknown error"
171+
)
172+
}
173+
}
174+
}

0 commit comments

Comments
 (0)