npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@conveniencepro/ctp-examples

v1.0.0

Published

Example tool implementations for ConveniencePro Tool Protocol

Downloads

97

Readme

@conveniencepro/ctp-examples

Example tool implementations for the ConveniencePro Tool Protocol (CTP).

Overview

This package provides reference implementations demonstrating CTP best practices:

  • JSON Formatter - Synchronous tool with multiple parameters
  • Base64 Encoder - Bidirectional tool with conditional parameters
  • Hash Generator - Async tool using Web Crypto API

Installation

npm install @conveniencepro/ctp-examples
# or
yarn add @conveniencepro/ctp-examples

Usage

Create Registry with Example Tools

import { createExampleRegistry } from '@conveniencepro/ctp-examples';

const registry = createExampleRegistry();

// Execute a tool
const result = await registry.execute('json-formatter', {
  json: '{"name":"test"}',
  indent: '2',
});

console.log(result.data.formatted);

Add to Existing Registry

import { createRegistry } from '@conveniencepro/ctp-runtime';
import { registerExampleTools } from '@conveniencepro/ctp-examples';

const registry = createRegistry();
registerExampleTools(registry);

// Your tools + example tools now available

Use Individual Tools

import {
  jsonFormatterDefinition,
  jsonFormatterFn,
  base64EncoderDefinition,
  base64EncoderFn,
  hashGeneratorDefinition,
  hashGeneratorFn,
} from '@conveniencepro/ctp-examples';

// Register only specific tools
registry.register(jsonFormatterDefinition, jsonFormatterFn);

Get Tool Definitions

import { getToolDefinitions, getToolById } from '@conveniencepro/ctp-examples';

// Get all definitions
const definitions = getToolDefinitions();

// Get specific tool
const jsonFormatter = getToolById('json-formatter');

Example Tools

JSON Formatter

ID: json-formatter Category: formatters

Format, validate, and beautify JSON data.

Parameters: | Name | Type | Required | Default | Description | |------|------|----------|---------|-------------| | json | textarea | Yes | - | JSON string to format | | indent | select | No | 2 | Indentation (0, 2, 4, tab) | | sortKeys | boolean | No | false | Sort keys alphabetically |

Example:

const result = await registry.execute('json-formatter', {
  json: '{"b":2,"a":1}',
  indent: '2',
  sortKeys: true,
});

// Output:
// {
//   "a": 1,
//   "b": 2
// }

Base64 Encoder/Decoder

ID: base64-encoder Category: encoders

Encode text to Base64 or decode Base64 to text.

Parameters: | Name | Type | Required | Default | Description | |------|------|----------|---------|-------------| | input | textarea | Yes | - | Text or Base64 string | | mode | select | No | encode | Operation mode | | urlSafe | boolean | No | false | Use URL-safe variant |

Example:

// Encode
const encoded = await registry.execute('base64-encoder', {
  input: 'Hello, World!',
  mode: 'encode',
});
// Output: SGVsbG8sIFdvcmxkIQ==

// Decode
const decoded = await registry.execute('base64-encoder', {
  input: 'SGVsbG8sIFdvcmxkIQ==',
  mode: 'decode',
});
// Output: Hello, World!

Hash Generator

ID: hash-generator Category: generators

Generate cryptographic hashes using SHA algorithms.

Parameters: | Name | Type | Required | Default | Description | |------|------|----------|---------|-------------| | input | textarea | Yes | - | Text to hash | | algorithm | select | No | SHA-256 | Hash algorithm | | format | select | No | hex | Output format |

Example:

const result = await registry.execute('hash-generator', {
  input: 'hello world',
  algorithm: 'SHA-256',
  format: 'hex',
});
// Output: b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

Creating Your Own Tools

Use these examples as templates. Key patterns:

1. Define Types

interface MyToolResult {
  output: string;
  // ...
}

2. Create Definition

const myToolDefinition: ToolDefinition = {
  id: 'my-tool',
  name: 'My Tool',
  description: '...',
  category: 'utilities',
  tags: ['example'],
  method: 'POST',
  parameters: [...],
  outputDescription: '...',
  example: { input: {...}, output: {...} },
};

3. Implement Function

const myToolFn: ToolFunction<MyToolResult> = (params) => {
  // Validate
  if (!params.input) {
    return { success: false, error: '...', errorCode: 'MISSING_REQUIRED' };
  }

  // Process
  const output = processInput(params.input);

  // Return
  return {
    success: true,
    data: { output },
    metadata: { executionTime: 0 },
  };
};

4. Export Both

export default { definition: myToolDefinition, fn: myToolFn };

Related Packages

  • @conveniencepro/ctp-core - Core types
  • @conveniencepro/ctp-runtime - Execution runtime
  • @conveniencepro/ctp-spec - Protocol specification

License

MIT © ConveniencePro