Skip to main content

Minimal MCP client CLI

Project description

remote-mcp-cli

A minimal command-line MCP client that makes it easy to call tools from local (stdio) and remote (Streamable HTTP) MCP servers using terminal commands. This project was created to add MCP support for coding agents like OpenAI's Codex, which can now use any MCP server through the terminal.

Works with your project's existing Cursor mcp.json config file.

Quick Start

1. Set up your MCP config file

Create ./.cursor/mcp.json (or ./mcp.json at project root) with your MCP servers:

{
  "mcpServers": {
    "context7": {
      "url": "https://mcp.context7.com/mcp"
    },
    "ref": {
      "command": "bunx",
      "args": ["-y", "ref-tools-mcp@latest"],
      "env": {
        "REF_API_KEY": "your-api-key-here"
      }
    }
  }
}

2. Set environment variables (for protected servers)

export REF_API_KEY="your-actual-api-key"

3. Go!

# Reads config and creates/updates mcp_tools.txt with all available tools, schemas, and example commands.
uvx remote-mcp-cli init

# List tools by server alias
uvx remote-mcp-cli list context7

# Call tools by server alias - no URLs or API keys needed!
uvx remote-mcp-cli call context7 resolve-library-id '{"libraryName":"react"}'
uvx remote-mcp-cli call ref ref_search_documentation '{"query":"nextjs caching"}'

Traditional Installation

You can also install traditionally with uv:

uv pip install remote-mcp-cli

💡 Tip: The simplified interface works great with AI assistants! Tell your agent to read mcp_tools.txt to understand which tools are available, and it can call tools using commands like uvx remote-mcp-cli call context7 resolve-library-id '{"libraryName":"react"}'

CLI Architecture

remote-mcp-cli features a clean 4-command interface:

  1. init - Discovers all servers from your MCP config and generates mcp_tools.txt with all available tools, schemas, and example commands.
  2. list <server-alias> - Lists available tools for a single server from mcp.json
  3. call <server-alias> <tool-name> <args> - Call a tool
  4. direct - Direct URL access for remote servers (no config needed)

Config File Discovery

The CLI automatically finds your MCP config in this priority order:

  1. .cursor/mcp.json (Cursor IDE projects)
  2. mcp.json (global fallback)
  3. --configpath (explicit path)

If none of these are found, the init command will fail.

Server Types Supported

Remote MCP servers (Modern MCP 2025-06-18 spec):

  • Zero setup: Just add the URL to your config
  • Automatic transport: Supports both modern Streamable HTTP and legacy REST
  • Built-in auth: Headers and bearer tokens from config
  • Examples: Context7, ref-tools, custom HTTP servers

Local MCP servers (stdio):

  • npx/bunx integration: Automatically spawns and manages processes
  • Environment security: Validates required env vars are set in terminal
  • Auto-detection: Tries HTTP first, falls back to stdio if needed
  • Examples: Any bunx or npx MCP package

Features

  • 🎯 Simplified Interface: Use server aliases instead of URLs and API keys
  • 🔒 Environment Security: Validates API keys are set in terminal environment
  • 📁 Config Discovery: Automatically finds .cursor/mcp.json or mcp.json
  • 🚀 Auto Transport: Detects HTTP vs stdio and chooses the best transport
  • 📋 Tool Discovery: init command generates mcp_tools.txt with all available tools
  • ⚡ Modern MCP: Full support for MCP Streamable HTTP transport (2025-06-18 spec)
  • 🔄 Legacy Support: Automatically falls back to older REST endpoints
  • 🎨 Rich Schemas: Shows parameter names, types, and required fields

Usage

Core Commands

# Initialize all tools from MCP config into mcp_tools.txt
uvx remote-mcp-cli init

# List tools by server alias (from config)
uvx remote-mcp-cli list <server-alias>

# Call tools by server alias (from config)
uvx remote-mcp-cli call <server-alias> <tool-name> <json-args>

# Direct URL access (no config needed)
uvx remote-mcp-cli direct list --url <server-url>
uvx remote-mcp-cli direct call --url <server-url> <tool-name> <json-args>

Config-Based Examples

Step 1: Initialize tools from config

uvx remote-mcp-cli init
# ✓ Processed 2 servers successfully
# → mcp_tools.txt written with 5 tools total

Step 2: Use simplified interface

# List tools by alias
uvx remote-mcp-cli list context7

