You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@McpDescription("List all available KMP module templates with their variables. Use this before calling kmp_generate_module to discover templateId values and required variables.")
21
-
suspendfunlistTemplates(): List<TemplateDto> {
22
-
val project = currentCoroutineContext().project
26
+
suspendfunlistTemplates(): List<TemplateDTO> {
27
+
val project =resolveProject(context =currentCoroutineContext()) ?: mcpFail("No project found")
23
28
val templates =TemplateService.getInstance(project).getAllTemplates()
24
29
25
30
if (templates.isEmpty()) {
26
31
throwMcpExpectedError("No templates found. Create templates in .idea/kmp-templates/ or configure a custom path in Settings > KMP Module Templates.")
27
32
}
28
33
29
34
return templates.map { template ->
30
-
TemplateDto(
35
+
TemplateDTO(
31
36
id = template.id,
32
37
name = template.name,
33
38
description = template.description,
34
39
variables = template.variables.map { v ->
35
-
TemplateVariableDto(
40
+
TemplateVariableDTO(
36
41
name = v.name,
37
42
displayName = v.displayName,
38
43
description = v.description,
@@ -52,16 +57,16 @@ class KmpMcpToolset : McpToolset {
52
57
@McpDescription("Template ID from kmp_list_templates") templateId:String,
53
58
@McpDescription("Absolute filesystem path where the module will be created") targetPath:String,
54
59
@McpDescription("JSON object with variable values, e.g. {\"key\": \"value\"}") variables:String = "{}",
55
-
): GenerationResultDto {
56
-
val project = currentCoroutineContext().project
60
+
): GenerationResultDTO {
61
+
val project =resolveProject(context =currentCoroutineContext()) ?: mcpFail("No project found")
57
62
val templateService =TemplateService.getInstance(project)
58
63
val generatorService =ModuleGeneratorService.getInstance(project)
59
64
60
65
val template = templateService.getTemplate(templateId)
61
66
?:throwMcpExpectedError("Template '$templateId' not found. Use kmp_list_templates to see available templates.")
62
67
63
68
val variablesMap =try {
64
-
if (variables.isBlank()|| variables =="{}") emptyMap()
0 commit comments