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

@tmcp/transport-cli

v0.0.3

Published

CLI transport for TMCP with static JSON-first tool commands

Readme

@tmcp/transport-cli

A CLI transport for TMCP that exposes your MCP tools as static, JSON-first commands. It is designed for agent-driven usage: tools are invoked with JSON input, schemas can be inspected directly, and output can be narrowed before it leaves stdout.

Installation

pnpm add @tmcp/transport-cli tmcp

Usage

import { McpServer } from 'tmcp';
import { CliTransport } from '@tmcp/transport-cli';
import { ZodJsonSchemaAdapter } from '@tmcp/adapter-zod';
import { z } from 'zod';

const server = new McpServer(
	{
		name: 'my-cli',
		version: '1.0.0',
		description: 'My CLI tool',
	},
	{
		adapter: new ZodJsonSchemaAdapter(),
		capabilities: { tools: {} },
	},
);

server.tool(
	{
		name: 'greet',
		description: 'Greet someone by name',
		schema: z.object({
			name: z.string(),
			loud: z.boolean().optional(),
		}),
		outputSchema: z.object({
			message: z.string(),
		}),
	},
	async (input) => {
		const message = `Hello, ${input.name}!`;

		return {
			content: [
				{
					type: 'text',
					text: input.loud ? message.toUpperCase() : message,
				},
			],
			structuredContent: { message },
		};
	},
);

const cli = new CliTransport(server);
await cli.run(undefined, process.argv.slice(2));

Commands

tools

Prints the available tools as pretty JSON.

node my-cli.js tools

schema <tool>

Prints the tool metadata plus its input and output schemas.

node my-cli.js schema greet

call <tool> [input]

Calls a tool with a JSON object. The first positional argument is the primary input source.

node my-cli.js call greet '{"name":"Alice"}'

<tool> [input]

Each tool name is also registered directly as an alias for call <tool>, unless the tool name would collide with a reserved command (tools, schema, or call).

node my-cli.js greet '{"name":"Alice","loud":true}'

Input sources

Tool calls accept exactly one input source:

  • Positional JSON: greet '{"name":"Alice"}'

All inputs must parse to a JSON object. If no input is provided, the transport sends {}.

Output controls

Tool calls support two static output flags:

  • --output full|structured|content|text
  • --fields path1,path2

Examples:

node my-cli.js greet '{"name":"Alice"}' --output text

node my-cli.js get-user '{"id":"1"}' --output structured --fields user.name,user.email

--fields uses comma-separated dot paths and is applied after the output mode is selected. It is not available with --output text.

Behavior

  • Output is written to stdout.
  • JSON outputs are pretty-printed.
  • Errors are written to stderr and set process.exitCode to 1.
  • Running the CLI without a command prints help output.
  • The CLI initializes an MCP session, sends notifications/initialized, and paginates through tools/list automatically.
  • The program name shown in help output comes from McpServer's name.

Custom context

If your server uses custom context, pass it as the first argument to run():

const cli = new CliTransport(server);
await cli.run({ userId: 'cli-user' }, process.argv.slice(2));

The context is forwarded on every request, so handlers can read it from server.ctx.custom.

API

CliTransport

Constructor

new CliTransport(server: McpServer)

Methods

run(ctx?: TCustom, argv?: string[]): Promise<void>

Starts the CLI, initializes a session, discovers tools, and executes the requested static command or tool alias.

Related Packages

Acknowledgments

Huge thanks to Sean O'Bannon that provided us with the @tmcp scope on npm.

License

MIT