Token导航 LogoToken导航TokenDH.com
MCP Gateway CLI logo
开发工具未说明官方级别未说明来源级核验

MCP Gateway CLI

MCP Server

一个用于与MCP服务器交互的命令行工具,支持发现工具、缓存模式以及从终端直接调用工具。

工具数

2

提示词数

0

GitHub Stars

2

资源数

0
命令行工具工具发现Go

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

VincentK1991

提供方

VincentK1991

最后核验

2026/5/17 20:20

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

详细介绍

网关cli

用于与进行交互的命令行工具 主控程序 服务器。它发现注册的MCP服务器暴露的工具,缓存它们的模式,并允许您直接从终端调用它们——完全支持管道、脚本和与其他CLI工具的组合。

______________________________________________________________________

安装

Homebrew(macOS和Linux)

brew install VincentK1991/tap/gateway-cli

curl(macOS和Linux)

curl -fsSL https://raw.githubusercontent.com/VincentK1991/mcp-gateway-cli/main/install.sh | bash

这会检测您的操作系统和架构,从最新的GitHub版本下载正确的二进制文件,验证校验和,并安装到 /usr/local/bin.

要安装特定版本,请执行以下操作:

VERSION=v1.2.0 curl -fsSL https://raw.githubusercontent.com/VincentK1991/mcp-gateway-cli/main/install.sh | bash

去安装(需要Go 1.23+)

go install github.com/VincentK1991/mcp-gateway-cli@latest

验证安装

gateway-cli --version

______________________________________________________________________

注册MCP服务器

MCP服务器已在中注册 ~/.gateway-cli/config.yaml。如果文件不存在,请创建该文件:

mcps:
  calculator:
    url: http://localhost:8000/mcp
  matrix:
    url: http://localhost:8001/mcp

每个条目都需要一个名称(用作CLI子命令)和MCP服务器的URL /mcp 终点。

对于需要身份验证或自定义标头的MCP服务器,添加 headers 块:

mcps:
  calculator:
    url: http://localhost:8000/mcp
  my-api:
    url: https://api.example.com/mcp
    headers:
      Authorization: "Bearer mytoken"
  another-api:
    url: https://other.example.com/mcp
    headers:
      Authorization: "Bearer ${MY_API_TOKEN}"   # reads from environment variable
      X-Tenant-Id: "acme"

标头值支持环境变量扩展--使用 ${VAR} 避免将机密直接存储在配置文件中。在运行任何命令之前,在shell中设置变量:

export MY_API_TOKEN="your-secret-token"
gateway-cli my-api some-tool --flag value

编辑配置后,刷新模式缓存:

gateway-cli schema refresh

您可以检查发现的内容:

gateway-cli schema info
Last fetched : 2026-03-16 22:29:12
MCP servers  : 2
Total tools  : 2

  calculator (1 tools)
    calculate            Perform a basic integer calculation.

  matrix (1 tools)
    process_matrix       Perform matrix operations on 1D/2D arrays or scalars.

______________________________________________________________________

运行工具

工具调用方式如下: gateway-cli [flags]

每个工具的标志都是根据其输入模式自动生成的。使用 --help 查看可用标志:

gateway-cli calculator calculate --help
gateway-cli matrix process_matrix --help

基本示例:

# Integer arithmetic
gateway-cli calculator calculate --a 10 --b 5 --operation add
gateway-cli calculator calculate --a 10 --b 3 --operation mul
gateway-cli calculator calculate --a 10 --b 0 --operation div   # returns error gracefully

# Vector operations
gateway-cli matrix process_matrix --a '[1,2,3]' --b '[4,5,6]' --operation add

# Matrix dot product
gateway-cli matrix process_matrix --a '[[1,2],[3,4]]' --b '[[5,6],[7,8]]' --operation dot

______________________________________________________________________

合成工具输出

使用 --json / -j 标记以剥离MCP信封并仅返回结构化结果。这使得将工具链接在一起变得简单明了:

# Step 1: compute a scale factor
# Step 2: use it as input to the matrix tool
SCALE=$(gateway-cli --json calculator calculate --a 3 --b 4 --operation mul | jq '.result | floor')
gateway-cli --json matrix process_matrix --a '[[1,2],[3,4]]' --b "$SCALE" --operation mul
{
  "error": null,
  "result": [[12, 24], [36, 48]]
}

多级管道:

# Chain three calculator calls
A=$(gateway-cli --json calculator calculate --a 2 --b 3 --operation add | jq '.result | floor')
B=$(gateway-cli --json calculator calculate --a 4 --b 2 --operation mul | jq '.result | floor')
gateway-cli --json calculator calculate --a "$A" --b "$B" --operation add | jq '.result'
# → 13

______________________________________________________________________

与其他CLI工具结合使用

输出是标准的JSON,因此它与Unix工具链自然集成。

jq——提取和转换:

# Extract just the result value
gateway-cli --json calculator calculate --a 10 --b 3 --operation mul | jq '.result'

# Extract matrix rows
gateway-cli --json matrix process_matrix --a '[[1,2],[3,4]]' --b '[[5,6],[7,8]]' --operation dot \
  | jq '.result[]'

将输出保存到文件:

gateway-cli --json matrix process_matrix --a '[[1,2],[3,4]]' --b '[[5,6],[7,8]]' --operation dot \
  > result.json

在shell脚本中使用:

#!/bin/bash
for op in add sub mul; do
  echo -n "$op: "
  gateway-cli --json calculator calculate --a 10 --b 3 --operation "$op" | jq '.result'
done

插入其他工具(fx, python等等):

# Interactive JSON explorer
gateway-cli --json matrix process_matrix --a '[[1,2],[3,4]]' --b '[[5,6],[7,8]]' --operation dot | fx

# Process in Python
gateway-cli --json calculator calculate --a 10 --b 3 --operation add \
  | python3 -c "import sys, json; d = json.load(sys.stdin); print(f'Result is {d[\"result\"]}')"

______________________________________________________________________

架构缓存管理

gateway-cli schema refresh      # force re-fetch from all MCP servers
gateway-cli schema info         # show cached MCPs and tools
gateway-cli schema invalidate   # delete the cache

每个命令上都有可用的标志:

标志描述
--json, -j仅输出结构化内容(无MCP信封)
--text, -t将第一个文本内容项以纯字符串形式输出
--refresh-schema运行命令前重新获取架构
--offline仅使用缓存的架构,切勿联系MCP服务器
--config自定义配置文件的路径

检查并更新您的版本

# Show installed version
gateway-cli --version

# Homebrew
brew upgrade gateway-cli

# curl (re-runs the installer, overwrites the binary)
curl -fsSL https://raw.githubusercontent.com/VincentK1991/mcp-gateway-cli/main/install.sh | bash

# Go install
go install github.com/VincentK1991/mcp-gateway-cli@latest

gateway-cli还会在后台自动检查新版本(最多每天一次),并在有新版本可用时向stderr打印提醒。

目录标签

目录标签

命令行工具工具发现Go本地部署MCP服务器模式缓存脚本集成

接入字段

传输方式(transport,传输协议)

未说明

鉴权方式(authType,认证方式)

token

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

未说明token部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

仍需确认:installCommand

来源信息

继续浏览同类 MCP