@isnow890/naver-search-mcp 1.0.18 → 1.0.19
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/LICENSE +21 -21
- package/README.md +205 -187
- package/dist/package.json +9 -5
- package/dist/src/handlers/unified-search.handlers.js +144 -0
- package/dist/src/index.js +10 -7
- package/dist/src/schemas/unified-search.schemas.js +70 -0
- package/dist/src/tools/unified-search.tools.js +14 -0
- package/dist/tests/unified-search.handlers.test.js +194 -0
- package/dist/tests/unified-search.schemas.test.js +187 -0
- package/dist/tests/unified-search.tools.test.js +38 -0
- package/package.json +43 -39
- package/dist/src/naver-search.client.js +0 -155
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 isnow890
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 isnow890
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,187 +1,205 @@
|
|
|
1
|
-
# Naver Search MCP Server
|
|
2
|
-
|
|
3
|
-
[](README-ko.md)
|
|
4
|
-
[](https://smithery.ai/server/@isnow890/naver-search-mcp)
|
|
5
|
-
[](https://mcp.so/server/naver-search-mcp/isnow890)
|
|
6
|
-
|
|
7
|
-
MCP server for Naver Search API and DataLab API integration, enabling comprehensive search across various Naver services and data trend analysis.
|
|
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
|
-
|
|
29
|
-
#### Prerequisites
|
|
30
|
-
|
|
31
|
-
- Naver Developers API Key (Client ID and Secret)
|
|
32
|
-
- Node.js 18 or higher
|
|
33
|
-
- NPM 8 or higher
|
|
34
|
-
- Docker (optional, for container deployment)
|
|
35
|
-
|
|
36
|
-
#### Getting API Keys
|
|
37
|
-
|
|
38
|
-
1. Visit [Naver Developers](https://developers.naver.com/apps/#/register)
|
|
39
|
-
2. Click "Register Application"
|
|
40
|
-
3. Enter application name and select ALL of the following APIs:
|
|
41
|
-
- Search (for blog, news, book search, etc.)
|
|
42
|
-
- DataLab (Search Trends)
|
|
43
|
-
- DataLab (Shopping Insight)
|
|
44
|
-
4. Set the obtained Client ID and Client Secret as environment variables
|
|
45
|
-
|
|
46
|
-
## Tool Details
|
|
47
|
-
|
|
48
|
-
### Available tools:
|
|
49
|
-
|
|
50
|
-
- **search_webkr**: Search Naver web documents
|
|
51
|
-
- **search_news**: Search Naver news
|
|
52
|
-
- **search_blog**: Search Naver blogs
|
|
53
|
-
- **search_cafearticle**: Search Naver cafe articles
|
|
54
|
-
- **search_shop**: Search Naver shopping
|
|
55
|
-
- **search_image**: Search Naver images
|
|
56
|
-
- **search_kin**: Search Naver KnowledgeiN
|
|
57
|
-
- **search_book**: Search Naver books
|
|
58
|
-
- **search_encyc**: Search Naver encyclopedia
|
|
59
|
-
- **search_academic**: Search Naver academic papers
|
|
60
|
-
- **search_local**: Search Naver local places
|
|
61
|
-
- **datalab_search**: Analyze search term trends
|
|
62
|
-
- **datalab_shopping_category**: Analyze shopping category trends
|
|
63
|
-
- **datalab_shopping_by_device**: Analyze shopping trends by device
|
|
64
|
-
- **datalab_shopping_by_gender**: Analyze shopping trends by gender
|
|
65
|
-
- **datalab_shopping_by_age**: Analyze shopping trends by age group
|
|
66
|
-
- **datalab_shopping_keywords**: Analyze shopping keyword trends
|
|
67
|
-
- **datalab_shopping_keyword_by_device**: Analyze shopping keyword trends by device
|
|
68
|
-
- **datalab_shopping_keyword_by_gender**: Analyze shopping keyword trends by gender
|
|
69
|
-
- **datalab_shopping_keyword_by_age**: Analyze shopping keyword trends by age group
|
|
70
|
-
|
|
71
|
-
## Installation
|
|
72
|
-
|
|
73
|
-
### Option 1: Quick Install via Smithery (Recommended)
|
|
74
|
-
|
|
75
|
-
To install Naver Search MCP Server automatically via Smithery, use one of these commands based on your AI client:
|
|
76
|
-
|
|
77
|
-
For Claude Desktop:
|
|
78
|
-
|
|
79
|
-
```bash
|
|
80
|
-
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client claude
|
|
81
|
-
```
|
|
82
|
-
|
|
83
|
-
For Cursor:
|
|
84
|
-
|
|
85
|
-
```bash
|
|
86
|
-
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client cursor
|
|
87
|
-
```
|
|
88
|
-
|
|
89
|
-
For Windsurf:
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client windsurf
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
For Cline:
|
|
96
|
-
|
|
97
|
-
```bash
|
|
98
|
-
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client cline
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
The installer will prompt you for:
|
|
102
|
-
|
|
103
|
-
- NAVER_CLIENT_ID
|
|
104
|
-
- NAVER_CLIENT_SECRET
|
|
105
|
-
|
|
106
|
-
### Option 2: Manual Installation
|
|
107
|
-
|
|
108
|
-
#### Environment Variables
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
# Windows
|
|
112
|
-
set NAVER_CLIENT_ID=your_client_id
|
|
113
|
-
set NAVER_CLIENT_SECRET=your_client_secret
|
|
114
|
-
|
|
115
|
-
# Linux/Mac
|
|
116
|
-
export NAVER_CLIENT_ID=your_client_id
|
|
117
|
-
export NAVER_CLIENT_SECRET=your_client_secret
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
#### Run with NPX
|
|
121
|
-
|
|
122
|
-
```bash
|
|
123
|
-
npx @
|
|
124
|
-
```
|
|
125
|
-
|
|
126
|
-
#### Run with Docker
|
|
127
|
-
|
|
128
|
-
```bash
|
|
129
|
-
docker run -i --rm \
|
|
130
|
-
-e NAVER_CLIENT_ID=your_client_id \
|
|
131
|
-
-e NAVER_CLIENT_SECRET=your_client_secret \
|
|
132
|
-
mcp/naver-search
|
|
133
|
-
```
|
|
134
|
-
|
|
135
|
-
##
|
|
136
|
-
|
|
137
|
-
Add to `claude_desktop_config.json`:
|
|
138
|
-
|
|
139
|
-
```json
|
|
140
|
-
{
|
|
141
|
-
"mcpServers": {
|
|
142
|
-
"naver-search": {
|
|
143
|
-
"command": "npx",
|
|
144
|
-
"args": ["-y", "@
|
|
145
|
-
"env": {
|
|
146
|
-
"NAVER_CLIENT_ID": "your_client_id",
|
|
147
|
-
"NAVER_CLIENT_SECRET": "your_client_secret"
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
```
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
"
|
|
166
|
-
"
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
1
|
+
# Naver Search MCP Server
|
|
2
|
+
|
|
3
|
+
[](README-ko.md)
|
|
4
|
+
[](https://smithery.ai/server/@isnow890/naver-search-mcp)
|
|
5
|
+
[](https://mcp.so/server/naver-search-mcp/isnow890)
|
|
6
|
+
|
|
7
|
+
MCP server for Naver Search API and DataLab API integration, enabling comprehensive search across various Naver services and data trend analysis.
|
|
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
|
+
|
|
29
|
+
#### Prerequisites
|
|
30
|
+
|
|
31
|
+
- Naver Developers API Key (Client ID and Secret)
|
|
32
|
+
- Node.js 18 or higher
|
|
33
|
+
- NPM 8 or higher
|
|
34
|
+
- Docker (optional, for container deployment)
|
|
35
|
+
|
|
36
|
+
#### Getting API Keys
|
|
37
|
+
|
|
38
|
+
1. Visit [Naver Developers](https://developers.naver.com/apps/#/register)
|
|
39
|
+
2. Click "Register Application"
|
|
40
|
+
3. Enter application name and select ALL of the following APIs:
|
|
41
|
+
- Search (for blog, news, book search, etc.)
|
|
42
|
+
- DataLab (Search Trends)
|
|
43
|
+
- DataLab (Shopping Insight)
|
|
44
|
+
4. Set the obtained Client ID and Client Secret as environment variables
|
|
45
|
+
|
|
46
|
+
## Tool Details
|
|
47
|
+
|
|
48
|
+
### Available tools:
|
|
49
|
+
|
|
50
|
+
- **search_webkr**: Search Naver web documents
|
|
51
|
+
- **search_news**: Search Naver news
|
|
52
|
+
- **search_blog**: Search Naver blogs
|
|
53
|
+
- **search_cafearticle**: Search Naver cafe articles
|
|
54
|
+
- **search_shop**: Search Naver shopping
|
|
55
|
+
- **search_image**: Search Naver images
|
|
56
|
+
- **search_kin**: Search Naver KnowledgeiN
|
|
57
|
+
- **search_book**: Search Naver books
|
|
58
|
+
- **search_encyc**: Search Naver encyclopedia
|
|
59
|
+
- **search_academic**: Search Naver academic papers
|
|
60
|
+
- **search_local**: Search Naver local places
|
|
61
|
+
- **datalab_search**: Analyze search term trends
|
|
62
|
+
- **datalab_shopping_category**: Analyze shopping category trends
|
|
63
|
+
- **datalab_shopping_by_device**: Analyze shopping trends by device
|
|
64
|
+
- **datalab_shopping_by_gender**: Analyze shopping trends by gender
|
|
65
|
+
- **datalab_shopping_by_age**: Analyze shopping trends by age group
|
|
66
|
+
- **datalab_shopping_keywords**: Analyze shopping keyword trends
|
|
67
|
+
- **datalab_shopping_keyword_by_device**: Analyze shopping keyword trends by device
|
|
68
|
+
- **datalab_shopping_keyword_by_gender**: Analyze shopping keyword trends by gender
|
|
69
|
+
- **datalab_shopping_keyword_by_age**: Analyze shopping keyword trends by age group
|
|
70
|
+
|
|
71
|
+
## Installation
|
|
72
|
+
|
|
73
|
+
### Option 1: Quick Install via Smithery (Recommended)
|
|
74
|
+
|
|
75
|
+
To install Naver Search MCP Server automatically via Smithery, use one of these commands based on your AI client:
|
|
76
|
+
|
|
77
|
+
For Claude Desktop:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client claude
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
For Cursor:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client cursor
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
For Windsurf:
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client windsurf
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
For Cline:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
npx -y @smithery/cli@latest install @isnow890/naver-search-mcp --client cline
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
The installer will prompt you for:
|
|
102
|
+
|
|
103
|
+
- NAVER_CLIENT_ID
|
|
104
|
+
- NAVER_CLIENT_SECRET
|
|
105
|
+
|
|
106
|
+
### Option 2: Manual Installation
|
|
107
|
+
|
|
108
|
+
#### Environment Variables
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
# Windows
|
|
112
|
+
set NAVER_CLIENT_ID=your_client_id
|
|
113
|
+
set NAVER_CLIENT_SECRET=your_client_secret
|
|
114
|
+
|
|
115
|
+
# Linux/Mac
|
|
116
|
+
export NAVER_CLIENT_ID=your_client_id
|
|
117
|
+
export NAVER_CLIENT_SECRET=your_client_secret
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
#### Run with NPX
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
npx @isnow890/naver-search-mcp
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
#### Run with Docker
|
|
127
|
+
|
|
128
|
+
```bash
|
|
129
|
+
docker run -i --rm \
|
|
130
|
+
-e NAVER_CLIENT_ID=your_client_id \
|
|
131
|
+
-e NAVER_CLIENT_SECRET=your_client_secret \
|
|
132
|
+
mcp/naver-search
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Claude Desktop Configuration
|
|
136
|
+
|
|
137
|
+
Add to `claude_desktop_config.json`:
|
|
138
|
+
|
|
139
|
+
```json
|
|
140
|
+
{
|
|
141
|
+
"mcpServers": {
|
|
142
|
+
"naver-search": {
|
|
143
|
+
"command": "npx",
|
|
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"],
|
|
164
|
+
"env": {
|
|
165
|
+
"NAVER_CLIENT_ID": "your_client_id",
|
|
166
|
+
"NAVER_CLIENT_SECRET": "your_client_secret"
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
For Docker:
|
|
174
|
+
|
|
175
|
+
```json
|
|
176
|
+
{
|
|
177
|
+
"mcpServers": {
|
|
178
|
+
"naver-search": {
|
|
179
|
+
"command": "docker",
|
|
180
|
+
"args": [
|
|
181
|
+
"run",
|
|
182
|
+
"-i",
|
|
183
|
+
"--rm",
|
|
184
|
+
"-e",
|
|
185
|
+
"NAVER_CLIENT_ID=your_client_id",
|
|
186
|
+
"-e",
|
|
187
|
+
"NAVER_CLIENT_SECRET=your_client_secret",
|
|
188
|
+
"mcp/naver-search"
|
|
189
|
+
]
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
## Build
|
|
196
|
+
|
|
197
|
+
Docker build:
|
|
198
|
+
|
|
199
|
+
```bash
|
|
200
|
+
docker build -t mcp/naver-search .
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
## License
|
|
204
|
+
|
|
205
|
+
MIT License
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@isnow890/naver-search-mcp",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"description": "Naver Search MCP Server",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"build": "tsc",
|
|
13
13
|
"prepare": "npm run build",
|
|
14
14
|
"watch": "tsc --watch",
|
|
15
|
-
"start": "node dist/src/index.js"
|
|
15
|
+
"start": "node dist/src/index.js",
|
|
16
|
+
"test": "npx cross-env NODE_OPTIONS=--experimental-vm-modules npx jest"
|
|
16
17
|
},
|
|
17
18
|
"engines": {
|
|
18
19
|
"node": ">=18"
|
|
@@ -20,14 +21,17 @@
|
|
|
20
21
|
"dependencies": {
|
|
21
22
|
"@modelcontextprotocol/sdk": "1.10.2",
|
|
22
23
|
"axios": "^1.6.7",
|
|
23
|
-
"
|
|
24
|
-
"zod-to-json-schema": "^3.23.5",
|
|
24
|
+
"dotenv": "^16.4.5",
|
|
25
25
|
"sharp": "^0.33.2",
|
|
26
|
-
"
|
|
26
|
+
"zod": "^3.22.4",
|
|
27
|
+
"zod-to-json-schema": "^3.23.5"
|
|
27
28
|
},
|
|
28
29
|
"devDependencies": {
|
|
30
|
+
"@types/jest": "^29.5.14",
|
|
29
31
|
"@types/node": "^22",
|
|
32
|
+
"jest": "^29.7.0",
|
|
30
33
|
"shx": "^0.3.4",
|
|
34
|
+
"ts-jest": "^29.3.2",
|
|
31
35
|
"typescript": "^5.3.3"
|
|
32
36
|
},
|
|
33
37
|
"author": "isnow890",
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { searchToolHandlers } from "./search.handlers.js";
|
|
2
|
+
import { datalabToolHandlers } from "./datalab.handlers.js";
|
|
3
|
+
import { UnifiedSearchSchema } from "../schemas/unified-search.schemas.js";
|
|
4
|
+
/**
|
|
5
|
+
* 통합 검색 핸들러
|
|
6
|
+
* 일반 검색과 트렌드 검색을 통합하여 처리
|
|
7
|
+
* @param args 통합 검색 파라미터
|
|
8
|
+
* @returns 검색 결과
|
|
9
|
+
*/
|
|
10
|
+
export async function handleUnifiedSearch(args) {
|
|
11
|
+
// Zod를 사용하여 입력 파라미터 검증
|
|
12
|
+
const parsedArgs = UnifiedSearchSchema.parse(args);
|
|
13
|
+
// 검색 유형에 따라 처리
|
|
14
|
+
if (parsedArgs.searchType === "general") {
|
|
15
|
+
return handleGeneralSearch(parsedArgs);
|
|
16
|
+
}
|
|
17
|
+
else if (parsedArgs.searchType === "trend") {
|
|
18
|
+
return handleTrendSearch(parsedArgs);
|
|
19
|
+
}
|
|
20
|
+
throw new Error("지원하지 않는 검색 유형입니다.");
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* 일반 검색 핸들러
|
|
24
|
+
* @param search 일반 검색 파라미터
|
|
25
|
+
* @returns 검색 결과
|
|
26
|
+
*/
|
|
27
|
+
async function handleGeneralSearch(search) {
|
|
28
|
+
const { generalType, params } = search;
|
|
29
|
+
// 모든 검색 타입을 통합하여 검색하는 경우
|
|
30
|
+
if (generalType === "all") {
|
|
31
|
+
return handleAllGeneralSearch(params);
|
|
32
|
+
}
|
|
33
|
+
// 단일 검색 유형인 경우
|
|
34
|
+
const handlerKey = `search_${generalType}`;
|
|
35
|
+
const handler = searchToolHandlers[handlerKey];
|
|
36
|
+
if (!handler) {
|
|
37
|
+
throw new Error(`'${generalType}' 유형에 대한 검색 핸들러가 없습니다.`);
|
|
38
|
+
}
|
|
39
|
+
return handler(params);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 모든 일반 검색을 병렬로 수행하는 핸들러
|
|
43
|
+
* @param params 검색 파라미터
|
|
44
|
+
* @returns 모든 검색 결과 (검색 유형별로 객체 키 할당)
|
|
45
|
+
*/
|
|
46
|
+
async function handleAllGeneralSearch(params) {
|
|
47
|
+
// 모든 가능한 일반 검색 타입 (local과 다른 타입은 파라미터가 다르므로 주의)
|
|
48
|
+
// 검색할 타입 목록 (local은 파라미터가 다르므로 처리 방식 구분)
|
|
49
|
+
const generalTypes = [
|
|
50
|
+
"webkr", "news", "blog", "shop", "image",
|
|
51
|
+
"kin", "book", "encyc", "academic", "cafearticle"
|
|
52
|
+
];
|
|
53
|
+
// Promise 배열 생성 및 결과 수집
|
|
54
|
+
const searchPromises = generalTypes.map(type => {
|
|
55
|
+
const handlerKey = `search_${type}`;
|
|
56
|
+
const handler = searchToolHandlers[handlerKey];
|
|
57
|
+
return handler(params)
|
|
58
|
+
.then(result => ({ type, result }))
|
|
59
|
+
.catch(error => ({ type, error: error.message }));
|
|
60
|
+
});
|
|
61
|
+
// local 검색은 파라미터가 다르지만 동일 인터페이스로 처리
|
|
62
|
+
const localHandler = searchToolHandlers["search_local"];
|
|
63
|
+
searchPromises.push(localHandler(params)
|
|
64
|
+
.then(result => ({ type: "local", result }))
|
|
65
|
+
.catch(error => ({ type: "local", error: error.message })));
|
|
66
|
+
// 모든 검색 병렬 실행
|
|
67
|
+
const results = await Promise.all(searchPromises);
|
|
68
|
+
// 결과를 유형별로 객체로 변환
|
|
69
|
+
return results.reduce((acc, item) => {
|
|
70
|
+
const { type } = item;
|
|
71
|
+
if ('result' in item) {
|
|
72
|
+
acc[type] = item.result;
|
|
73
|
+
}
|
|
74
|
+
else if ('error' in item) {
|
|
75
|
+
acc[type] = { error: item.error };
|
|
76
|
+
}
|
|
77
|
+
return acc;
|
|
78
|
+
}, {});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 트렌드 검색 핸들러
|
|
82
|
+
* @param search 트렌드 검색 파라미터
|
|
83
|
+
* @returns 검색 결과
|
|
84
|
+
*/
|
|
85
|
+
async function handleTrendSearch(search) {
|
|
86
|
+
const { trendType, params } = search;
|
|
87
|
+
// 모든 트렌드 타입을 통합하여 검색하는 경우
|
|
88
|
+
if (trendType === "all") {
|
|
89
|
+
return handleAllTrendSearch(params);
|
|
90
|
+
}
|
|
91
|
+
// 단일 트렌드 검색 유형인 경우
|
|
92
|
+
const handlerKey = `datalab_${trendType}`;
|
|
93
|
+
const handler = datalabToolHandlers[handlerKey];
|
|
94
|
+
if (!handler) {
|
|
95
|
+
throw new Error(`'${trendType}' 유형에 대한 트렌드 검색 핸들러가 없습니다.`);
|
|
96
|
+
}
|
|
97
|
+
return handler(params);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* 모든 트렌드 검색을 병렬로 수행하는 핸들러
|
|
101
|
+
* @param params 트렌드 검색 파라미터
|
|
102
|
+
* @returns 모든 트렌드 검색 결과 (검색 유형별로 객체 키 할당)
|
|
103
|
+
*/
|
|
104
|
+
async function handleAllTrendSearch(params) {
|
|
105
|
+
// 파라미터 유형에 따라 가능한 트렌드 검색 타입 결정
|
|
106
|
+
const trendTypes = [
|
|
107
|
+
"search"
|
|
108
|
+
];
|
|
109
|
+
// 쇼핑 관련 트렌드는 category 파라미터가 있어야 함
|
|
110
|
+
if (params.category) {
|
|
111
|
+
trendTypes.push("shopping_category", "shopping_by_device", "shopping_by_gender", "shopping_by_age", "shopping_keywords");
|
|
112
|
+
// 키워드 관련 트렌드는 keyword 파라미터가 있어야 함
|
|
113
|
+
if (params.keyword) {
|
|
114
|
+
trendTypes.push("shopping_keyword_by_device", "shopping_keyword_by_gender", "shopping_keyword_by_age");
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Promise 배열 생성 및 결과 수집
|
|
118
|
+
const trendPromises = trendTypes.map(type => {
|
|
119
|
+
const handlerKey = `datalab_${type}`;
|
|
120
|
+
const handler = datalabToolHandlers[handlerKey];
|
|
121
|
+
// 일부 트렌드 검색은 파라미터 형식이 다를 수 있으므로
|
|
122
|
+
// 에러가 발생해도 다른 검색은 계속 진행하도록 처리
|
|
123
|
+
return handler(params)
|
|
124
|
+
.then((result) => ({ type, result }))
|
|
125
|
+
.catch((error) => ({ type, error: error.message }));
|
|
126
|
+
});
|
|
127
|
+
// 모든 트렌드 검색 병렬 실행
|
|
128
|
+
const results = await Promise.all(trendPromises);
|
|
129
|
+
// 결과를 유형별로 객체로 변환
|
|
130
|
+
return results.reduce((acc, item) => {
|
|
131
|
+
const { type } = item;
|
|
132
|
+
if ('result' in item) {
|
|
133
|
+
acc[type] = item.result;
|
|
134
|
+
}
|
|
135
|
+
else if ('error' in item) {
|
|
136
|
+
acc[type] = { error: item.error };
|
|
137
|
+
}
|
|
138
|
+
return acc;
|
|
139
|
+
}, {});
|
|
140
|
+
}
|
|
141
|
+
// 통합 검색 도구 핸들러 맵
|
|
142
|
+
export const unifiedSearchToolHandlers = {
|
|
143
|
+
unified_search: (args) => handleUnifiedSearch(args)
|
|
144
|
+
};
|
package/dist/src/index.js
CHANGED
|
@@ -6,10 +6,8 @@ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
|
6
6
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
7
7
|
import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
8
8
|
import { NaverSearchClient } from "./clients/naver-search.client.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { searchToolHandlers } from "./handlers/search.handlers.js";
|
|
12
|
-
import { datalabToolHandlers } from "./handlers/datalab.handlers.js";
|
|
9
|
+
import { unifiedSearchTools } from "./tools/unified-search.tools.js";
|
|
10
|
+
import { unifiedSearchToolHandlers } from "./handlers/unified-search.handlers.js";
|
|
13
11
|
dotenv.config();
|
|
14
12
|
console.error("[MCP] dotenv.config() 실행됨");
|
|
15
13
|
// 환경 변수 유효성 검사
|
|
@@ -41,12 +39,17 @@ console.error("[MCP] Server 인스턴스 생성 완료");
|
|
|
41
39
|
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
42
40
|
console.error("[MCP] ListToolsRequestSchema 핸들러 호출됨");
|
|
43
41
|
return {
|
|
44
|
-
tools: [
|
|
42
|
+
tools: [
|
|
43
|
+
//...searchTools,
|
|
44
|
+
// // ...datalabTools,
|
|
45
|
+
...unifiedSearchTools
|
|
46
|
+
],
|
|
45
47
|
};
|
|
46
48
|
});
|
|
47
49
|
const toolHandlers = {
|
|
48
|
-
...searchToolHandlers,
|
|
49
|
-
...datalabToolHandlers,
|
|
50
|
+
// ...searchToolHandlers,
|
|
51
|
+
// ...datalabToolHandlers,
|
|
52
|
+
...unifiedSearchToolHandlers,
|
|
50
53
|
};
|
|
51
54
|
// 에러 응답 헬퍼 함수
|
|
52
55
|
function createErrorResponse(error) {
|