MCP Server Framework
Node.js library for building small Model Context Protocol servers, with an HTTP and a stdio transport and a shared registry file.
robos-mcp-lib is a library first. Other packages (system-mcp, task-manager-mcp, workspace-manager-mcp and several more under packages/) call it to define their tools and resources.
What the library provides
const { createMCPServer, startStdioTransport, listRegisteredServers } = require('../robos-mcp-lib/index');
const server = createMCPServer({
appId: 'demo',
tools: [{ name: 'hello', description: 'Say hello', handler: async () => 'hi' }],
port: 19200, // optional; omit to skip HTTP
});
- JSON-RPC 2.0 handling for
initialize,ping,tools/list,tools/call,resources/listandresources/read, reporting protocol version2024-11-05. Any other method returns error-32601. - Naming. A tool named
helloin appdemobecomesrobos_demo_hello; names that already start withrobos_are kept. A resource URI such asinfobecomesrobos://demo/info. - HTTP transport (
startHttp(port)or theportoption):POST /mcpfor JSON-RPC andGET /health, with permissive CORS headers. - stdio transport (
startStdioTransport(server)): one JSON request per line on stdin, one response per line on stdout. - Registry. When a server starts it writes itself to
~/.config/robos/mcp/servers.json(app id, name, version, port, endpoint, tool names, resource URIs).stop()removes the entry. The MCP Router reads this file.
A tool handler’s return value is sent back as one text block (strings as-is, other values as pretty-printed JSON). If the handler throws, the result has isError: true and the error message.
The inspector window
main.js creates a demo server with the tools calculate_metrics and query_workspace and the resource system-info, and shows them in RobOS MCP Server Inspector & Framework. The tool results are fixed sample values. Click Call calculate_metrics to see the request and response in the protocol trace; Clear Trace empties it. The demo server has no HTTP port. Run it with npm start in packages/robos-mcp-lib (there is no .desktop launcher). npm test runs node --test.