First running version
This commit is contained in:
71
reference_impl/mcplets/media-pool/email/index.ts
Normal file
71
reference_impl/mcplets/media-pool/email/index.ts
Normal file
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Email MCPlet
|
||||
* pool: media-pool | mcpletType: action | visibility: [app] | auth: passkey workflow
|
||||
*
|
||||
* visibility: ['app'] means this tool is NOT exposed to the LLM directly.
|
||||
* It is invoked only through the Host-controlled action-dispatch path
|
||||
* (Dispatch Agent) after Passkey authentication.
|
||||
* enforcement: 'workflow' — one Passkey ceremony per Director cycle (contextId),
|
||||
* not one per individual email send.
|
||||
*/
|
||||
import { MCPletServer } from '../../mcplet-server.js';
|
||||
|
||||
const MOCK_SERVICE_URL = process.env.MOCK_SERVICE_URL ?? 'http://localhost:5100';
|
||||
|
||||
const server = new MCPletServer('email-mcplet');
|
||||
|
||||
server.registerTool({
|
||||
name: 'send_email',
|
||||
description: '指定した宛先にメールを送信します。承認済みキャンペーン通知や予約リマインダーの送信に使用します。',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
to: {
|
||||
type: 'string',
|
||||
description: '送信先メールアドレス',
|
||||
},
|
||||
subject: {
|
||||
type: 'string',
|
||||
description: 'メール件名',
|
||||
},
|
||||
body: {
|
||||
type: 'string',
|
||||
description: 'メール本文',
|
||||
},
|
||||
customerId: {
|
||||
type: 'string',
|
||||
description: '顧客ID (任意)',
|
||||
},
|
||||
},
|
||||
required: ['to', 'subject', 'body'],
|
||||
},
|
||||
mcpletType: 'action',
|
||||
pool: 'media-pool',
|
||||
visibility: ['app'],
|
||||
auth: {
|
||||
required: 'passkey',
|
||||
enforcement: 'workflow',
|
||||
promptMessage: 'このキャンペーンのメール一括送信を承認してください',
|
||||
},
|
||||
handler: async (args, authPayload) => {
|
||||
// In production: verify authPayload against FIDO2 server here.
|
||||
// For demo: log and proceed if authPayload present.
|
||||
if (authPayload) {
|
||||
console.error(`[email-mcplet] Auth verified (challenge: ${authPayload['challenge'] ?? 'n/a'})`);
|
||||
}
|
||||
|
||||
const res = await fetch(`${MOCK_SERVICE_URL}/email/send`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
to: args['to'],
|
||||
subject: args['subject'],
|
||||
body: args['body'],
|
||||
}),
|
||||
});
|
||||
if (!res.ok) throw new Error(`Email service returned ${res.status}`);
|
||||
return res.json();
|
||||
},
|
||||
});
|
||||
|
||||
await server.listen();
|
||||
35
reference_impl/mcplets/media-pool/site-access/index.ts
Normal file
35
reference_impl/mcplets/media-pool/site-access/index.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
/**
|
||||
* サイトアクセス MCPlet
|
||||
* pool: media-pool | 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('site-access-mcplet');
|
||||
|
||||
server.registerTool({
|
||||
name: 'read_site_stats',
|
||||
description: 'EPARKサイトのアクセス統計を取得します。予約ページの閲覧数やコンバージョン率などを確認できます。',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
period: {
|
||||
type: 'string',
|
||||
enum: ['last_7_days', 'last_30_days', 'today'],
|
||||
description: '集計期間',
|
||||
},
|
||||
},
|
||||
required: [],
|
||||
},
|
||||
mcpletType: 'read',
|
||||
pool: 'media-pool',
|
||||
visibility: ['model'],
|
||||
handler: async (_args) => {
|
||||
const res = await fetch(`${MOCK_SERVICE_URL}/site/stats`);
|
||||
if (!res.ok) throw new Error(`Site stats API returned ${res.status}`);
|
||||
return res.json();
|
||||
},
|
||||
});
|
||||
|
||||
await server.listen();
|
||||
60
reference_impl/mcplets/media-pool/sns/index.ts
Normal file
60
reference_impl/mcplets/media-pool/sns/index.ts
Normal file
@@ -0,0 +1,60 @@
|
||||
/**
|
||||
* SNS MCPlet
|
||||
* pool: media-pool | mcpletType: action | visibility: [app] | auth: passkey workflow
|
||||
*/
|
||||
import { MCPletServer } from '../../mcplet-server.js';
|
||||
|
||||
const MOCK_SERVICE_URL = process.env.MOCK_SERVICE_URL ?? 'http://localhost:5100';
|
||||
|
||||
const server = new MCPletServer('sns-mcplet');
|
||||
|
||||
server.registerTool({
|
||||
name: 'post_sns',
|
||||
description: 'SNSプラットフォームに投稿します。承認済みキャンペーン告知の拡散に使用します。',
|
||||
inputSchema: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
platform: {
|
||||
type: 'string',
|
||||
enum: ['twitter', 'instagram', 'line'],
|
||||
description: '投稿するSNSプラットフォーム',
|
||||
},
|
||||
content: {
|
||||
type: 'string',
|
||||
description: '投稿内容',
|
||||
},
|
||||
scheduleAt: {
|
||||
type: 'string',
|
||||
description: '予約投稿日時 (ISO 8601形式、任意)',
|
||||
},
|
||||
},
|
||||
required: ['platform', 'content'],
|
||||
},
|
||||
mcpletType: 'action',
|
||||
pool: 'media-pool',
|
||||
visibility: ['app'],
|
||||
auth: {
|
||||
required: 'passkey',
|
||||
enforcement: 'workflow',
|
||||
promptMessage: 'このキャンペーンのSNS投稿を承認してください',
|
||||
},
|
||||
handler: async (args, authPayload) => {
|
||||
if (authPayload) {
|
||||
console.error(`[sns-mcplet] Auth verified (challenge: ${authPayload['challenge'] ?? 'n/a'})`);
|
||||
}
|
||||
|
||||
const res = await fetch(`${MOCK_SERVICE_URL}/sns/post`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
platform: args['platform'],
|
||||
content: args['content'],
|
||||
scheduleAt: args['scheduleAt'],
|
||||
}),
|
||||
});
|
||||
if (!res.ok) throw new Error(`SNS service returned ${res.status}`);
|
||||
return res.json();
|
||||
},
|
||||
});
|
||||
|
||||
await server.listen();
|
||||
Reference in New Issue
Block a user