Skip to content

Tiny node.js helper lib to simplify running MCP server via a CLI and to register MCP tools on the server

License

Notifications You must be signed in to change notification settings

cliffano/convo-node

Repository files navigation

Avatar

Build Status Dependencies Status Code Scanning Status Coverage Status Security Status Published Version

convo-node

convo-node is a tiny node.js helper lib to simplify running MCP server via a CLI and to register MCP tools on the server.

Installation

npm install convo-node

or as a dependency in package.json file:

"dependencies": {
  "convo-node": "x.y.z"
}

Usage

Create tools:

import { z } from 'zod';

const tool1 = {
    info: {
        name: 'tool_1',
        description: 'MCP Tool 1',
        parameters: { name: z.string() }
    },
    handler: function(opts, actionCb) {
        return async({ arg1 }) => {
          function _contentText(result) {
            return `Tool1 ${arg1} has been handled`;
          }
          return new Promise((resolve, reject) => {
            const cb = actionCb(resolve, reject, _contentText);
            console.log(`Param 1 is ${opts.param1}`);
            cb();
          });
        };
    }
};

const tool2 = ...

const tools: [
  tool1,
  tool2
]

Create application directory which is the location of the node.js module file which uses convo-node:

import p from 'path';

const appDir = p.dirname(import.meta.url).replace('file://', '');

Create options callback function which accepts CLI arguments and returns the options object:

function toolOptsCb(args) {

  // opts contains properties that could be needed by the tools handler function
  const opts = {
    param1: 'value1'
  };

  return opts;

}

Execute Convo:

convo.exec(appDir, tools, toolOptsCb)();

Colophon

Developer's Guide

Build reports:

Related Projects:

  • Convo - Specification based voice and text conversation app
  • Convo Generator - Convo agent and middleware generator

About

Tiny node.js helper lib to simplify running MCP server via a CLI and to register MCP tools on the server

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published