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

mcp-2-cli

v0.0.2

Published

Convert any MCP server to a CLI application

Readme

mcp-2-cli

Convert a Model Context Protocol (MCP) server to a CLI application.

This is useful if you want to use an MCP server's tools, resources, and prompts outside an MCP client. The mcp-2-cli library acts as a MCP client with the CLI as the interface.

You may want to use an MCP server's tools inside an Agent Skill or in a programmatic script.

Features

  • Automatically generates CLI commands from MCP server capabilities
  • Supports MCP prompts, resources, and tools
  • JSON Schema validation for tool arguments
  • Graceful error handling with JSONRPC error support

Supported Server Types

Currently, mcp-2-cli only supports stdio MCP servers.

Support for Streamable HTTP servers coming soon!

Configuration

You must first create a JSON configuration file with the following schema:

{
    "command": "<root command>", // Required
    "args": ["--additional", "args"] // Optional
    "transport": "stdio" // Required. currently only "stdio" supported
    "cliName": "<name>" // Optional. defaults to "mcp-cli"
}

For example:

{
  "command": "npx",
  "args": ["-y", "@modelcontextprotocol/server-filesystem", "."],
  "transport": "stdio",
  "cliName": "fs-cli"
}

mcp-2-cli will first look for this file in the environment variable MCP_2_CLI_CONFIG_PATH. If the environment variable is not provided, mcp-2-cli will look for a file named mcp-2-cli.config.json in the current directory.

To run the MCP CLI, you can use npx:

MCP_2_CLI_CONFIG_PATH="path/to/config.json" npx mcp-2-cli <args...>

CLI Commands

An mcp-2-cli CLI automatically get commands for all available prompts, resources, and tools.

The generated CLI follows CLI best practices, with nested actions and --help commands.

The CLI commands use the following pattern:

mcp-cli <action> <name> --arg1 val1 --arg2 val2 ... 

For example, to use the server-filesystem MCP's read_text_file tool:

server-filesystem tools read_text_file --path path/to/file.ext

If there are not any available actions for one of the prompts, resources or tools action categories, those actions categories will not be listed. For example, if your server supports only tools but no prompts and resources, only mcp-cli tools would be a valid command.

Prompts

# List all available prompts
mcp-cli prompts -help

# Get a specific prompt 
mcp-cli prompts <prompt-name>
# Get help with specific prompt
mcp-cli prompts <prompt-name> --help

Resources

# List all available resources
mcp-cli resources -help

# Get a specific resource
mcp-cli resources <resource-uri>
# Get help with a specific resource
mcp-cli resources <resource-uri> --help

Tools

# List all available tools
mcp-cli tools --help

# Call a tool (with optional arguments as JSON)
mcp-cli tools <tool-name> 
# Get help with a specific tool
mcp-cli tools <tool-name> --help

Use as Library

Installation

npm install mcp-2-cli

Basic Example

import { createMcpCli } from 'mcp-2-cli';

const config = {
  command: 'npx',
  args: ['-y', '@modelcontextprotocol/server-filesystem', '/tmp'],
  transport: 'stdio',
  name: "filesystem-cli"
};

const cli = await createMcpCli(config);
await cli.parseAsync();