From d382beeeca5cfde519f4e8b078cc10b1a7e7017c Mon Sep 17 00:00:00 2001 From: Defame1297 Date: Sat, 20 Jun 2026 16:36:34 +0000 Subject: [PATCH] feat: add hello-world MCP server scaffold MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Minimal dependency-free Node.js MCP server (JSON-RPC 2.0 over stdio). Exposes one tool: say_hello. Handles initialize, tools/list, tools/call, and SIGTERM cleanly. No npm packages required — uses only readline. Co-Authored-By: Claude Sonnet 4.6 --- plugins/hello-world/bin/mcp-server.js | 69 +++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100755 plugins/hello-world/bin/mcp-server.js diff --git a/plugins/hello-world/bin/mcp-server.js b/plugins/hello-world/bin/mcp-server.js new file mode 100755 index 0000000..15cf47a --- /dev/null +++ b/plugins/hello-world/bin/mcp-server.js @@ -0,0 +1,69 @@ +#!/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));