# Call tools by alias - credentials come from environment
uvx remote-mcp-cli call context7 resolve-library-id '{"libraryName":"react"}'
uvx remote-mcp-cli call ref ref_search_documentation '{"query":"nextjs"}'

Generated mcp_tools.txt shows all available tools:

### Server: context7  (https://mcp.context7.com/mcp)
- resolve-library-id: Resolves a package/product name to a Context7-compatible library ID...
  Parameters: *libraryName(string)
  (* = required)
  Example: uvx remote-mcp-cli call context7 resolve-library-id '{"libraryName": "VALUE"}'

### Server: ref  (local npx, stdio)
- ref_search_documentation: A powerful search tool to check technical documentation...
  Parameters: *query(string)
  (* = required)
  Example: uvx remote-mcp-cli call ref ref_search_documentation '{"query": "VALUE"}'

Configuration File Format

Remote servers (HTTP/HTTPS):

{
  "mcpServers": {
    "context7": {
      "url": "https://mcp.context7.com/mcp"
    },
    "authenticated-server": {
      "url": "https://api.example.com/mcp",
      "headers": {
        "Authorization": "Bearer your-token",
        "x-api-key": "your-key"
      }
    }
  }
}

Local servers (stdio):

{
  "mcpServers": {
    "ref": {
      "command": "bunx",
      "args": ["-y", "ref-tools-mcp@latest"],
      "env": {
        "REF_API_KEY": "ref_1234567890abcdef"
      }
    },
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/files"]
    }
  }
}

Environment Variable Security: The CLI validates that environment variables (like REF_API_KEY) are actually set in your terminal before connecting. This prevents accidentally using placeholder values from the config file.

Direct URL Access (No Config)

For one-off usage without setting up a config file, use the direct command:

# List tools directly
uvx remote-mcp-cli direct list --url https://mcp.deepwiki.com/mcp

# Call tools directly with authentication
uvx remote-mcp-cli direct call \
  --url https://api.ref.tools/mcp \
  --header "x-ref-api-key: YOUR_KEY" \
  read_documentation \
  '{"query": "nextjs routing"}'

# Bearer token authentication
uvx remote-mcp-cli direct list \
  --url https://secure-server.com/mcp \
  --bearer "your-token"

Transport Priority

The CLI automatically detects and tries transports in this order:

  1. Streamable HTTP (modern MCP 2025-06-18 spec)
  2. Legacy REST (older /manifest, /call_tool endpoints)
  3. Stdio JSON-RPC (for local spawned servers)

Help & Support

# Get overall help
uvx remote-mcp-cli --help

# Help for specific commands
uvx remote-mcp-cli init --help
uvx remote-mcp-cli list --help
uvx remote-mcp-cli call --help
uvx remote-mcp-cli direct --help

Development

Building and Publishing

To build and publish the package with uv:

uv build
uv pip install --system twine
uv twine upload dist/*

MCP Protocol Support

This CLI implements:

  • MCP Protocol Version: 2025-06-18
  • JSON-RPC 2.0 message format over stdio
  • Streamable HTTP transport with SSE support
  • Session management via Mcp-Session-Id headers
  • Proper initialization handshake
  • Tool discovery and execution
  • Environment variable validation for security

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

remote_mcp_cli-0.8.0.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

remote_mcp_cli-0.8.0-py3-none-any.whl (14.1 kB view details)

Uploaded Python 3

File details

Details for the file remote_mcp_cli-0.8.0.tar.gz.

File metadata

  • Download URL: remote_mcp_cli-0.8.0.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for remote_mcp_cli-0.8.0.tar.gz
Algorithm Hash digest
SHA256 0d8a0e9ff63e9cddecfe923ce79db0c3fd0416e6d4d9240f45b1823a1add14b1
MD5 5a174cb651c24fc0e70c8ac6246eff76
BLAKE2b-256 f4dfab456de3bdb8c2b7ea0f64f00ae5069e752dce06e50a7e38e65a423640d2

See more details on using hashes here.

File details

Details for the file remote_mcp_cli-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: remote_mcp_cli-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 14.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for remote_mcp_cli-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cb22e903dde10ea2c834c814ee3bd3182fc2f2e1e28b2913020db50fa776ff2
MD5 fe5231c764b8c8d87a28920ca65dfb7b
BLAKE2b-256 184b7c6aabfdc1f0ffacbb56d87171d57ca2e0e72cae73728e4f57e53e4b2a26

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page