@axboot-mcp/mcp-server 1.0.0 → 1.0.6

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,17 +1,18 @@
1
1
  import * as fs from 'fs';
2
2
  import * as path from 'path';
3
+ import { execSync } from 'child_process';
3
4
 
4
5
  /**
5
6
  * SearchParams 코드 생성 도구
6
7
  * App.tsx에 직접 SearchParams를 추가합니다.
7
8
  */
8
9
  export interface GenerateSearchParamsParams {
9
- /** App.tsx 파일 경로 (절대 경로) - dtoPath를 사용하면 자동 감지 */
10
+ /** App.tsx 파일 경로 (절대 경로) - searchDtoPath를 사용하면 자동 감지 */
10
11
  appPath?: string;
11
12
  /** SearchParams 설정 */
12
13
  searchParams?: SearchParamsConfig;
13
- /** DTO 파일 경로 (절대 경로) - DTO를 분석해서 자동으로 SearchParams 생성 및 App.tsx 수정 */
14
- dtoPath?: string;
14
+ /** 검색용 DTO 파일 경로 (절대 경로) - DTO를 분석해서 자동으로 SearchParams 생성 및 App.tsx 수정 */
15
+ searchDtoPath?: string;
15
16
  }
16
17
 
17
18
  export interface SearchParamsConfig {
@@ -100,15 +101,15 @@ interface DtoField {
100
101
  export async function generateSearchParams(params: GenerateSearchParamsParams): Promise<{
101
102
  content: Array<{ type: string; text: string }>;
102
103
  }> {
103
- const { dtoPath, searchParams } = params;
104
+ const { searchDtoPath, searchParams } = params;
104
105
 
105
106
  // 1. DTO 파싱
106
107
  let config: SearchParamsConfig | null = null;
107
108
  let dtoAnalysis = '';
108
109
  let detectedCodes: string[] = [];
109
110
 
110
- if (dtoPath) {
111
- const dtoResult = parseDtoFile(dtoPath);
111
+ if (searchDtoPath) {
112
+ const dtoResult = parseDtoFile(searchDtoPath);
112
113
  dtoAnalysis = dtoResult.analysis;
113
114
  config = dtoResult.searchParams;
114
115
  detectedCodes = dtoResult.detectedCodes;
@@ -133,12 +134,12 @@ export async function generateSearchParams(params: GenerateSearchParamsParams):
133
134
 
134
135
  // 2. App.tsx 경로 결정
135
136
  let appPath = params.appPath;
136
- if (!appPath && dtoPath) {
137
+ if (!appPath && searchDtoPath) {
137
138
  // DTO 경로에서 App.tsx 경로 추정
138
139
  // 예: /Users/kyle/Desktop/nh-fe-bo/src/services/@interface/dto/BannerSearch.ts
139
140
  // → /Users/kyle/Desktop/nh-fe-bo/src/pages/resources/banner/App.tsx
140
141
  const projectRoot = '/Users/kyle/Desktop/nh-fe-bo';
141
- const dtoName = path.basename(dtoPath, '.ts').replace('Search', '');
142
+ const dtoName = path.basename(searchDtoPath, '.ts').replace('Search', '');
142
143
  const pageName = dtoName.toLowerCase();
143
144
 
144
145
  const possiblePaths = [
@@ -177,7 +178,7 @@ export async function generateSearchParams(params: GenerateSearchParamsParams):
177
178
  dtoAnalysis,
178
179
  appPath,
179
180
  modifications,
180
- message: generateSuccessMessage(dtoPath, finalConfig, appPath),
181
+ message: generateSuccessMessage(searchDtoPath, finalConfig, appPath),
181
182
  }),
182
183
  }],
183
184
  };
@@ -186,7 +187,7 @@ export async function generateSearchParams(params: GenerateSearchParamsParams):
186
187
  /**
187
188
  * DTO 파일 파싱
188
189
  */
189
- function parseDtoFile(dtoPath: string): {
190
+ function parseDtoFile(searchDtoPath: string): {
190
191
  fields: DtoField[];
191
192
  analysis: string;
192
193
  searchParams: SearchParamsConfig;
@@ -194,11 +195,11 @@ function parseDtoFile(dtoPath: string): {
194
195
  } {
195
196
  let content = '';
196
197
  try {
197
- content = fs.readFileSync(dtoPath, 'utf-8');
198
+ content = fs.readFileSync(searchDtoPath, 'utf-8');
198
199
  } catch (e) {
199
200
  return {
200
201
  fields: [],
201
- analysis: `DTO 파일을 읽을 수 없습니다: ${dtoPath}`,
202
+ analysis: `DTO 파일을 읽을 수 없습니다: ${searchDtoPath}`,
202
203
  searchParams: {},
203
204
  detectedCodes: [],
204
205
  };
@@ -517,6 +518,16 @@ async function modifyAppTsx(appPath: string, config: SearchParamsConfig): Promis
517
518
  fs.writeFileSync(appPath, content, 'utf-8');
518
519
  console.error(`[MCP] App.tsx 수정 완료: ${appPath}`);
519
520
 
521
+ // ESLint 실행
522
+ try {
523
+ const appDir = path.dirname(appPath);
524
+ execSync(`npx eslint "${appPath}" --fix`, { cwd: appDir, stdio: 'pipe' });
525
+ console.error(`[MCP] ESLint 실행 완료: ${appPath}`);
526
+ modifications.push('ESLint 실행 완료');
527
+ } catch (e) {
528
+ console.error(`[MCP] ESLint 실행 실패 (무시): ${e}`);
529
+ }
530
+
520
531
  return modifications;
521
532
  }
522
533
 
@@ -671,15 +682,15 @@ function generateSearchParamsJsx(): string {
671
682
  * 성공 메시지 생성
672
683
  */
673
684
  function generateSuccessMessage(
674
- dtoPath: string | undefined,
685
+ searchDtoPath: string | undefined,
675
686
  config: SearchParamsConfig,
676
687
  appPath: string | undefined
677
688
  ): string {
678
689
  let message = '# ✅ SearchParams 자동 생성 완료\n\n';
679
690
 
680
- if (dtoPath) {
691
+ if (searchDtoPath) {
681
692
  message += `## DTO 파일\n`;
682
- message += `\`${dtoPath}\`\n\n`;
693
+ message += `\`${searchDtoPath}\`\n\n`;
683
694
  }
684
695
 
685
696
  message += `## App.tsx 수정 완료\n`;