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-core

v1.0.0

Published

Core types and interfaces for the ConveniencePro Tool Protocol (CTP)

Readme

@conveniencepro/ctp-core

Core types and interfaces for the ConveniencePro Tool Protocol (CTP).

CTP is a protocol for defining, discovering, and executing browser-native utility tools. It extends MCP (Model Context Protocol) principles to client-side execution with a privacy-first design.

Installation

npm install @conveniencepro/ctp-core
# or
yarn add @conveniencepro/ctp-core
# or
pnpm add @conveniencepro/ctp-core

Quick Start

import {
  defineTool,
  success,
  failure,
  type ToolDefinition,
  type ToolFunction,
} from '@conveniencepro/ctp-core';

// Define a tool with full type safety
const myToolDefinition = defineTool({
  id: 'my-tool',
  name: 'My Tool',
  description: 'A simple example tool',
  category: 'examples',
  tags: ['example', 'demo'],
  method: 'GET',
  parameters: [
    {
      name: 'input',
      type: 'text',
      label: 'Input',
      description: 'The input text to process',
      required: true,
      placeholder: 'Enter text...',
    },
  ],
  outputDescription: 'Returns the processed text',
  example: {
    input: { input: 'hello' },
    output: { success: true, result: 'HELLO' },
  },
});

// Implement the tool function
const myTool: ToolFunction = (params) => {
  const input = params.input;

  if (!input) {
    return failure('Missing required parameter: input');
  }

  return success({
    result: input.toUpperCase(),
    length: input.length,
  });
};

Core Types

ToolDefinition

The primary interface for defining a CTP-compliant tool:

interface ToolDefinition {
  id: string;                    // Unique identifier (URL-safe)
  name: string;                  // Human-readable name
  description: string;           // Tool description
  category: string;              // Category for organization
  tags: string[];                // Discovery tags
  method: 'GET' | 'POST';        // HTTP method
  parameters: ParameterSchema[]; // Input parameters
  outputDescription: string;     // Output format description
  example: ToolExample;          // Example input/output
  // ... additional optional fields
}

ParameterSchema

Defines a single parameter:

interface ParameterSchema {
  name: string;        // Parameter name
  type: FieldType;     // 'text' | 'textarea' | 'number' | 'boolean' | 'select' | 'json' | ...
  label: string;       // Display label
  description: string; // Parameter description
  required: boolean;   // Is required?
  default?: unknown;   // Default value
  // ... validation constraints
}

ToolResult

All tools return this format:

type ToolResult<T> =
  | { success: true; [key: string]: unknown }
  | { success: false; error: string; errorCode?: string };

Validation

Validate tool definitions and parameters at runtime:

import {
  validateToolDefinition,
  validateParameters,
  normalizeParams,
} from '@conveniencepro/ctp-core';

// Validate a tool definition
const result = validateToolDefinition(myDefinition);
if (!result.valid) {
  console.error('Validation errors:', result.errors);
}

// Validate parameters
const params = normalizeParams(new URLSearchParams('input=hello'));
const paramResult = validateParameters(params, myDefinition);

Helper Functions

import {
  success,
  failure,
  safeExecute,
  getProtocolInfo,
} from '@conveniencepro/ctp-core';

// Create success/failure results
const okResult = success({ data: 'processed' });
const errResult = failure('Something went wrong', 'ERR_INVALID_INPUT');

// Safe execution with validation
const result = await safeExecute(myTool, params, myDefinition);

// Get protocol info
const info = getProtocolInfo();
// { name: 'ConveniencePro Tool Protocol', version: '1.0.0', ... }

Type Utilities

import type {
  ToolFunction,
  ToolFunctionAsync,
  NormalizedParams,
  ToolId,
} from '@conveniencepro/ctp-core';

import { createToolId, isValidToolId } from '@conveniencepro/ctp-core';

// Branded tool IDs for type safety
const toolId = createToolId('json-format'); // ToolId type

// Validate ID format
isValidToolId('my-tool');     // true
isValidToolId('MyTool');      // false (must be lowercase)
isValidToolId('my_tool');     // false (no underscores)

Protocol Version

import { CTP_VERSION } from '@conveniencepro/ctp-core';

console.log(CTP_VERSION); // '1.0.0'

Related Packages

  • @conveniencepro/ctp-runtime - Tool execution runtime (browser & Node.js)
  • @conveniencepro/ctp-discovery - Manifest generation (OpenAPI, AI tools)
  • @conveniencepro/ctp-sdk - Embeddable SDK for websites

License

MIT © ConveniencePro