First running version

This commit is contained in:
qingjie.du
2026-03-30 17:39:13 +09:00
parent 5ffea3d849
commit bce2a5672c
67 changed files with 16503 additions and 0 deletions

View File

@@ -0,0 +1,56 @@
/**
* CRM MCPlet (内部システム)
* pool: なし (pool-less) | mcpletType: read | visibility: [model]
*/
import { MCPletServer } from '../../mcplet-server.js';
const MOCK_SERVICE_URL = process.env.MOCK_SERVICE_URL ?? 'http://localhost:5100';
const server = new MCPletServer('crm-mcplet');
server.registerTool({
name: 'query_crm',
description: 'CRMシステムから顧客・予約情報を取得します。キャンセル傾向分析や顧客リスト取得に使用します。',
inputSchema: {
type: 'object',
properties: {
entity: {
type: 'string',
enum: ['customers', 'reservations'],
description: '取得するエンティティ種別',
},
filter: {
type: 'string',
description: 'フィルタ条件 (例: rain_cancel_tendency, date=YYYY-MM-DD)',
},
},
required: ['entity'],
},
mcpletType: 'read',
visibility: ['model'],
handler: async (args) => {
const entity = args['entity'] as string;
const filter = args['filter'] as string | undefined;
if (entity === 'customers') {
const qs = filter ? `?filter=${encodeURIComponent(filter)}` : '';
const res = await fetch(`${MOCK_SERVICE_URL}/crm/customers${qs}`);
if (!res.ok) throw new Error(`CRM API returned ${res.status}`);
return res.json();
}
if (entity === 'reservations') {
// filter may be "date=2026-03-28"
const dateMatch = filter?.match(/date=(\d{4}-\d{2}-\d{2})/);
const date = dateMatch ? dateMatch[1] : '';
const qs = date ? `?date=${date}` : '';
const res = await fetch(`${MOCK_SERVICE_URL}/crm/reservations${qs}`);
if (!res.ok) throw new Error(`CRM API returned ${res.status}`);
return res.json();
}
throw new Error(`Unknown CRM entity: ${entity}`);
},
});
await server.listen();