smartmart-mcp 1.0.0
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/lib/api-client.js +88 -0
- package/lib/tools.js +336 -0
- package/package.json +47 -0
- package/server.js +92 -0
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart-Mart MCP API Client
|
|
3
|
+
* ロボティクス横断プラットフォーム(Smart-Mart / Physical AI Rental / Humanoid Mart / Humanoid Jobs)
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
export class SmartMartApiClient {
|
|
7
|
+
constructor(apiKey, baseUrl = 'https://smart-mart.jp') {
|
|
8
|
+
this.apiKey = apiKey;
|
|
9
|
+
this.baseUrl = baseUrl.replace(/\/$/, '');
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 認証ありリクエスト(標準)
|
|
14
|
+
*/
|
|
15
|
+
async request(action, params = {}) {
|
|
16
|
+
const url = `${this.baseUrl}/api/mcp.php`;
|
|
17
|
+
const response = await fetch(url, {
|
|
18
|
+
method: 'POST',
|
|
19
|
+
headers: {
|
|
20
|
+
'Authorization': `Bearer ${this.apiKey}`,
|
|
21
|
+
'Content-Type': 'application/json',
|
|
22
|
+
},
|
|
23
|
+
body: JSON.stringify({ action, params }),
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
const json = await response.json();
|
|
27
|
+
if (!response.ok || !json.success) {
|
|
28
|
+
throw new Error(json.message || `API error: ${response.status}`);
|
|
29
|
+
}
|
|
30
|
+
return json.data;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* ヘルスチェック(認証不要)
|
|
35
|
+
*/
|
|
36
|
+
async health() {
|
|
37
|
+
const url = `${this.baseUrl}/api/mcp.php`;
|
|
38
|
+
const response = await fetch(url, {
|
|
39
|
+
method: 'POST',
|
|
40
|
+
headers: { 'Content-Type': 'application/json' },
|
|
41
|
+
body: JSON.stringify({ action: 'health' }),
|
|
42
|
+
});
|
|
43
|
+
return response.json();
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ==========================================
|
|
47
|
+
// 商品検索 (5)
|
|
48
|
+
// ==========================================
|
|
49
|
+
|
|
50
|
+
async productsSearch(params) { return this.request('products.search', params); }
|
|
51
|
+
async productsDetail(slug) { return this.request('products.detail', { slug }); }
|
|
52
|
+
async productsCompare(slugs) { return this.request('products.compare', { slugs }); }
|
|
53
|
+
async categoriesList() { return this.request('categories.list'); }
|
|
54
|
+
async brandsList(params = {}) { return this.request('brands.list', params); }
|
|
55
|
+
|
|
56
|
+
// ==========================================
|
|
57
|
+
// レンタル (2)
|
|
58
|
+
// ==========================================
|
|
59
|
+
|
|
60
|
+
async rentalSearch(params) { return this.request('rental.search', params); }
|
|
61
|
+
async rentalAvailability(slug) { return this.request('rental.availability', { slug }); }
|
|
62
|
+
|
|
63
|
+
// ==========================================
|
|
64
|
+
// 購入・リース (2)
|
|
65
|
+
// ==========================================
|
|
66
|
+
|
|
67
|
+
async purchaseOptions(slug) { return this.request('purchase.options', { slug }); }
|
|
68
|
+
async leaseEstimate(slug, termMonths) { return this.request('lease.estimate', { slug, term_months: termMonths }); }
|
|
69
|
+
|
|
70
|
+
// ==========================================
|
|
71
|
+
// 買取査定 (1)
|
|
72
|
+
// ==========================================
|
|
73
|
+
|
|
74
|
+
async buybackEstimate(params) { return this.request('buyback.estimate', params); }
|
|
75
|
+
|
|
76
|
+
// ==========================================
|
|
77
|
+
// 求人 (2)
|
|
78
|
+
// ==========================================
|
|
79
|
+
|
|
80
|
+
async jobsSearch(params) { return this.request('jobs.search', params); }
|
|
81
|
+
async jobsByRobot(robotSlug) { return this.request('jobs.by_robot', { robot_slug: robotSlug }); }
|
|
82
|
+
|
|
83
|
+
// ==========================================
|
|
84
|
+
// ユーティリティ (1)
|
|
85
|
+
// ==========================================
|
|
86
|
+
|
|
87
|
+
async consultRequest(params) { return this.request('consult.request', params); }
|
|
88
|
+
}
|
package/lib/tools.js
ADDED
|
@@ -0,0 +1,336 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart-Mart MCP ツール定義 (14ツール)
|
|
3
|
+
*
|
|
4
|
+
* カテゴリ:
|
|
5
|
+
* 商品検索 (5): products.search / products.detail / products.compare / categories.list / brands.list
|
|
6
|
+
* レンタル (2): rental.search / rental.availability
|
|
7
|
+
* 購入・リース (2): purchase.options / lease.estimate
|
|
8
|
+
* 買取査定 (1): buyback.estimate
|
|
9
|
+
* 求人 (2): jobs.search / jobs.by_robot
|
|
10
|
+
* ユーティリティ (2): health / consult.request
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
export const TOOLS = [
|
|
14
|
+
// ============================================================
|
|
15
|
+
// ユーティリティ (2)
|
|
16
|
+
// ============================================================
|
|
17
|
+
{
|
|
18
|
+
name: 'health',
|
|
19
|
+
description: 'Smart-Mart MCPサーバーのヘルスチェック。認証不要。DB接続確認・商品数・カテゴリ一覧・稼働サイト一覧を返す',
|
|
20
|
+
inputSchema: { type: 'object', properties: {} },
|
|
21
|
+
},
|
|
22
|
+
|
|
23
|
+
// ============================================================
|
|
24
|
+
// 商品検索 (5)
|
|
25
|
+
// ============================================================
|
|
26
|
+
{
|
|
27
|
+
name: 'products_search',
|
|
28
|
+
description: 'Smart-Mart / Physical AI Rental / Humanoid Mart の全サイト横断で商品を検索。ヒューマノイドロボット・XR/VRデバイス・ドローン・AIデバイスなどを横断検索できる。価格・カテゴリ・ブランド・コンディションでフィルタ可能',
|
|
29
|
+
inputSchema: {
|
|
30
|
+
type: 'object',
|
|
31
|
+
properties: {
|
|
32
|
+
keyword: {
|
|
33
|
+
type: 'string',
|
|
34
|
+
description: 'キーワード(商品名・ブランド名など)',
|
|
35
|
+
},
|
|
36
|
+
category: {
|
|
37
|
+
type: 'string',
|
|
38
|
+
enum: ['humanoid', 'xr', 'drone', 'ai', 'quadruped', 'industrial'],
|
|
39
|
+
description: '商品カテゴリ。humanoid=ヒューマノイドロボット, xr=XR/VRデバイス, drone=ドローン, ai=AIデバイス, quadruped=4足歩行ロボット, industrial=産業用ロボット',
|
|
40
|
+
},
|
|
41
|
+
brand: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'ブランドID(brands.listで取得)',
|
|
44
|
+
},
|
|
45
|
+
min_price: {
|
|
46
|
+
type: 'integer',
|
|
47
|
+
description: '最低価格(円・新品販売価格基準)',
|
|
48
|
+
},
|
|
49
|
+
max_price: {
|
|
50
|
+
type: 'integer',
|
|
51
|
+
description: '最高価格(円・新品販売価格基準)',
|
|
52
|
+
},
|
|
53
|
+
condition: {
|
|
54
|
+
type: 'string',
|
|
55
|
+
enum: ['new', 'used'],
|
|
56
|
+
description: '商品状態。new=新品, used=中古',
|
|
57
|
+
},
|
|
58
|
+
available_only: {
|
|
59
|
+
type: 'boolean',
|
|
60
|
+
description: 'trueの場合、在庫あり商品のみ返す(デフォルト: false)',
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
name: 'products_detail',
|
|
67
|
+
description: '商品の詳細情報と全サイト別価格比較を取得。スペック・画像・各サイトの新品/中古/レンタル/リース/買取の価格を一覧で確認できる',
|
|
68
|
+
inputSchema: {
|
|
69
|
+
type: 'object',
|
|
70
|
+
properties: {
|
|
71
|
+
slug: {
|
|
72
|
+
type: 'string',
|
|
73
|
+
description: '商品スラッグ(例: figure-03, meta-quest-3, dji-mavic-3-pro)',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
required: ['slug'],
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: 'products_compare',
|
|
81
|
+
description: '複数商品(最大5点)のスペック・価格を並べた比較表を生成。どのロボットを選ぶか検討中のユーザーへの提案に最適',
|
|
82
|
+
inputSchema: {
|
|
83
|
+
type: 'object',
|
|
84
|
+
properties: {
|
|
85
|
+
slugs: {
|
|
86
|
+
type: 'array',
|
|
87
|
+
items: { type: 'string' },
|
|
88
|
+
minItems: 2,
|
|
89
|
+
maxItems: 5,
|
|
90
|
+
description: '比較する商品スラッグの配列(2〜5件)',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
required: ['slugs'],
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
name: 'categories_list',
|
|
98
|
+
description: '取扱カテゴリ一覧と各カテゴリの商品数を取得',
|
|
99
|
+
inputSchema: { type: 'object', properties: {} },
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
name: 'brands_list',
|
|
103
|
+
description: '取扱ブランド一覧を取得。カテゴリで絞り込み可能',
|
|
104
|
+
inputSchema: {
|
|
105
|
+
type: 'object',
|
|
106
|
+
properties: {
|
|
107
|
+
category: {
|
|
108
|
+
type: 'string',
|
|
109
|
+
enum: ['humanoid', 'xr', 'drone', 'ai', 'quadruped', 'industrial'],
|
|
110
|
+
description: '絞り込むカテゴリ(省略時は全カテゴリ)',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
|
|
116
|
+
// ============================================================
|
|
117
|
+
// レンタル (2)
|
|
118
|
+
// ============================================================
|
|
119
|
+
{
|
|
120
|
+
name: 'rental_search',
|
|
121
|
+
description: 'レンタル可能な商品を検索(Physical AI Rental / Smart-Mart Rental)。日額・週額・月額・長期月額でフィルタ可能',
|
|
122
|
+
inputSchema: {
|
|
123
|
+
type: 'object',
|
|
124
|
+
properties: {
|
|
125
|
+
category: {
|
|
126
|
+
type: 'string',
|
|
127
|
+
enum: ['humanoid', 'xr', 'drone', 'ai', 'quadruped', 'industrial'],
|
|
128
|
+
description: 'カテゴリ絞り込み',
|
|
129
|
+
},
|
|
130
|
+
brand: {
|
|
131
|
+
type: 'string',
|
|
132
|
+
description: 'ブランドID',
|
|
133
|
+
},
|
|
134
|
+
max_monthly_price: {
|
|
135
|
+
type: 'integer',
|
|
136
|
+
description: '月額上限(円)',
|
|
137
|
+
},
|
|
138
|
+
period: {
|
|
139
|
+
type: 'string',
|
|
140
|
+
enum: ['daily', 'weekly', 'monthly', 'long'],
|
|
141
|
+
description: '料金プランのタイプ。daily=日額, weekly=週額, monthly=月額, long=長期月額(3ヶ月以上)',
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
{
|
|
147
|
+
name: 'rental_availability',
|
|
148
|
+
description: '特定商品のレンタル在庫・空き状況と料金(日額/週額/月額/長期月額)を確認',
|
|
149
|
+
inputSchema: {
|
|
150
|
+
type: 'object',
|
|
151
|
+
properties: {
|
|
152
|
+
slug: {
|
|
153
|
+
type: 'string',
|
|
154
|
+
description: '商品スラッグ',
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
required: ['slug'],
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
// ============================================================
|
|
162
|
+
// 購入・リース (2)
|
|
163
|
+
// ============================================================
|
|
164
|
+
{
|
|
165
|
+
name: 'purchase_options',
|
|
166
|
+
description: '購入オプションを全サイト横断で比較。新品・中古・各サイトの在庫状況・価格を一覧表示。最安値のサイトを見つけるのに使う',
|
|
167
|
+
inputSchema: {
|
|
168
|
+
type: 'object',
|
|
169
|
+
properties: {
|
|
170
|
+
slug: {
|
|
171
|
+
type: 'string',
|
|
172
|
+
description: '商品スラッグ',
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
required: ['slug'],
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
name: 'lease_estimate',
|
|
180
|
+
description: 'リース月額の見積もりを計算。契約期間(12〜60ヶ月)別の月額・総コスト・購入との差額を提示',
|
|
181
|
+
inputSchema: {
|
|
182
|
+
type: 'object',
|
|
183
|
+
properties: {
|
|
184
|
+
slug: {
|
|
185
|
+
type: 'string',
|
|
186
|
+
description: '商品スラッグ',
|
|
187
|
+
},
|
|
188
|
+
term_months: {
|
|
189
|
+
type: 'integer',
|
|
190
|
+
enum: [12, 24, 36, 48, 60],
|
|
191
|
+
description: 'リース期間(月数)',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
required: ['slug', 'term_months'],
|
|
195
|
+
},
|
|
196
|
+
},
|
|
197
|
+
|
|
198
|
+
// ============================================================
|
|
199
|
+
// 買取査定 (1)
|
|
200
|
+
// ============================================================
|
|
201
|
+
{
|
|
202
|
+
name: 'buyback_estimate',
|
|
203
|
+
description: 'ロボット・XRデバイス・ドローン等の買取査定価格を即時算出。コンディション・付属品・年式に応じた査定レンジ(min/max)を返す',
|
|
204
|
+
inputSchema: {
|
|
205
|
+
type: 'object',
|
|
206
|
+
properties: {
|
|
207
|
+
brand: {
|
|
208
|
+
type: 'string',
|
|
209
|
+
description: 'メーカー名(例: Meta, Boston Dynamics, DJI, Figure)',
|
|
210
|
+
},
|
|
211
|
+
model: {
|
|
212
|
+
type: 'string',
|
|
213
|
+
description: '商品名またはスラッグ(例: meta-quest-3, Quest 3, dji-mavic-3-pro)',
|
|
214
|
+
},
|
|
215
|
+
condition: {
|
|
216
|
+
type: 'string',
|
|
217
|
+
enum: ['S', 'A', 'B', 'C', 'D'],
|
|
218
|
+
description: 'コンディション。S=未使用品/新品同様, A=良好(使用感少), B=並(使用感あり), C=難あり(軽微な傷・不具合), D=ジャンク',
|
|
219
|
+
},
|
|
220
|
+
year: {
|
|
221
|
+
type: 'integer',
|
|
222
|
+
description: '購入年(例: 2023)',
|
|
223
|
+
},
|
|
224
|
+
accessories: {
|
|
225
|
+
type: 'array',
|
|
226
|
+
items: { type: 'string' },
|
|
227
|
+
description: '付属品リスト(例: ["充電ケーブル", "純正ケース", "コントローラー"])',
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
required: ['brand', 'model', 'condition'],
|
|
231
|
+
},
|
|
232
|
+
},
|
|
233
|
+
|
|
234
|
+
// ============================================================
|
|
235
|
+
// 求人 (2)
|
|
236
|
+
// ============================================================
|
|
237
|
+
{
|
|
238
|
+
name: 'jobs_search',
|
|
239
|
+
description: 'Humanoid Jobsのロボット関連求人を検索。ヒューマノイドロボット・自動化・AI導入を推進する企業の求人を横断検索',
|
|
240
|
+
inputSchema: {
|
|
241
|
+
type: 'object',
|
|
242
|
+
properties: {
|
|
243
|
+
keyword: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: 'キーワード(職種・スキル・企業名など)',
|
|
246
|
+
},
|
|
247
|
+
location: {
|
|
248
|
+
type: 'string',
|
|
249
|
+
description: '勤務地(例: 東京, 大阪, リモート)',
|
|
250
|
+
},
|
|
251
|
+
employment_type: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
enum: ['full_time', 'part_time', 'contract', 'freelance'],
|
|
254
|
+
description: '雇用形態',
|
|
255
|
+
},
|
|
256
|
+
min_salary: {
|
|
257
|
+
type: 'integer',
|
|
258
|
+
description: '下限年収(万円)',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
},
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
name: 'jobs_by_robot',
|
|
265
|
+
description: '特定のロボット(商品)を導入・活用している企業の求人を取得。「このロボットを扱う仕事がしたい」というユーザーの要求に対応',
|
|
266
|
+
inputSchema: {
|
|
267
|
+
type: 'object',
|
|
268
|
+
properties: {
|
|
269
|
+
robot_slug: {
|
|
270
|
+
type: 'string',
|
|
271
|
+
description: 'ロボットのスラッグ(例: figure-03, atlas, spot)',
|
|
272
|
+
},
|
|
273
|
+
},
|
|
274
|
+
required: ['robot_slug'],
|
|
275
|
+
},
|
|
276
|
+
},
|
|
277
|
+
|
|
278
|
+
// ============================================================
|
|
279
|
+
// ユーティリティ (1)
|
|
280
|
+
// ============================================================
|
|
281
|
+
{
|
|
282
|
+
name: 'consult_request',
|
|
283
|
+
description: '購入・レンタル・リース・買取・修理に関する無料相談を申し込む。Smart-Martの専門スタッフが対応。inquiry_idを返す',
|
|
284
|
+
inputSchema: {
|
|
285
|
+
type: 'object',
|
|
286
|
+
properties: {
|
|
287
|
+
name: {
|
|
288
|
+
type: 'string',
|
|
289
|
+
description: '相談者氏名',
|
|
290
|
+
},
|
|
291
|
+
email: {
|
|
292
|
+
type: 'string',
|
|
293
|
+
description: 'メールアドレス',
|
|
294
|
+
},
|
|
295
|
+
phone: {
|
|
296
|
+
type: 'string',
|
|
297
|
+
description: '電話番号(任意)',
|
|
298
|
+
},
|
|
299
|
+
inquiry_type: {
|
|
300
|
+
type: 'string',
|
|
301
|
+
enum: ['purchase', 'rental', 'lease', 'buyback', 'repair'],
|
|
302
|
+
description: '相談種別。purchase=購入, rental=レンタル, lease=リース, buyback=買取, repair=修理',
|
|
303
|
+
},
|
|
304
|
+
message: {
|
|
305
|
+
type: 'string',
|
|
306
|
+
description: '相談内容(具体的な要件・予算・用途など)',
|
|
307
|
+
},
|
|
308
|
+
product_slug: {
|
|
309
|
+
type: 'string',
|
|
310
|
+
description: '対象商品のスラッグ(任意・特定商品についての相談の場合)',
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
required: ['name', 'email', 'inquiry_type', 'message'],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
];
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* ツール名 → APIアクションのマッピング
|
|
320
|
+
*/
|
|
321
|
+
export const ACTION_MAP = {
|
|
322
|
+
'health': 'health',
|
|
323
|
+
'products_search': 'products.search',
|
|
324
|
+
'products_detail': 'products.detail',
|
|
325
|
+
'products_compare': 'products.compare',
|
|
326
|
+
'categories_list': 'categories.list',
|
|
327
|
+
'brands_list': 'brands.list',
|
|
328
|
+
'rental_search': 'rental.search',
|
|
329
|
+
'rental_availability': 'rental.availability',
|
|
330
|
+
'purchase_options': 'purchase.options',
|
|
331
|
+
'lease_estimate': 'lease.estimate',
|
|
332
|
+
'buyback_estimate': 'buyback.estimate',
|
|
333
|
+
'jobs_search': 'jobs.search',
|
|
334
|
+
'jobs_by_robot': 'jobs.by_robot',
|
|
335
|
+
'consult_request': 'consult.request',
|
|
336
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "smartmart-mcp",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "MCP Server for Smart-Mart Robotics Platform - 14 tools for product search, rental, purchase, lease, buyback valuation, and job listings across Smart-Mart, Physical AI Rental, Humanoid Mart, and Humanoid Jobs.",
|
|
5
|
+
"main": "server.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"smartmart-mcp": "server.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"start": "node server.js"
|
|
12
|
+
},
|
|
13
|
+
"keywords": [
|
|
14
|
+
"mcp",
|
|
15
|
+
"model-context-protocol",
|
|
16
|
+
"smartmart",
|
|
17
|
+
"robotics",
|
|
18
|
+
"humanoid",
|
|
19
|
+
"xr",
|
|
20
|
+
"drone",
|
|
21
|
+
"ai-hardware",
|
|
22
|
+
"rental",
|
|
23
|
+
"lease",
|
|
24
|
+
"buyback",
|
|
25
|
+
"claude-code"
|
|
26
|
+
],
|
|
27
|
+
"files": [
|
|
28
|
+
"server.js",
|
|
29
|
+
"lib/**/*.js",
|
|
30
|
+
"README.md"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/asi-productions/mothership"
|
|
35
|
+
},
|
|
36
|
+
"author": "ASI Productions",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"engines": {
|
|
39
|
+
"node": ">=18.0.0"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"dependencies": {
|
|
45
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
46
|
+
}
|
|
47
|
+
}
|
package/server.js
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Smart-Mart Robotics MCP Server
|
|
5
|
+
* ロボティクス横断プラットフォーム
|
|
6
|
+
* Smart-Mart + Physical AI Rental + Humanoid Mart + Humanoid Jobs
|
|
7
|
+
*
|
|
8
|
+
* 14ツール:
|
|
9
|
+
* 商品検索 (5): products_search / products_detail / products_compare / categories_list / brands_list
|
|
10
|
+
* レンタル (2): rental_search / rental_availability
|
|
11
|
+
* 購入・リース (2): purchase_options / lease_estimate
|
|
12
|
+
* 買取査定 (1): buyback_estimate
|
|
13
|
+
* 求人 (2): jobs_search / jobs_by_robot
|
|
14
|
+
* ユーティリティ (2): health / consult_request
|
|
15
|
+
*
|
|
16
|
+
* 起動方法:
|
|
17
|
+
* SMARTMART_API_KEY=sm_xxx node server.js
|
|
18
|
+
* SMARTMART_API_KEY=sm_xxx SMARTMART_BASE_URL=https://smart-mart.jp node server.js
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
22
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
23
|
+
import { CallToolRequestSchema, ListToolsRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
24
|
+
import { SmartMartApiClient } from './lib/api-client.js';
|
|
25
|
+
import { TOOLS, ACTION_MAP } from './lib/tools.js';
|
|
26
|
+
|
|
27
|
+
const API_KEY = process.env.SMARTMART_API_KEY || '';
|
|
28
|
+
const BASE_URL = process.env.SMARTMART_BASE_URL || 'https://smart-mart.jp';
|
|
29
|
+
|
|
30
|
+
if (!API_KEY) {
|
|
31
|
+
console.error('[smartmart-mcp] Warning: SMARTMART_API_KEY is not set.');
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const client = new SmartMartApiClient(API_KEY, BASE_URL);
|
|
35
|
+
|
|
36
|
+
const server = new Server(
|
|
37
|
+
{ name: 'smartmart-mcp-server', version: '1.0.0' },
|
|
38
|
+
{ capabilities: { tools: {} } }
|
|
39
|
+
);
|
|
40
|
+
|
|
41
|
+
// ==========================================
|
|
42
|
+
// Handlers
|
|
43
|
+
// ==========================================
|
|
44
|
+
|
|
45
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
46
|
+
tools: TOOLS,
|
|
47
|
+
}));
|
|
48
|
+
|
|
49
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
50
|
+
const { name, arguments: args } = request.params;
|
|
51
|
+
const action = ACTION_MAP[name];
|
|
52
|
+
|
|
53
|
+
if (!action) {
|
|
54
|
+
return {
|
|
55
|
+
content: [{ type: 'text', text: JSON.stringify({ error: `Unknown tool: ${name}` }) }],
|
|
56
|
+
isError: true,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
try {
|
|
61
|
+
let result;
|
|
62
|
+
if (name === 'health') {
|
|
63
|
+
result = await client.health();
|
|
64
|
+
} else {
|
|
65
|
+
result = await client.request(action, args || {});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
content: [{ type: 'text', text: JSON.stringify(result, null, 2) }],
|
|
70
|
+
};
|
|
71
|
+
} catch (error) {
|
|
72
|
+
return {
|
|
73
|
+
content: [{ type: 'text', text: JSON.stringify({ error: error.message }) }],
|
|
74
|
+
isError: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ==========================================
|
|
80
|
+
// Start
|
|
81
|
+
// ==========================================
|
|
82
|
+
|
|
83
|
+
async function main() {
|
|
84
|
+
const transport = new StdioServerTransport();
|
|
85
|
+
await server.connect(transport);
|
|
86
|
+
console.error(`[smartmart-mcp] Server started (stdio, ${TOOLS.length} tools)`);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
main().catch((error) => {
|
|
90
|
+
console.error('[smartmart-mcp] Fatal error:', error);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
});
|