#!/usr/bin/env node 'use strict'; // Minimal MCP server — JSON-RPC 2.0 over stdio, no external dependencies. // Exposes one tool: `say_hello`. Replace with your actual tools. const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, terminal: false }); function send(obj) { process.stdout.write(JSON.stringify(obj) + '\n'); } const TOOLS = [ { name: 'say_hello', description: 'Say hello from the holocron marketplace hello-world plugin.', inputSchema: { type: 'object', properties: { name: { type: 'string', description: 'Name to greet (optional)' } } } } ]; rl.on('line', (line) => { let msg; try { msg = JSON.parse(line); } catch { return; } const { method, id, params } = msg; if (method === 'initialize') { send({ jsonrpc: '2.0', id, result: { protocolVersion: '2024-11-05', capabilities: { tools: {} }, serverInfo: { name: 'hello-world', version: '1.0.0' } } }); } else if (method === 'notifications/initialized') { // no response required } else if (method === 'tools/list') { send({ jsonrpc: '2.0', id, result: { tools: TOOLS } }); } else if (method === 'tools/call') { const toolName = params?.name; const args = params?.arguments ?? {}; if (toolName === 'say_hello') { const greeting = args.name ? `Hello, ${args.name}! The holocron marketplace hello-world plugin is working.` : 'Hello from the holocron marketplace hello-world plugin!'; send({ jsonrpc: '2.0', id, result: { content: [{ type: 'text', text: greeting }] } }); } else { send({ jsonrpc: '2.0', id, error: { code: -32601, message: `Unknown tool: ${toolName}` } }); } } else if (id !== undefined) { send({ jsonrpc: '2.0', id, error: { code: -32601, message: 'Method not found' } }); } }); process.on('SIGINT', () => process.exit(0)); process.on('SIGTERM', () => process.exit(0));