Get the FREE Ultimate OpenClaw Setup Guide →

oclif-plugin

A plugin for the oclif CLI framework that automatically discovers commands and serves them through the Model Context Protocol (MCP).

Installation
Run this command in your terminal to add the MCP server to Claude Code.
Run in terminal:
Command
claude mcp add --transport stdio npjonath-oclif-plugin-mcp-server node <path_to_project_folder>/bin/dev.js mcp

How to use

This MCP server automatically exposes all commands from your oclif CLI as MCP-compliant tools. It enables AI assistants to discover, validate, and execute your CLI commands through conversation, using the MCP 2025-06-18 specification. Features include auto-discovery of oclif commands, type-safe argument schemas generated from your flags and arguments, and full support for MCP resources with lazy loading and structured prompts. You can run the server locally via the CLI’s built-in mcp transport (stdio) or expose it over HTTP for web clients, allowing clients to request command execution, fetch resource metadata, and receive progress and results in a standardized JSON format.

To use it, configure your AI assistant with an MCP configuration that points at your CLI’s MCP endpoint. The plugin supports multiple transport modes; stdio is ideal for local development, while the HTTP transport provides persistent sessions, OAuth 2.1 compatibility, and server-sent events for real-time updates. Once configured, you can ask the assistant to discover available commands, validate inputs, and execute tasks such as deploying, testing, or managing data, with the server translating natural language intents into precise CLI invocations.

How to install

Prerequisites:

  • Node.js (LTS version) and npm or yarn installed on your system
  • Access to the internet to install npm packages

Install from npm:

  1. Ensure your CLI includes the MCP server plugin in its dependencies: npm install oclif-plugin-mcp-server@latest

  2. If you are consuming the plugin directly as a server, install the MCP server package: npm install oclif-plugin-mcp-server@latest

  3. If you are developing locally, clone the repository and install dependencies: git clone https://github.com/npjonath/oclif-plugin-mcp-server.git cd oclif-plugin-mcp-server npm install

Configure and run the MCP server within your CLI project by wiring the plugin into your CLI and starting the MCP endpoint as described in your CLI’s docs. The README provides example configurations for embedding the plugin and starting the server via the mcp command.

Additional notes

Tips and notes:

  • Ensure MCP-Protocol-Version headers (MCP-Protocol-Version: 2025-06-18) are correctly emitted in responses when using the HTTP transport.
  • If using OAuth 2.1, PKCE, and token handling, configure the authorization endpoints as part of the HTTP transport flow.
  • The plugin supports zero-setup exposure of commands, with automatic schema generation for arguments and validation using Zod.
  • For local development, the stdio transport is simple and fast; for integrations with web clients or remote assistants, prefer the HTTP transport with proper session management and CORS settings.
  • When upgrading, verify compatibility with the MCP 2025-06-18 specification and test end-to-end command execution and resource access.
  • If you plan to run multiple CLIs, you can add multiple entries under mcpServers, each with its own command and arguments.

Related MCP Servers

Sponsor this space

Reach thousands of developers