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

@procedures/mcp

v0.1.0

Published

Map typed procedures to MCP tools: JSON Schema from Zod, tool names, and input and result conversion for Model Context Protocol servers.

Readme

@procedures/mcp

npm

License: MIT TypeScript Node.js MCP

Core types and utilities for MCP (Model Context Protocol) integration. Converts Zod schemas and procedures to MCP-compatible formats.

Table of Contents


Overview

mcp provides the foundation for MCP integration:

  • Schema Conversion - Convert Zod schemas to JSON Schema format
  • Procedure Mapping - Transform procedures to MCP tool definitions
  • Filtering - Control which procedures become MCP tools
  • Type Definitions - TypeScript types for MCP tools and filters

Installation

npm install @procedures/mcp

Architecture

Conversion Pipeline

graph LR
    subgraph "Input"
        Proc[Procedure]
        Zod[Zod Schema]
    end

    subgraph "mcp Package"
        Z2J[zodToJsonSchema]
        P2T[procedureToMcpTool]
    end

    subgraph "Output"
        JSON[JSON Schema]
        Tool[MCP Tool]
    end

    Zod --> Z2J
    Z2J --> JSON
    Proc --> P2T
    JSON --> P2T
    P2T --> Tool

Procedure to MCP Tool Mapping

graph TB
    subgraph "Procedure"
        Path[path: string[]]
        Meta[metadata.description]
        Input[input: ZodSchema]
        Handler[handler: Function]
    end

    subgraph "MCP Tool"
        Name[name: string]
        Desc[description: string]
        Schema[inputSchema: JSONSchema]
    end

    Path -->|"join('.')"| Name
    Meta --> Desc
    Input -->|zodToJsonSchema| Schema

System Integration

graph TB
    subgraph "Procedure Registry"
        R1[fs.read]
        R2[git.commit]
        R3[shell.run]
        R4[...]
    end

    subgraph "mcp"
        Convert[proceduresToMcpTools]
        Filter[McpToolFilter]
    end

    subgraph "client-mcp"
        Transport[McpServerTransport]
    end

    subgraph "Claude"
        Tools[MCP Tools]
    end

    R1 --> Convert
    R2 --> Convert
    R3 --> Convert
    R4 --> Convert
    Filter --> Convert
    Convert --> Transport
    Transport --> Tools

Quick Start

import { proceduresToMcpTools, zodToJsonSchema } from "@procedures/mcp";
import { PROCEDURE_REGISTRY } from "@procedures/client";

// Convert all registered procedures to MCP tools
const tools = proceduresToMcpTools(PROCEDURE_REGISTRY.getAll());

// Convert a Zod schema to JSON Schema
const jsonSchema = zodToJsonSchema(myZodSchema);

API Reference

zodToJsonSchema

Converts a Zod schema to JSON Schema format for MCP tool input definitions.

function zodToJsonSchema(schema: ZodType): JsonSchema;

Supported Zod Types:

| Zod Type | JSON Schema | |----------|-------------| | z.string() | { type: "string" } | | z.number() | { type: "number" } | | z.boolean() | { type: "boolean" } | | z.array() | { type: "array", items: ... } | | z.object() | { type: "object", properties: ... } | | z.enum() | { type: "string", enum: [...] } | | z.optional() | Removes from required | | z.default() | Adds default value | | z.describe() | Adds description |

Example:

import { z } from "zod";
import { zodToJsonSchema } from "@procedures/mcp";

const schema = z.object({
  path: z.string().describe("File path"),
  encoding: z.enum(["utf8", "base64"]).default("utf8"),
});

const jsonSchema = zodToJsonSchema(schema);
// {
//   type: "object",
//   properties: {
//     path: { type: "string", description: "File path" },
//     encoding: { type: "string", enum: ["utf8", "base64"], default: "utf8" }
//   },
//   required: ["path"]
// }

procedureToMcpTool

Converts a single procedure to an MCP tool definition.

function procedureToMcpTool(procedure: Procedure): McpTool;

interface McpTool {
  name: string;           // Dot-joined path: "fs.read"
  description: string;    // From procedure metadata
  inputSchema: JsonSchema; // Converted from Zod
}

Example:

const tool = procedureToMcpTool(fsReadProcedure);
// {
//   name: "fs.read",
//   description: "Read file contents",
//   inputSchema: { type: "object", properties: { path: ... } }
// }

proceduresToMcpTools

Converts multiple procedures to MCP tools with optional filtering.

function proceduresToMcpTools(
  procedures: Procedure[],
  filter?: McpToolFilter
): McpTool[];

Example:

// Convert all procedures
const allTools = proceduresToMcpTools(PROCEDURE_REGISTRY.getAll());

// Convert with filtering
const filteredTools = proceduresToMcpTools(procedures, {
  includeTags: ["fs", "git"],
  excludeInternal: true,
});

Tool Filtering

Control which procedures are exposed as MCP tools:

interface McpToolFilter {
  includeTags?: string[];      // Only include procedures with these tags
  excludeTags?: string[];      // Exclude procedures with these tags
  excludeInternal?: boolean;   // Exclude procedures starting with _
  pathPrefix?: string[];       // Only include procedures with this path prefix
  include?: (path: string[]) => boolean;  // Only the procedures for which it gives true
}

Filter Examples

graph TB
    subgraph "Original (10 procedures)"
        All[fs.read, fs.write, git.commit,<br/>_internal.debug, api.users, ...]
    end

    subgraph "excludeInternal: true"
        NoInt[fs.read, fs.write, git.commit,<br/>api.users, ...]
    end

    subgraph "pathPrefix: ['fs']"
        FSOnly[fs.read, fs.write]
    end

    subgraph "includeTags: ['public']"
        Public[Tagged as public only]
    end

    All --> NoInt
    All --> FSOnly
    All --> Public

Usage:

import { proceduresToMcpTools, type McpToolFilter } from "@procedures/mcp";

const filter: McpToolFilter = {
  includeTags: ["fs", "git"],      // Only the procedures with these tags
  excludeTags: ["internal"],       // Exclude internal
  excludeInternal: true,           // Exclude _prefixed
  pathPrefix: ["fs"],              // Only fs.* procedures
};

const tools = proceduresToMcpTools(procedures, filter);

Integration

With client-mcp

import { McpServerTransport } from "@procedures/mcp-server";
import { proceduresToMcpTools } from "@procedures/mcp";

// client-mcp uses mcp internally
const transport = new McpServerTransport(server, {
  transport: "stdio",
  // Filter uses McpToolFilter from mcp package
  filter: {
    excludeInternal: true,
  },
});

Package Hierarchy

graph BT
    subgraph "Implementation"
        Impl[impl-mcp-dev]
    end

    subgraph "Transport"
        ClientMCP[client-mcp]
    end

    subgraph "Core"
        MCP[mcp]
        Client[client]
    end

    subgraph "External"
        SDK[@modelcontextprotocol/sdk]
    end

    Impl --> ClientMCP
    ClientMCP --> MCP
    ClientMCP --> Client
    MCP --> Client
    ClientMCP --> SDK

Requirements

  • Node.js >= 22
  • Dependencies:
    • @procedures/client
    • zod

License

MIT