@mandujs/mcp 0.37.1 → 0.37.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,49 +1,13 @@
1
- import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
- import {
3
- validateSlotConstraints,
4
- DEFAULT_SLOT_CONSTRAINTS,
5
- API_SLOT_CONSTRAINTS,
6
- READONLY_SLOT_CONSTRAINTS,
7
- type SlotConstraints,
8
- } from "@mandujs/core";
9
-
10
- export const slotValidationToolDefinitions: Tool[] = [
11
- {
12
- name: "mandu.slot.validate",
13
- description:
14
- "Validate a slot file against semantic constraints (lines, complexity, patterns, imports).",
15
- annotations: {
16
- readOnlyHint: true,
17
- },
18
- inputSchema: {
19
- type: "object",
20
- properties: {
21
- file: {
22
- type: "string",
23
- description: "Path to the slot file to validate",
24
- },
25
- preset: {
26
- type: "string",
27
- enum: ["default", "api", "readonly"],
28
- description: "Constraint preset to use (default: 'default')",
29
- },
30
- constraints: {
31
- type: "object",
32
- description: "Custom constraints (overrides preset)",
33
- properties: {
34
- maxLines: { type: "number" },
35
- maxCyclomaticComplexity: { type: "number" },
36
- requiredPatterns: { type: "array", items: { type: "string" } },
37
- forbiddenPatterns: { type: "array", items: { type: "string" } },
38
- allowedImports: { type: "array", items: { type: "string" } },
39
- },
40
- },
41
- },
42
- required: ["file"],
43
- },
44
- },
45
- {
46
- name: "mandu.slot.constraints",
1
+ import type { Tool } from "@modelcontextprotocol/sdk/types.js";
2
+ import {
3
+ DEFAULT_SLOT_CONSTRAINTS,
4
+ API_SLOT_CONSTRAINTS,
5
+ READONLY_SLOT_CONSTRAINTS,
6
+ } from "@mandujs/core";
7
+
8
+ export const slotValidationToolDefinitions: Tool[] = [
9
+ {
10
+ name: "mandu.slot.constraints",
47
11
  description:
48
12
  "Get recommended slot constraint presets (default, api, readonly).",
49
13
  annotations: {
@@ -63,79 +27,10 @@ export const slotValidationToolDefinitions: Tool[] = [
63
27
  },
64
28
  ];
65
29
 
66
- export function slotValidationTools(projectRoot: string) {
67
- const handlers: Record<string, (args: Record<string, unknown>) => Promise<unknown>> = {
68
- "mandu.slot.validate": async (args: Record<string, unknown>) => {
69
- const { file, preset, constraints: customConstraints } = args as {
70
- file: string;
71
- preset?: "default" | "api" | "readonly";
72
- constraints?: SlotConstraints;
73
- };
74
-
75
- if (!file) {
76
- return {
77
- error: "File path is required",
78
- tip: "Provide the path to the slot file to validate",
79
- };
80
- }
81
-
82
- // 프리셋 선택
83
- let constraints: SlotConstraints;
84
- if (customConstraints) {
85
- constraints = customConstraints;
86
- } else {
87
- switch (preset) {
88
- case "api":
89
- constraints = API_SLOT_CONSTRAINTS;
90
- break;
91
- case "readonly":
92
- constraints = READONLY_SLOT_CONSTRAINTS;
93
- break;
94
- default:
95
- constraints = DEFAULT_SLOT_CONSTRAINTS;
96
- }
97
- }
98
-
99
- // 파일 경로 정규화 및 보안 검증 (LFI 방지)
100
- const path = await import("path");
101
- const rawPath = file.startsWith("/") || file.includes(":")
102
- ? file
103
- : path.join(projectRoot, file);
104
- const filePath = path.normalize(path.resolve(rawPath));
105
- const normalizedRoot = path.normalize(path.resolve(projectRoot));
106
-
107
- // 경로가 프로젝트 루트 내에 있는지 검증
108
- if (!filePath.startsWith(normalizedRoot)) {
109
- return {
110
- error: "Access denied: File path is outside project root",
111
- tip: "Only files within the project directory can be validated",
112
- requestedPath: file,
113
- projectRoot: projectRoot,
114
- };
115
- }
116
-
117
- const result = await validateSlotConstraints(filePath, constraints);
118
-
119
- return {
120
- valid: result.valid,
121
- file: result.filePath,
122
- stats: result.stats,
123
- violations: result.violations.map((v) => ({
124
- type: v.type,
125
- severity: v.severity,
126
- message: v.message,
127
- suggestion: v.suggestion,
128
- line: v.line,
129
- })),
130
- suggestions: result.suggestions,
131
- constraintsUsed: constraints,
132
- tip: result.valid
133
- ? "✅ Slot passes all constraints"
134
- : "Fix violations before deployment. Use mandu.slot.constraints for guidance.",
135
- };
136
- },
137
-
138
- "mandu.slot.constraints": async (args: Record<string, unknown>) => {
30
+ export function slotValidationTools(projectRoot: string) {
31
+ void projectRoot;
32
+ const handlers: Record<string, (args: Record<string, unknown>) => Promise<unknown>> = {
33
+ "mandu.slot.constraints": async (args: Record<string, unknown>) => {
139
34
  const { preset } = args as { preset?: "default" | "api" | "readonly" };
140
35
 
141
36
  const presets = {
@@ -189,11 +84,10 @@ Mandu.filling()
189
84
  `.trim(),
190
85
  };
191
86
  },
192
- };
193
-
194
- // Backward-compatible aliases
195
- handlers["mandu_validate_slot"] = handlers["mandu.slot.validate"];
196
- handlers["mandu_get_slot_constraints"] = handlers["mandu.slot.constraints"];
197
-
87
+ };
88
+
89
+ // Backward-compatible aliases
90
+ handlers["mandu_get_slot_constraints"] = handlers["mandu.slot.constraints"];
91
+
198
92
  return handlers;
199
93
  }