A universal CLI for working with Model Context Protocol (MCP) servers from your terminal, CI jobs, and automation scripts.
mcp-cli lets you:
- list configured MCP servers,
- fetch and inspect available tools,
- search tools by relevance (
tool-search) to reduce context bloat, - call tools with JSON arguments from inline text, files, or stdin.
Built with TypeScript and designed to work with both:
- stdio transport (spawn an MCP server process locally), and
- HTTP transport (JSON-RPC over HTTP).
When many tools are available, sending every tool schema to an LLM or automation pipeline can be wasteful. mcp-cli includes a practical tool-search command that ranks tools locally and returns only the top matches (with optional schema limiting), so your workflows stay lean and predictable.
- Node.js 18+
- npm
npm install
npm run buildRun directly from source in dev mode:
npm run dev -- --helpOr run the built CLI:
node dist/index.js --helpIf installed globally (or linked), the executable name is:
mcp- Create a global config in
~/.mcp-cli/config.json. - Define at least one server.
- Run:
mcp servers
mcp tools --server <name>
mcp tool-search "create pull request" --server <name>mcp-cli reads configuration from:
- global:
~/.mcp-cli/ - project-local:
./mcp-cli/(overrides global)
Supported config files (first match in each directory):
config.jsonconfig.yamlconfig.yml
{
"defaultServer": "demo-http",
"strictEnv": false,
"servers": {
"demo-http": {
"transport": "http",
"url": "http://localhost:8080/mcp",
"headers": {
"Authorization": "Bearer ${MCP_DEMO_TOKEN}"
},
"timeoutMs": 60000,
"summary": "Demo HTTP MCP server"
},
"demo-stdio": {
"transport": "stdio",
"command": "node",
"args": ["./servers/demo/build/index.js"],
"cwd": "${PWD}",
"env": {
"DEMO_TOKEN": "${DEMO_TOKEN}"
},
"summary": "Demo stdio MCP server"
}
},
"cache": {
"enabled": true,
"ttlSeconds": 300,
"maxOutputBytes": 262144
},
"toolSearch": {
"defaultLimit": 5,
"defaultSchemas": 3
}
}Any string value can use ${VAR} placeholders.
- If
strictEnv: true, missing variables cause an error. - If
strictEnv: false(default), unresolved placeholders are left as-is.
Server selection precedence:
--server <name>MCP_CLI_SERVERenvironment variabledefaultServerfrom config
Global options:
--server <name>--output <format>(json|text)--pretty--config-dir <path>--no-cache--cache-ttl <seconds>
List configured servers.
Text output:
<name>\t<transport>\t<summary>
JSON output:
{ "servers": [ ... ] }List tools available on the selected server.
Examples:
mcp tools --server demo-http
mcp tools --server demo-http --output json --prettyReturn details for a single tool.
Example:
mcp describe github.createPullRequest --server github --prettyRank tools by relevance and return a compact JSON payload.
Options:
--limit <n>--schemas <n>--no-schemas--explain
Examples:
mcp tool-search "create jira ticket" --server jira
mcp tool-search "open pull request" --server github --limit 5 --schemas 2 --explain --prettyNotes:
- By default, only top schema entries are included to keep output small.
- If output exceeds configured max size, schemas/results are truncated and a warning is emitted.
Call a tool with JSON input.
Input modes (exactly one):
--args '{"k":"v"}'--args-file ./payload.json--args-stdin
Examples:
mcp call jira.createIssue --server jira --args '{"project":"ENG","summary":"Bug report"}'
cat payload.json | mcp call jira.createIssue --server jira --args-stdinTool lists are cached per server to improve repeat performance.
- Default location:
- Linux/macOS:
${XDG_CACHE_HOME:-~/.cache}/mcp-cli - Windows:
%LOCALAPPDATA%\\mcp-cli
- Linux/macOS:
- Default TTL:
300seconds - Disable per command:
--no-cache - Override TTL:
--cache-ttl <seconds>
tool-searchandcallalways emit JSON.serversandtoolssupport text and JSON output.--prettyformats JSON with indentation.
- The CLI sets non-zero exit codes on errors.
describesets exit code2when a tool is not found.- Invalid JSON passed to
callargument options returns an input error.
npm install
npm test
npm run buildProject layout:
src/index.ts— CLI commands and option wiringsrc/config.ts— config loading, merge precedence, env expansionsrc/client.ts— stdio/HTTP JSON-RPC client transportssrc/search.ts— local relevance scoring/rankingsrc/cache.ts— tool list cachesrc/io.ts— argument parsing helperstest/*.ts— unit tests (Vitest)
- “No server selected”: pass
--server, setMCP_CLI_SERVER, or setdefaultServer. - “Server not found in config”: verify merged config contains that server name.
- HTTP call errors: verify
url, headers, and server availability. - stdio call errors: verify
command,args,cwd, and environment variables. - JSON input errors: validate payload syntax and ensure only one of
--args,--args-file,--args-stdinis used.
No license file is currently included in this repository.