@isnow890/naver-search-mcp 1.0.0 → 1.0.2

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.
package/README.md CHANGED
@@ -6,6 +6,26 @@
6
6
 
7
7
  MCP server for Naver Search API and DataLab API integration, enabling comprehensive search across various Naver services and data trend analysis.
8
8
 
9
+ #### Version History
10
+
11
+ ###### 1.0.2 (2025-04-26)
12
+
13
+ - README updated: cafe article search tool and version history section improved
14
+
15
+ ###### 1.0.1 (2025-04-26)
16
+
17
+ - Cafe article search feature added
18
+ - Shopping category info added to zod
19
+ - Source code refactored
20
+
21
+ ###### 1.0.0 (2025-04-08)
22
+
23
+ - Initial release
24
+
25
+ #### Information
26
+
27
+ **If you want to install the MCP via npm, do NOT use @mseep/server-naver-search (https://www.npmjs.com/package/@mseep/server-naver-search). That package is a copy of my work and was published without my permission. The npx version of that package is also broken and will not work properly. Please use this official package instead.**
28
+
9
29
  #### Prerequisites
10
30
 
11
31
  - Naver Developers API Key (Client ID and Secret)
@@ -30,6 +50,7 @@ MCP server for Naver Search API and DataLab API integration, enabling comprehens
30
50
  - **search_webkr**: Search Naver web documents
31
51
  - **search_news**: Search Naver news
32
52
  - **search_blog**: Search Naver blogs
53
+ - **search_cafearticle**: Search Naver cafe articles
33
54
  - **search_shop**: Search Naver shopping
34
55
  - **search_image**: Search Naver images
35
56
  - **search_kin**: Search Naver KnowledgeiN
@@ -99,7 +120,7 @@ export NAVER_CLIENT_SECRET=your_client_secret
99
120
  #### Run with NPX
100
121
 
101
122
  ```bash
102
- npx @modelcontextprotocol/server-naver-search
123
+ npx @isnow890/naver-search-mcp
103
124
  ```
104
125
 
105
126
  #### Run with Docker
@@ -111,7 +132,7 @@ docker run -i --rm \
111
132
  mcp/naver-search
112
133
  ```
113
134
 
114
- ## Cursor Desktop Configuration
135
+ ## Claude Desktop Configuration
115
136
 
116
137
  Add to `claude_desktop_config.json`:
117
138
 
@@ -120,7 +141,26 @@ Add to `claude_desktop_config.json`:
120
141
  "mcpServers": {
121
142
  "naver-search": {
122
143
  "command": "npx",
123
- "args": ["-y", "@modelcontextprotocol/server-naver-search"],
144
+ "args": ["-y", "@isnow890/naver-search-mcp"],
145
+ "env": {
146
+ "NAVER_CLIENT_ID": "your_client_id",
147
+ "NAVER_CLIENT_SECRET": "your_client_secret"
148
+ }
149
+ }
150
+ }
151
+ }
152
+ ```
153
+
154
+ ## Cursor AI Configuration
155
+
156
+ Add to `mcp.json`:
157
+
158
+ ```json
159
+ {
160
+ "mcpServers": {
161
+ "naver-search": {
162
+ "command": "npx",
163
+ "args": ["-y", "@isnow890/naver-search-mcp"],
124
164
  "env": {
125
165
  "NAVER_CLIENT_ID": "your_client_id",
126
166
  "NAVER_CLIENT_SECRET": "your_client_secret"
@@ -151,6 +191,7 @@ For Docker:
151
191
  }
152
192
  }
153
193
  ```
194
+
154
195
  ## Build
155
196
 
156
197
  Docker build:
@@ -159,8 +200,6 @@ Docker build:
159
200
  docker build -t mcp/naver-search .
160
201
  ```
161
202
 
162
-
163
-
164
203
  ## License
165
204
 
166
205
  MIT License
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@isnow890/naver-search-mcp",
3
+ "version": "1.0.2",
4
+ "description": "Naver Search MCP Server",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "prebuild": "shx rm -rf dist",
12
+ "build": "tsc",
13
+ "prepare": "npm run build",
14
+ "watch": "tsc --watch",
15
+ "start": "node dist/src/index.js"
16
+ },
17
+ "engines": {
18
+ "node": ">=18"
19
+ },
20
+ "dependencies": {
21
+ "@modelcontextprotocol/sdk": "0.5.0",
22
+ "axios": "^1.6.7",
23
+ "zod": "^3.22.4",
24
+ "zod-to-json-schema": "^3.23.5",
25
+ "sharp": "^0.33.2",
26
+ "dotenv": "^16.4.5"
27
+ },
28
+ "devDependencies": {
29
+ "@types/node": "^22",
30
+ "shx": "^0.3.4",
31
+ "typescript": "^5.3.3"
32
+ },
33
+ "author": "isnow890",
34
+ "license": "MIT",
35
+ "bin": {
36
+ "naver-search-mcp": "dist/src/index.js"
37
+ },
38
+ "type": "module"
39
+ }
@@ -0,0 +1,30 @@
1
+ import axios from "axios";
2
+ export class NaverApiCoreClient {
3
+ constructor() {
4
+ this.searchBaseUrl = "https://openapi.naver.com/v1/search";
5
+ this.datalabBaseUrl = "https://openapi.naver.com/v1/datalab";
6
+ this.config = null;
7
+ }
8
+ initialize(config) {
9
+ this.config = config;
10
+ }
11
+ getHeaders(contentType = "application/json") {
12
+ if (!this.config)
13
+ throw new Error("NaverApiCoreClient is not initialized.");
14
+ return {
15
+ headers: {
16
+ "X-Naver-Client-Id": this.config.clientId,
17
+ "X-Naver-Client-Secret": this.config.clientSecret,
18
+ "Content-Type": contentType,
19
+ },
20
+ };
21
+ }
22
+ async get(url, params) {
23
+ const response = await axios.get(url, { params, ...this.getHeaders() });
24
+ return response.data;
25
+ }
26
+ async post(url, data) {
27
+ const response = await axios.post(url, data, this.getHeaders());
28
+ return response.data;
29
+ }
30
+ }
@@ -0,0 +1,100 @@
1
+ import { NaverApiCoreClient } from "./naver-api-core.client.js";
2
+ /**
3
+ * NaverSearchClient - 네이버 API 서비스를 위한 싱글톤 클라이언트
4
+ * 검색, 데이터랩 API 요청 처리
5
+ */
6
+ export class NaverSearchClient extends NaverApiCoreClient {
7
+ constructor() {
8
+ super();
9
+ }
10
+ /**
11
+ * 싱글톤 인스턴스 반환
12
+ */
13
+ static getInstance() {
14
+ if (!NaverSearchClient.instance) {
15
+ NaverSearchClient.instance = new NaverSearchClient();
16
+ }
17
+ return NaverSearchClient.instance;
18
+ }
19
+ /**
20
+ * API 자격 증명으로 클라이언트 초기화
21
+ */
22
+ initialize(config) {
23
+ this.config = config;
24
+ }
25
+ /**
26
+ * 네이버 검색 API 호출 (type별로)
27
+ * @param type 검색 타입(카테고리)
28
+ * @param params 검색 파라미터
29
+ */
30
+ async search(type, params) {
31
+ return this.get(`${this.searchBaseUrl}/${type}`, params);
32
+ }
33
+ /**
34
+ * 전문자료 검색 메서드
35
+ */
36
+ async searchAcademic(params) {
37
+ return this.get(`${this.searchBaseUrl}/doc`, params);
38
+ }
39
+ /**
40
+ * 지역 검색 메서드
41
+ */
42
+ async searchLocal(params) {
43
+ return this.get(`${this.searchBaseUrl}/local`, params);
44
+ }
45
+ /**
46
+ * 검색어 트렌드 분석 메서드
47
+ */
48
+ async searchTrend(params) {
49
+ return this.post(`${this.datalabBaseUrl}/search`, params);
50
+ }
51
+ /**
52
+ * 쇼핑 카테고리 트렌드 분석 메서드
53
+ */
54
+ async datalabShoppingCategory(params) {
55
+ return this.post(`${this.datalabBaseUrl}/shopping/categories`, params);
56
+ }
57
+ /**
58
+ * 쇼핑 기기별 트렌드 분석 메서드
59
+ */
60
+ async datalabShoppingByDevice(params) {
61
+ return this.post(`${this.datalabBaseUrl}/shopping/category/device`, params);
62
+ }
63
+ /**
64
+ * 쇼핑 성별 트렌드 분석 메서드
65
+ */
66
+ async datalabShoppingByGender(params) {
67
+ return this.post(`${this.datalabBaseUrl}/shopping/category/gender`, params);
68
+ }
69
+ /**
70
+ * 쇼핑 연령별 트렌드 분석 메서드
71
+ */
72
+ async datalabShoppingByAge(params) {
73
+ return this.post(`${this.datalabBaseUrl}/shopping/category/age`, params);
74
+ }
75
+ /**
76
+ * 쇼핑 키워드 트렌드 분석 메서드
77
+ */
78
+ async datalabShoppingKeywords(params) {
79
+ return this.post(`${this.datalabBaseUrl}/shopping/category/keywords`, params);
80
+ }
81
+ /**
82
+ * 쇼핑 키워드 기기별 트렌드 분석 메서드
83
+ */
84
+ async datalabShoppingKeywordByDevice(params) {
85
+ return this.post(`${this.datalabBaseUrl}/shopping/category/keyword/device`, params);
86
+ }
87
+ /**
88
+ * 쇼핑 키워드 성별 트렌드 분석 메서드
89
+ */
90
+ async datalabShoppingKeywordByGender(params) {
91
+ return this.post(`${this.datalabBaseUrl}/shopping/category/keyword/gender`, params);
92
+ }
93
+ /**
94
+ * 쇼핑 키워드 연령별 트렌드 분석 메서드
95
+ */
96
+ async datalabShoppingKeywordByAge(params) {
97
+ return this.post(`${this.datalabBaseUrl}/shopping/category/keyword/age`, params);
98
+ }
99
+ }
100
+ NaverSearchClient.instance = null;
@@ -1,20 +1,42 @@
1
- import { NaverSearchClient } from "../naver-search.client.js";
2
- // 클라이언트 인스턴스
1
+ import { NaverSearchClient } from "../clients/naver-search.client.js";
2
+ // 클라이언트 인스턴스 (싱글톤)
3
3
  const client = NaverSearchClient.getInstance();
4
+ /**
5
+ * 데이터랩 도구 핸들러 맵
6
+ * 각 도구 이름을 키로, 실행할 핸들러 함수를 값으로 가짐
7
+ * index.ts에서 도구 실행 분기 없이 바로 사용
8
+ */
9
+ export const datalabToolHandlers = {
10
+ datalab_search: (args) => handleSearchTrend(args), // 검색어 트렌드 분석
11
+ datalab_shopping_category: (args) => handleShoppingCategoryTrend(args), // 쇼핑 카테고리별 트렌드
12
+ datalab_shopping_by_device: (args) => handleShoppingByDeviceTrend(args), // 쇼핑 기기별 트렌드
13
+ datalab_shopping_by_gender: (args) => handleShoppingByGenderTrend(args), // 쇼핑 성별 트렌드
14
+ datalab_shopping_by_age: (args) => handleShoppingByAgeTrend(args), // 쇼핑 연령별 트렌드
15
+ datalab_shopping_keywords: (args) => handleShoppingKeywordsTrend(args), // 쇼핑 키워드 그룹 트렌드
16
+ datalab_shopping_keyword_by_device: (args) => handleShoppingKeywordByDeviceTrend(args), // 쇼핑 키워드 기기별 트렌드
17
+ datalab_shopping_keyword_by_gender: (args) => handleShoppingKeywordByGenderTrend(args), // 쇼핑 키워드 성별 트렌드
18
+ datalab_shopping_keyword_by_age: (args) => handleShoppingKeywordByAgeTrend(args), // 쇼핑 키워드 연령별 트렌드
19
+ };
4
20
  /**
5
21
  * 검색어 트렌드 핸들러
22
+ * 네이버 데이터랩 검색어 트렌드 분석 API 호출
23
+ * @param params DatalabSearch
6
24
  */
7
25
  export async function handleSearchTrend(params) {
8
26
  return client.searchTrend(params);
9
27
  }
10
28
  /**
11
29
  * 쇼핑 카테고리 트렌드 핸들러
30
+ * 네이버 데이터랩 쇼핑 카테고리별 트렌드 분석 API 호출
31
+ * @param params DatalabShopping
12
32
  */
13
33
  export async function handleShoppingCategoryTrend(params) {
14
34
  return client.datalabShoppingCategory(params);
15
35
  }
16
36
  /**
17
37
  * 쇼핑 기기별 트렌드 핸들러
38
+ * 네이버 데이터랩 쇼핑 기기별 트렌드 분석 API 호출
39
+ * @param params DatalabShoppingDevice
18
40
  */
19
41
  export async function handleShoppingByDeviceTrend(params) {
20
42
  return client.datalabShoppingByDevice({
@@ -27,6 +49,8 @@ export async function handleShoppingByDeviceTrend(params) {
27
49
  }
28
50
  /**
29
51
  * 쇼핑 성별 트렌드 핸들러
52
+ * 네이버 데이터랩 쇼핑 성별 트렌드 분석 API 호출
53
+ * @param params DatalabShoppingGender
30
54
  */
31
55
  export async function handleShoppingByGenderTrend(params) {
32
56
  return client.datalabShoppingByGender({
@@ -39,6 +63,8 @@ export async function handleShoppingByGenderTrend(params) {
39
63
  }
40
64
  /**
41
65
  * 쇼핑 연령별 트렌드 핸들러
66
+ * 네이버 데이터랩 쇼핑 연령별 트렌드 분석 API 호출
67
+ * @param params DatalabShoppingAge
42
68
  */
43
69
  export async function handleShoppingByAgeTrend(params) {
44
70
  return client.datalabShoppingByAge({
@@ -50,8 +76,9 @@ export async function handleShoppingByAgeTrend(params) {
50
76
  });
51
77
  }
52
78
  /**
53
- * 쇼핑 키워드 트렌드 핸들러
54
- * 복수 키워드 그룹을 지원합니다.
79
+ * 쇼핑 키워드 트렌드 핸들러 (복수 키워드 그룹 지원)
80
+ * 네이버 데이터랩 쇼핑 키워드 그룹 트렌드 분석 API 호출
81
+ * @param params DatalabShoppingKeywords
55
82
  */
56
83
  export async function handleShoppingKeywordsTrend(params) {
57
84
  // 키워드 배열을 네이버 API에 맞는 형식으로 변환
@@ -60,11 +87,13 @@ export async function handleShoppingKeywordsTrend(params) {
60
87
  endDate: params.endDate,
61
88
  timeUnit: params.timeUnit,
62
89
  category: params.category,
63
- keyword: params.keyword
90
+ keyword: params.keyword,
64
91
  });
65
92
  }
66
93
  /**
67
94
  * 쇼핑 키워드 기기별 트렌드 핸들러
95
+ * 네이버 데이터랩 쇼핑 키워드 기기별 트렌드 분석 API 호출
96
+ * @param params DatalabShoppingKeywordDevice
68
97
  */
69
98
  export async function handleShoppingKeywordByDeviceTrend(params) {
70
99
  return client.datalabShoppingKeywordByDevice({
@@ -78,6 +107,8 @@ export async function handleShoppingKeywordByDeviceTrend(params) {
78
107
  }
79
108
  /**
80
109
  * 쇼핑 키워드 성별 트렌드 핸들러
110
+ * 네이버 데이터랩 쇼핑 키워드 성별 트렌드 분석 API 호출
111
+ * @param params DatalabShoppingKeywordGender
81
112
  */
82
113
  export async function handleShoppingKeywordByGenderTrend(params) {
83
114
  return client.datalabShoppingKeywordByGender({
@@ -91,6 +122,8 @@ export async function handleShoppingKeywordByGenderTrend(params) {
91
122
  }
92
123
  /**
93
124
  * 쇼핑 키워드 연령별 트렌드 핸들러
125
+ * 네이버 데이터랩 쇼핑 키워드 연령별 트렌드 분석 API 호출
126
+ * @param params DatalabShoppingKeywordAge
94
127
  */
95
128
  export async function handleShoppingKeywordByAgeTrend(params) {
96
129
  return client.datalabShoppingKeywordByAge({
@@ -1,12 +1,20 @@
1
- import { NaverSearchClient } from "../naver-search.client.js";
1
+ import { NaverSearchClient } from "../clients/naver-search.client.js";
2
+ import { SearchArgsSchema } from "../schemas/search.schemas.js";
2
3
  // 클라이언트 인스턴스
3
4
  const client = NaverSearchClient.getInstance();
4
- /**
5
- * 기본 검색 핸들러
6
- */
7
- export async function handleSearch(params) {
8
- return client.search({ ...params });
9
- }
5
+ export const searchToolHandlers = {
6
+ search_webkr: (args) => handleWebKrSearch(SearchArgsSchema.parse(args)),
7
+ search_news: (args) => handleNewsSearch(SearchArgsSchema.parse(args)),
8
+ search_blog: (args) => handleBlogSearch(SearchArgsSchema.parse(args)),
9
+ search_shop: (args) => handleShopSearch(SearchArgsSchema.parse(args)),
10
+ search_image: (args) => handleImageSearch(SearchArgsSchema.parse(args)),
11
+ search_kin: (args) => handleKinSearch(SearchArgsSchema.parse(args)),
12
+ search_book: (args) => handleBookSearch(SearchArgsSchema.parse(args)),
13
+ search_encyc: (args) => handleEncycSearch(SearchArgsSchema.parse(args)),
14
+ search_academic: (args) => handleAcademicSearch(SearchArgsSchema.parse(args)),
15
+ search_local: (args) => handleLocalSearch(args),
16
+ search_cafearticle: (args) => handleCafeArticleSearch(args),
17
+ };
10
18
  /**
11
19
  * 전문자료 검색 핸들러
12
20
  */
@@ -17,25 +25,25 @@ export async function handleAcademicSearch(params) {
17
25
  * 도서 검색 핸들러
18
26
  */
19
27
  export async function handleBookSearch(params) {
20
- return client.search({ type: "book", ...params });
28
+ return client.search("book", params);
21
29
  }
22
30
  /**
23
31
  * 지식백과 검색 핸들러
24
32
  */
25
33
  export async function handleEncycSearch(params) {
26
- return client.search({ type: "encyc", ...params });
34
+ return client.search("encyc", params);
27
35
  }
28
36
  /**
29
37
  * 이미지 검색 핸들러
30
38
  */
31
39
  export async function handleImageSearch(params) {
32
- return client.search({ type: "image", ...params });
40
+ return client.search("image", params);
33
41
  }
34
42
  /**
35
43
  * 지식iN 검색 핸들러
36
44
  */
37
45
  export async function handleKinSearch(params) {
38
- return client.search({ type: "kin", ...params });
46
+ return client.search("kin", params);
39
47
  }
40
48
  /**
41
49
  * 지역 검색 핸들러
@@ -47,33 +55,27 @@ export async function handleLocalSearch(params) {
47
55
  * 뉴스 검색 핸들러
48
56
  */
49
57
  export async function handleNewsSearch(params) {
50
- return client.search({ type: "news", ...params });
58
+ return client.search("news", params);
51
59
  }
52
60
  /**
53
61
  * 블로그 검색 핸들러
54
62
  */
55
63
  export async function handleBlogSearch(params) {
56
- return client.search({ type: "blog", ...params });
64
+ return client.search("blog", params);
57
65
  }
58
66
  /**
59
67
  * 쇼핑 검색 핸들러
60
68
  */
61
69
  export async function handleShopSearch(params) {
62
- return client.search({ type: "shop", ...params });
63
- }
64
- /**
65
- * 웹문서 검색 핸들러
66
- */
67
- export async function handleWebSearch(params) {
68
- return client.search({ type: "webkr", ...params });
70
+ return client.search("shop", params);
69
71
  }
70
72
  /**
71
73
  * 카페글 검색 핸들러
72
74
  */
73
75
  export async function handleCafeArticleSearch(params) {
74
- return client.search({ type: "cafearticle", ...params });
76
+ return client.search("cafearticle", params);
75
77
  }
76
78
  export async function handleWebKrSearch(args) {
77
79
  const client = NaverSearchClient.getInstance();
78
- return await client.search({ type: "webkr", ...args });
80
+ return await client.search("webkr", args);
79
81
  }
package/dist/src/index.js CHANGED
@@ -1,15 +1,14 @@
1
- #!/usr/bin/env node
2
1
  import * as dotenv from "dotenv";
3
- dotenv.config();
2
+ import pkg from "../package.json" with { type: "json" };
4
3
  import { Server } from "@modelcontextprotocol/sdk/server/index.js";
5
4
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
6
5
  import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
7
- import { NaverSearchClient } from "./naver-search.client.js";
8
- import { SearchArgsSchema } from "./schemas/search.schemas.js";
6
+ import { NaverSearchClient } from "./clients/naver-search.client.js";
9
7
  import { searchTools } from "./tools/search.tools.js";
10
8
  import { datalabTools } from "./tools/datalab.tools.js";
11
- import { handleAcademicSearch, handleBlogSearch, handleBookSearch, handleEncycSearch, handleImageSearch, handleKinSearch, handleLocalSearch, handleNewsSearch, handleShopSearch, handleWebKrSearch, } from "./handlers/search.handlers.js";
12
- import { handleSearchTrend, handleShoppingByAgeTrend, handleShoppingByDeviceTrend, handleShoppingByGenderTrend, handleShoppingCategoryTrend, handleShoppingKeywordByAgeTrend, handleShoppingKeywordByDeviceTrend, handleShoppingKeywordByGenderTrend, handleShoppingKeywordsTrend, } from "./handlers/datalab.handlers.js";
9
+ import { searchToolHandlers } from "./handlers/search.handlers.js";
10
+ import { datalabToolHandlers } from "./handlers/datalab.handlers.js";
11
+ dotenv.config();
13
12
  // 환경 변수 유효성 검사
14
13
  const NAVER_CLIENT_ID = process.env.NAVER_CLIENT_ID;
15
14
  const NAVER_CLIENT_SECRET = process.env.NAVER_CLIENT_SECRET;
@@ -26,7 +25,7 @@ client.initialize({
26
25
  // MCP 서버 인스턴스 생성
27
26
  const server = new Server({
28
27
  name: "naver-search",
29
- version: "1.0.0",
28
+ version: pkg.version,
30
29
  }, {
31
30
  capabilities: {
32
31
  tools: {},
@@ -38,6 +37,10 @@ server.setRequestHandler(ListToolsRequestSchema, async () => {
38
37
  tools: [...searchTools, ...datalabTools],
39
38
  };
40
39
  });
40
+ const toolHandlers = {
41
+ ...searchToolHandlers,
42
+ ...datalabToolHandlers,
43
+ };
41
44
  // 에러 응답 헬퍼 함수
42
45
  function createErrorResponse(error) {
43
46
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -55,70 +58,10 @@ server.setRequestHandler(CallToolRequestSchema, async (request) => {
55
58
  if (!args) {
56
59
  throw new Error("Arguments are required");
57
60
  }
58
- let result;
59
- switch (name) {
60
- // 검색 API
61
- case "search_webkr":
62
- result = await handleWebKrSearch(SearchArgsSchema.parse(args));
63
- break;
64
- case "search_news":
65
- result = await handleNewsSearch(SearchArgsSchema.parse(args));
66
- break;
67
- case "search_blog":
68
- result = await handleBlogSearch(SearchArgsSchema.parse(args));
69
- break;
70
- case "search_shop":
71
- result = await handleShopSearch(SearchArgsSchema.parse(args));
72
- break;
73
- case "search_image":
74
- result = await handleImageSearch(SearchArgsSchema.parse(args));
75
- break;
76
- case "search_kin":
77
- result = await handleKinSearch(SearchArgsSchema.parse(args));
78
- break;
79
- case "search_book":
80
- result = await handleBookSearch(SearchArgsSchema.parse(args));
81
- break;
82
- case "search_encyc":
83
- result = await handleEncycSearch(SearchArgsSchema.parse(args));
84
- break;
85
- case "search_academic":
86
- result = await handleAcademicSearch(SearchArgsSchema.parse(args));
87
- break;
88
- case "search_local":
89
- result = await handleLocalSearch(args);
90
- break;
91
- // 데이터랩 API
92
- case "datalab_search":
93
- result = await handleSearchTrend(args);
94
- break;
95
- case "datalab_shopping_category":
96
- result = await handleShoppingCategoryTrend(args);
97
- break;
98
- case "datalab_shopping_by_device":
99
- result = await handleShoppingByDeviceTrend(args);
100
- break;
101
- case "datalab_shopping_by_gender":
102
- result = await handleShoppingByGenderTrend(args);
103
- break;
104
- case "datalab_shopping_by_age":
105
- result = await handleShoppingByAgeTrend(args);
106
- break;
107
- case "datalab_shopping_keywords":
108
- result = await handleShoppingKeywordsTrend(args);
109
- break;
110
- case "datalab_shopping_keyword_by_device":
111
- result = await handleShoppingKeywordByDeviceTrend(args);
112
- break;
113
- case "datalab_shopping_keyword_by_gender":
114
- result = await handleShoppingKeywordByGenderTrend(args);
115
- break;
116
- case "datalab_shopping_keyword_by_age":
117
- result = await handleShoppingKeywordByAgeTrend(args);
118
- break;
119
- default:
120
- throw new Error(`Unknown tool: ${name}`);
121
- }
61
+ const handler = toolHandlers[name];
62
+ if (!handler)
63
+ throw new Error(`Unknown tool: ${name}`);
64
+ const result = await handler(args);
122
65
  console.error(`Tool ${name} executed successfully`);
123
66
  return {
124
67
  content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
@@ -1,17 +1,47 @@
1
1
  import { z } from "zod";
2
- // 기본 검색 파라미터 스키마
2
+ // 네이버 검색 타입(카테고리)
3
+ export const NaverSearchTypeSchema = z.enum([
4
+ "news",
5
+ "encyc",
6
+ "blog",
7
+ "shop",
8
+ "webkr",
9
+ "image",
10
+ "doc",
11
+ "kin",
12
+ "book",
13
+ "cafearticle",
14
+ "local",
15
+ ]);
16
+ // 네이버 검색 공통 파라미터
3
17
  export const SearchArgsSchema = z.object({
4
- query: z.string().describe("Search query"),
5
- display: z
6
- .number()
7
- .optional()
8
- .describe("Number of results to display (default: 10)"),
9
- start: z
10
- .number()
11
- .optional()
12
- .describe("Start position of search results (default: 1)"),
18
+ query: z.string().describe("검색어"),
19
+ display: z.number().optional().describe("한 번에 가져올 결과 수 (기본 10)"),
20
+ start: z.number().optional().describe("검색 시작 위치 (기본 1)"),
13
21
  sort: z
14
22
  .enum(["sim", "date"])
15
23
  .optional()
16
- .describe("Sort method (sim: similarity, date: date)"),
24
+ .describe("정렬 방식 (sim: 유사도, date: 날짜순)"),
25
+ });
26
+ // 네이버 API 인증 정보
27
+ export const NaverSearchConfigSchema = z.object({
28
+ clientId: z.string().describe("네이버 개발자센터에서 발급받은 Client ID"),
29
+ clientSecret: z
30
+ .string()
31
+ .describe("네이버 개발자센터에서 발급받은 Client Secret"),
32
+ });
33
+ // 전문자료(논문 등) 검색 파라미터
34
+ export const NaverDocumentSearchParamsSchema = z.object({
35
+ query: z.string().describe("검색어"),
36
+ display: z.number().optional().describe("한 번에 가져올 결과 수 (최대 100)"),
37
+ start: z.number().optional().describe("검색 시작 위치 (최대 1000)"),
38
+ });
39
+ // 지역 검색 파라미터
40
+ export const NaverLocalSearchParamsSchema = SearchArgsSchema.extend({
41
+ sort: z
42
+ .enum(["random", "comment"])
43
+ .optional()
44
+ .describe("정렬 방식 (random: 정확도순, comment: 리뷰 많은순)"),
45
+ display: z.number().optional().describe("한 번에 가져올 결과 수 (최대 5)"),
46
+ start: z.number().optional().describe("검색 시작 위치 (최대 1)"),
17
47
  });
@@ -1,6 +1,5 @@
1
1
  import { zodToJsonSchema } from "zod-to-json-schema";
2
- import { SearchArgsSchema } from "../schemas/search.schemas.js";
3
- import { NaverLocalSearchParamsSchema } from "../types/naver-search.types.js";
2
+ import { SearchArgsSchema, NaverLocalSearchParamsSchema, } from "../schemas/search.schemas.js";
4
3
  /**
5
4
  * 검색 관련 도구 정의
6
5
  */
@@ -55,4 +54,9 @@ export const searchTools = [
55
54
  description: "Perform a search on Naver Local. (네이버 지역 검색)",
56
55
  inputSchema: zodToJsonSchema(NaverLocalSearchParamsSchema),
57
56
  },
57
+ {
58
+ name: "search_cafearticle",
59
+ description: "Perform a search on Naver Cafe Articles. (네이버 카페글 검색)",
60
+ inputSchema: zodToJsonSchema(SearchArgsSchema),
61
+ },
58
62
  ];
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@isnow890/naver-search-mcp",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Naver Search MCP Server",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -1,155 +0,0 @@
1
- import axios from "axios";
2
- /**
3
- * NaverSearchClient - 네이버 API 서비스를 위한 싱글톤 클라이언트
4
- * 검색, 데이터랩 API 요청 처리
5
- */
6
- export class NaverSearchClient {
7
- constructor() {
8
- this.searchBaseUrl = "https://openapi.naver.com/v1/search";
9
- this.datalabBaseUrl = "https://openapi.naver.com/v1/datalab";
10
- this.config = null;
11
- }
12
- /**
13
- * 싱글톤 인스턴스 반환
14
- */
15
- static getInstance() {
16
- if (!NaverSearchClient.instance) {
17
- NaverSearchClient.instance = new NaverSearchClient();
18
- }
19
- return NaverSearchClient.instance;
20
- }
21
- /**
22
- * API 자격 증명으로 클라이언트 초기화
23
- */
24
- initialize(config) {
25
- this.config = config;
26
- }
27
- /**
28
- * API 요청에 필요한 헤더 생성
29
- * @throws 클라이언트가 초기화되지 않은 경우 에러 발생
30
- */
31
- getHeaders(contentType = "application/json") {
32
- if (!this.config) {
33
- throw new Error("NaverSearchClient is not initialized. Please call initialize() first.");
34
- }
35
- const headers = {
36
- "X-Naver-Client-Id": this.config.clientId,
37
- "X-Naver-Client-Secret": this.config.clientSecret,
38
- "Content-Type": contentType,
39
- };
40
- return { headers };
41
- }
42
- /**
43
- * 모든 검색 유형을 지원하는 일반 검색 메서드
44
- */
45
- async search(params) {
46
- const { type, ...searchParams } = params;
47
- const response = await axios.get(`${this.searchBaseUrl}/${type}`, {
48
- params: searchParams,
49
- ...this.getHeaders(),
50
- });
51
- return response.data;
52
- }
53
- /**
54
- * 전문자료 검색 메서드
55
- */
56
- async searchAcademic(params) {
57
- return this.search({ type: "doc", ...params });
58
- }
59
- /**
60
- * 지역 검색 메서드
61
- */
62
- async searchLocal(params) {
63
- const response = await axios.get(`${this.searchBaseUrl}/local`, {
64
- params: { ...params },
65
- ...this.getHeaders(),
66
- });
67
- return response.data;
68
- }
69
- /**
70
- * 검색어 트렌드 분석 메서드
71
- */
72
- async searchTrend(params) {
73
- return this.post("datalab", "/search", params);
74
- }
75
- /**
76
- * 쇼핑 카테고리 트렌드 분석 메서드
77
- */
78
- async datalabShoppingCategory(params) {
79
- return this.post("datalab", "/shopping/categories", params);
80
- }
81
- /**
82
- * 쇼핑 기기별 트렌드 분석 메서드
83
- */
84
- async datalabShoppingByDevice(params) {
85
- return this.post("datalab", "/shopping/category/device", params);
86
- }
87
- /**
88
- * 쇼핑 성별 트렌드 분석 메서드
89
- */
90
- async datalabShoppingByGender(params) {
91
- return this.post("datalab", "/shopping/category/gender", params);
92
- }
93
- /**
94
- * 쇼핑 연령별 트렌드 분석 메서드
95
- */
96
- async datalabShoppingByAge(params) {
97
- return this.post("datalab", "/shopping/category/age", params);
98
- }
99
- /**
100
- * 쇼핑 키워드 트렌드 분석 메서드
101
- */
102
- async datalabShoppingKeywords(params) {
103
- return this.post("datalab", "/shopping/category/keywords", params);
104
- }
105
- /**
106
- * 쇼핑 키워드 기기별 트렌드 분석 메서드
107
- */
108
- async datalabShoppingKeywordByDevice(params) {
109
- return this.post("datalab", "/shopping/category/keyword/device", params);
110
- }
111
- /**
112
- * 쇼핑 키워드 성별 트렌드 분석 메서드
113
- */
114
- async datalabShoppingKeywordByGender(params) {
115
- return this.post("datalab", "/shopping/category/keyword/gender", params);
116
- }
117
- /**
118
- * 쇼핑 키워드 연령별 트렌드 분석 메서드
119
- */
120
- async datalabShoppingKeywordByAge(params) {
121
- return this.post("datalab", "/shopping/category/keyword/age", params);
122
- }
123
- /**
124
- * POST 요청 처리 헬퍼 메서드
125
- * @param apiType - API 유형 (search, datalab)
126
- * @param endpoint - API 엔드포인트
127
- * @param data - 요청 데이터
128
- */
129
- async post(apiType, endpoint, data) {
130
- if (!this.config) {
131
- throw new Error("NaverSearchClient is not initialized. Please call initialize() first.");
132
- }
133
- const baseUrl = {
134
- search: this.searchBaseUrl,
135
- datalab: this.datalabBaseUrl,
136
- }[apiType];
137
- try {
138
- const headers = {
139
- "X-Naver-Client-Id": this.config.clientId,
140
- "X-Naver-Client-Secret": this.config.clientSecret,
141
- };
142
- const response = await axios.post(`${baseUrl}${endpoint}`, data, {
143
- headers,
144
- });
145
- return response.data;
146
- }
147
- catch (error) {
148
- if (axios.isAxiosError(error)) {
149
- throw new Error(`Naver API Error: ${error.response?.data?.errorMessage || error.message}`);
150
- }
151
- throw error;
152
- }
153
- }
154
- }
155
- NaverSearchClient.instance = null;
@@ -1,61 +0,0 @@
1
- import { z } from "zod";
2
- export const NaverSearchTypeSchema = z.enum([
3
- "news",
4
- "encyc",
5
- "blog",
6
- "shop",
7
- "webkr",
8
- "image",
9
- "doc",
10
- "kin",
11
- "book",
12
- "cafearticle",
13
- "local",
14
- ]);
15
- export const NaverSearchParamsSchema = z.object({
16
- query: z.string().describe("Search query"),
17
- display: z
18
- .number()
19
- .optional()
20
- .describe("Number of results to display (default: 10)"),
21
- start: z
22
- .number()
23
- .optional()
24
- .describe("Start position of search results (default: 1)"),
25
- sort: z
26
- .enum(["sim", "date"])
27
- .optional()
28
- .describe("Sort method (sim: similarity, date: chronological)"),
29
- });
30
- export const NaverSearchConfigSchema = z.object({
31
- clientId: z.string().describe("Client ID issued by Naver Developer Center"),
32
- clientSecret: z
33
- .string()
34
- .describe("Client Secret issued by Naver Developer Center"),
35
- });
36
- // 전문자료 검색 파라미터 스키마
37
- export const NaverDocumentSearchParamsSchema = z.object({
38
- query: z.string().describe("Search query"),
39
- display: z
40
- .number()
41
- .optional()
42
- .describe("Number of results to display (default: 10, max: 100)"),
43
- start: z
44
- .number()
45
- .optional()
46
- .describe("Start position of search results (default: 1, max: 1000)"),
47
- });
48
- // 지역 검색 파라미터 스키마
49
- export const NaverLocalSearchParamsSchema = NaverSearchParamsSchema.extend({
50
- sort: z.enum(["random", "comment"])
51
- .optional()
52
- .describe("Sort method (random: accuracy, comment: review count)"),
53
- display: z
54
- .number()
55
- .optional()
56
- .describe("Number of results to display (default: 1, max: 5)"),
57
- start: z
58
- .number()
59
- .optional()
60
- .describe("Start position of search results (default: 1, max: 1)"),
61
- });
@@ -1,61 +0,0 @@
1
- import sharp from "sharp";
2
- export class ImageProcessor {
3
- /**
4
- * base64 이미지를 압축하여 Buffer로 반환
5
- * @param base64Image base64로 인코딩된 이미지
6
- * @returns 압축된 이미지 Buffer
7
- */
8
- static async compressImage(base64Image) {
9
- const imageBuffer = Buffer.from(base64Image, "base64");
10
- // 이미지 크기가 2MB 이하면 그대로 반환
11
- if (imageBuffer.length <= this.MAX_SIZE) {
12
- return imageBuffer;
13
- }
14
- // 이미지 메타데이터 가져오기
15
- const metadata = await sharp(imageBuffer).metadata();
16
- // 압축 품질 계산 (2MB를 기준으로 비율 계산)
17
- const quality = Math.floor((this.MAX_SIZE / imageBuffer.length) * 100);
18
- // 이미지 크기 조절 계수 계산
19
- const scale = Math.sqrt(this.MAX_SIZE / imageBuffer.length);
20
- const width = Math.floor((metadata.width || 1000) * scale);
21
- const height = Math.floor((metadata.height || 1000) * scale);
22
- // 이미지 압축
23
- const compressedBuffer = await sharp(imageBuffer)
24
- .resize(width, height, {
25
- fit: "inside",
26
- withoutEnlargement: true,
27
- })
28
- .jpeg({
29
- quality: Math.max(quality, 60), // 최소 품질 60으로 제한
30
- progressive: true,
31
- })
32
- .toBuffer();
33
- // 압축 후에도 2MB를 초과하면 더 강하게 압축
34
- if (compressedBuffer.length > this.MAX_SIZE) {
35
- return await sharp(compressedBuffer)
36
- .jpeg({
37
- quality: 60,
38
- progressive: true,
39
- })
40
- .toBuffer();
41
- }
42
- return compressedBuffer;
43
- }
44
- /**
45
- * 이미지 크기 확인
46
- * @param imageBuffer 이미지 버퍼
47
- * @returns 이미지 크기가 2MB를 초과하는지 여부
48
- */
49
- static isOversize(imageBuffer) {
50
- return imageBuffer.length > this.MAX_SIZE;
51
- }
52
- /**
53
- * 이미지 메타데이터 확인
54
- * @param imageBuffer 이미지 버퍼
55
- * @returns 이미지 메타데이터
56
- */
57
- static async getMetadata(imageBuffer) {
58
- return await sharp(imageBuffer).metadata();
59
- }
60
- }
61
- ImageProcessor.MAX_SIZE = 2 * 1024 * 1024; // 2MB