Skip to main content
Glama

Enhanced Miyabi MCP Server

by mo666-med
handlers.js8.1 kB
/** * Enhanced Miyabi MCP Server - Core Handlers * タスク分析・振り分けの純粋なビジネスロジック */ /** * タスクが開発関連かどうかを判定 * @param {string} prompt - ユーザーのプロンプト * @returns {boolean} 開発関連タスクの場合true */ export function isDevelopmentTask(prompt) { const devKeywords = [ 'コード', 'プログラム', 'バグ', 'デバッグ', 'テスト', 'デプロイ', 'API', 'データベース', 'フロントエンド', 'バックエンド', 'リファクタリング', '実装', '開発', 'アプリ', 'ウェブサイト', 'システム', 'モジュール', 'code', 'program', 'bug', 'debug', 'test', 'deploy', 'api', 'database', 'frontend', 'backend', 'refactor', 'implement', 'develop', 'app', 'website', 'system', 'module' ]; const lowerPrompt = prompt.toLowerCase(); return devKeywords.some(keyword => lowerPrompt.includes(keyword.toLowerCase())); } /** * 記事執筆タスクかどうかを判定 * @param {string} prompt - ユーザーのプロンプト * @returns {boolean} 記事執筆タスクの場合true */ export function isArticleWritingTask(prompt) { const articleKeywords = [ '記事', '論文', 'note', 'ブログ', '執筆', '書いて', '作成', 'article', 'paper', 'blog', 'write', 'create', 'post', '医療AI', '医療', 'AI', 'LLMO', 'サムネイル', 'ハッシュタグ' ]; const lowerPrompt = prompt.toLowerCase(); return articleKeywords.some(keyword => lowerPrompt.includes(keyword.toLowerCase())); } /** * 利用可能なツールのリストを返す * @returns {Array} ツールのリスト */ export function listToolsHandler() { return [ { name: "miyabi__analyze_task_intent", description: "ユーザーのタスクを分析し、開発関連か一般タスクかを判定します", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "分析するユーザーのプロンプト" } }, required: ["prompt"] } }, { name: "miyabi__auto_dispatch", description: "タスクを自動的に適切なハンドラーに振り分けます(開発タスク→Miyabi、一般タスク→Manus)", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "振り分けるタスクのプロンプト" } }, required: ["prompt"] } }, { name: "miyabi__handle_development_task", description: "開発タスクを処理します(Issue作成→Agent実行)", inputSchema: { type: "object", properties: { prompt: { type: "string", description: "開発タスクの内容" }, projectPath: { type: "string", description: "プロジェクトのパス(オプション)" } }, required: ["prompt"] } }, { name: "miyabi__generate_article", description: "医療AI関連の学術記事を生成します(LLMO対策、サムネイル指示付き)", inputSchema: { type: "object", properties: { articleTitle: { type: "string", description: "参照元の論文/記事のタイトル" }, articleAuthor: { type: "string", description: "著者名" }, articleSource: { type: "string", description: "出典" }, articleUrl: { type: "string", description: "参照元のURL" }, keyConcepts: { type: "string", description: "キーコンセプト(箇条書き)" }, perspective: { type: "string", description: "執筆者のペルソナ・専門分野" }, angle: { type: "string", description: "論文の切り口" }, deepDivePoints: { type: "string", description: "特に深掘りしたい論点" } }, required: ["articleTitle", "articleUrl", "perspective", "angle"] } } ]; } /** * ツール呼び出しを処理 * @param {string} toolName - ツール名 * @param {object} args - 引数 * @returns {object} 実行結果 */ export function callToolHandler(toolName, args) { switch (toolName) { case "miyabi__analyze_task_intent": { const isDev = isDevelopmentTask(args.prompt); const isArticle = isArticleWritingTask(args.prompt); return { content: [{ type: "text", text: JSON.stringify({ isDevelopmentTask: isDev, isArticleWritingTask: isArticle, taskType: isArticle ? "article" : (isDev ? "development" : "general"), prompt: args.prompt }, null, 2) }] }; } case "miyabi__auto_dispatch": { const isDev = isDevelopmentTask(args.prompt); const isArticle = isArticleWritingTask(args.prompt); if (isArticle) { return { content: [{ type: "text", text: JSON.stringify({ action: "handle_article", message: "記事執筆タスクとして処理します", nextStep: "miyabi__generate_articleツールを使用してください" }, null, 2) }] }; } else if (isDev) { return { content: [{ type: "text", text: JSON.stringify({ action: "handle_development", message: "開発タスクとしてMiyabiで処理します", nextStep: "miyabi__handle_development_taskツールを使用してください" }, null, 2) }] }; } else { return { content: [{ type: "text", text: JSON.stringify({ action: "return_to_manus", message: "一般タスクとしてManusで処理します" }, null, 2) }] }; } } case "miyabi__handle_development_task": { return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: "開発タスクを処理しました", steps: [ "1. Issueを自動作成", "2. Miyabi Agentを実行", "3. PRを作成" ], prompt: args.prompt, projectPath: args.projectPath || "デフォルトプロジェクト" }, null, 2) }] }; } case "miyabi__generate_article": { return { content: [{ type: "text", text: JSON.stringify({ status: "success", message: "記事生成を開始します", article: { title: args.articleTitle, author: args.articleAuthor || "不明", source: args.articleSource || "不明", url: args.articleUrl, perspective: args.perspective, angle: args.angle, deepDivePoints: args.deepDivePoints || "指定なし" }, nextSteps: [ "1. 参照元の完全読解と分析", "2. 超詳細な論文構成案の策定", "3. 補足情報の調査と引用準備", "4. 品格ある文体での本文執筆(8000字以上)", "5. 引用文献リストの作成(最大10本)", "6. 最終校正と整形", "7. 末尾LLMOまとめ", "8. ハッシュタグ(10個)", "9. サムネイル画像の生成prompt(3点)" ] }, null, 2) }] }; } default: throw new Error(`Unknown tool: ${toolName}`); } }

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/mo666-med/enhanced-miyabi-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server