Skip to main content
Glama

Enhanced Miyabi MCP Server

by mo666-med
handler-test-runner.js5.7 kB
/** * Enhanced Miyabi MCP Server - Handler Unit Tests */ import { isDevelopmentTask, isArticleWritingTask, listToolsHandler, callToolHandler } from '../src/handlers.js'; let passedTests = 0; let totalTests = 0; function test(description, fn) { totalTests++; try { fn(); console.log(`✔ ${description}`); passedTests++; } catch (error) { console.error(`✗ ${description}`); console.error(` Error: ${error.message}`); } } function assert(condition, message) { if (!condition) { throw new Error(message || 'Assertion failed'); } } console.log('===== Running Handler Unit Tests ====='); // isDevelopmentTask tests test('isDevelopmentTask should return true for development-related tasks', () => { assert(isDevelopmentTask('バグを修正してください'), 'Should detect bug fix task'); assert(isDevelopmentTask('新しいAPIを実装する'), 'Should detect API implementation task'); assert(isDevelopmentTask('Please debug this code'), 'Should detect English debug task'); }); test('isDevelopmentTask should return false for general tasks', () => { assert(!isDevelopmentTask('天気を教えて'), 'Should not detect weather query as dev task'); assert(!isDevelopmentTask('レシピを探して'), 'Should not detect recipe search as dev task'); }); // isArticleWritingTask tests test('isArticleWritingTask should return true for article writing tasks', () => { assert(isArticleWritingTask('医療AIについて記事を書いて'), 'Should detect article writing task'); assert(isArticleWritingTask('noteの続編記事を作成'), 'Should detect note article task'); assert(isArticleWritingTask('Write a blog post about AI'), 'Should detect English blog task'); }); test('isArticleWritingTask should return false for non-article tasks', () => { assert(!isArticleWritingTask('天気を教えて'), 'Should not detect weather query as article task'); assert(!isArticleWritingTask('計算してください'), 'Should not detect calculation as article task'); }); // listToolsHandler test test('listToolsHandler should return a list of tools', () => { const tools = listToolsHandler(); assert(Array.isArray(tools), 'Should return an array'); assert(tools.length > 0, 'Should have at least one tool'); assert(tools[0].name, 'Tool should have a name'); assert(tools[0].description, 'Tool should have a description'); }); // callToolHandler tests test('callToolHandler for miyabi__analyze_task_intent (dev task)', () => { const result = callToolHandler('miyabi__analyze_task_intent', { prompt: 'バグを修正してください' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.isDevelopmentTask === true, 'Should identify as development task'); }); test('callToolHandler for miyabi__analyze_task_intent (article task)', () => { const result = callToolHandler('miyabi__analyze_task_intent', { prompt: '医療AIについて記事を書いて' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.isArticleWritingTask === true, 'Should identify as article writing task'); assert(data.taskType === 'article', 'Task type should be article'); }); test('callToolHandler for miyabi__analyze_task_intent (general task)', () => { const result = callToolHandler('miyabi__analyze_task_intent', { prompt: '天気を教えて' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.isDevelopmentTask === false, 'Should not identify as development task'); assert(data.isArticleWritingTask === false, 'Should not identify as article task'); assert(data.taskType === 'general', 'Task type should be general'); }); test('callToolHandler for miyabi__auto_dispatch (dev task)', () => { const result = callToolHandler('miyabi__auto_dispatch', { prompt: 'APIを実装してください' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.action === 'handle_development', 'Should dispatch to development handler'); }); test('callToolHandler for miyabi__auto_dispatch (article task)', () => { const result = callToolHandler('miyabi__auto_dispatch', { prompt: '医療AIについて記事を書いて' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.action === 'handle_article', 'Should dispatch to article handler'); }); test('callToolHandler for miyabi__auto_dispatch (general task)', () => { const result = callToolHandler('miyabi__auto_dispatch', { prompt: '天気を教えて' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.action === 'return_to_manus', 'Should return to Manus'); }); test('callToolHandler for miyabi__generate_article', () => { const result = callToolHandler('miyabi__generate_article', { articleTitle: 'Test Article', articleUrl: 'https://example.com', perspective: '臨床倫理', angle: '技術の倫理的含意' }); assert(result.content, 'Should return content'); const data = JSON.parse(result.content[0].text); assert(data.status === 'success', 'Should return success status'); assert(data.article.title === 'Test Article', 'Should include article title'); }); console.log(`\n ${passedTests}/${totalTests} tests passed. \n`); if (passedTests === totalTests) { console.log('All handler tests passed successfully!'); process.exit(0); } else { console.error('Some tests failed.'); process.exit(1); }

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