htsc-mcp-proxy
v0.8.7
Published
A stateless stdio MCP forwarder: tools, resources and prompts pass through to a remote MCP server unmodified.
Maintainers
Readme
htsc-mcp-proxy
一个极简的、无状态的 MCP 转发服务。把 tools / resources / prompts 透传给远程 MCP server——远端返回什么就原样转告什么,不做任何加工。
安装
npm install -g htsc-mcp-proxy或用 npx 直接运行,无需安装:
npx htsc-mcp-proxy insight-stock-data sk-12312312312需要 Node.js ≥ 18。
启动
htsc-mcp-proxy # 默认 prod 环境
htsc-mcp-proxy insight-stock-data # 指定服务
htsc-mcp-proxy insight-stock-data sk-12312312312 # 服务 + app key
htsc-mcp-proxy --help # 查看全部用法位置参数按值识别、顺序无关,以下几个写法等价:
htsc-mcp-proxy insight-stock-data sk-12312312312
htsc-mcp-proxy sk-12312312312 insight-stock-data| 位置参数的值 | 作用 |
| --- | --- |
| <service>-<name>-data | 选服务,决定远端 URL 路径 |
| prod | 生产环境(默认,不传也是它) |
| 其它任意值(如 sk-xxx) | app key |
同名参数也可用 --app-key <值>、环境变量等方式传入,详见 --help。
服务名 → URL 规则
服务名不需要注册表,URL 直接从名字推导,新增远端服务无需改代码:
<service>-<name>-data -> https://inst.htsc.com/mcp/v1/<service>/<name>| 服务名 | 实际地址 |
| --- | --- |
| insight-stock-data | https://inst.htsc.com/mcp/v1/insight/stock |
| insight-index-data | https://inst.htsc.com/mcp/v1/insight/index |
| insight-bond-data | https://inst.htsc.com/mcp/v1/insight/bond |
| insight-fund-data | https://inst.htsc.com/mcp/v1/insight/fund |
| insight-option-data | https://inst.htsc.com/mcp/v1/insight/option |
| foo-bar-data | https://inst.htsc.com/mcp/v1/foo/bar |
<service>是第一个短横线分段(只允许字母、数字);<name>可含短横线(如insight-my-thing-data→/mcp/v1/insight/my-thing)- 任意
<service>都生效,不限于insight - 不传服务名时使用默认路径
/mcp/v1/insight/insight_mcp
接入 MCP 客户端
服务名与 app key 按位置传入,顺序无关:
{
"mcpServers": {
"insight": {
"command": "<启动方式,见下>",
"args": ["insight-stock-data", "sk-12312312312"]
}
}
}macOS / Linux
{
"mcpServers": {
"insight": {
"command": "npx",
"args": [
"--yes",
"--registry=https://registry.npmmirror.com",
"htsc-mcp-proxy@latest",
"insight-stock-data",
"sk-12312312312"
]
}
}
}--yes 跳过 npx 的安装确认;--registry 可换成其它镜像源(npm 官方源访问不畅时使用)。两者必须放在包名之前。
Windows
⚠️ 直接写
"command": "npx"在 Windows 上大概率起不来。 多数 MCP 宿主不经 shell 直接拉进程,而 Windows 的npx是批处理/脚本(不是可执行文件),会被以ENOENT拒绝——进程没起来,宿主往往还不报错,表现为"怎么重启都没反应"。
方式一:走 cmd 解析 npx(改动最小)
{
"mcpServers": {
"insight": {
"command": "cmd",
"args": [
"/c", "npx",
"--yes",
"htsc-mcp-proxy@latest",
"insight-stock-data",
"sk-12312312312"
]
}
}
}方式二:全局安装后用 node 指向绝对路径(最稳,推荐长期使用)
npm install -g htsc-mcp-proxy{
"mcpServers": {
"insight": {
"command": "C:\\Program Files\\nodejs\\node.exe",
"args": [
"C:\\Users\\<你>\\AppData\\Roaming\\npm\\node_modules\\htsc-mcp-proxy\\dist\\mcp-auth-proxy.mjs",
"insight-stock-data",
"sk-12312312312"
]
}
}
}node 与脚本的绝对路径以实际安装位置为准(npm root -g 可查)。该写法同时摆脱了对 shell 与 PATH 的依赖,跨宿主最稳。
若已全局安装,也可以直接指向 bin(npx 的思路):
{
"mcpServers": {
"insight": {
"command": "htsc-mcp-proxy",
"args": ["insight-stock-data", "sk-12312312312"]
}
}
}注意:bin 同样是
.cmd垫片,无 shell 宿主下仍可能失败——Windows 上请优先用方式二。
通用建议
- 固定版本号:
@latest会在上游发布后静默升级,行为变了难排查;生产环境建议写死具体版本号(查看 npm 上的最新发布版本后填入)。 - app key 是明文:配置文件会被客户端读取、可能进日志。宿主支持环境变量引用时(如
${env:HTSC_APP_KEY})优先用变量。 - 首次调用返回 40101:属正常流程——本地 key 需要完成一次授权绑定,按返回信息中的链接登录即可,之后无需再管。
License
MIT
