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

MCP Runner

MCP Server

A TypeScript SDK for running MCP (Model Context Protocol) servers with process reuse capabilities

工具数

0

提示词数

0

GitHub Stars

6

资源数

0
命令行工具TypeScript服务器管理

安装说明

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

作者 / 组织

cookiecad

提供方

cookiecad

最后核验

2026/5/18 02:15

快速接入

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

详细介绍

mcp跑步者

用于运行MCP(模型上下文协议)服务器的TypeScript SDK和CLI。

概述

mcp-runner 旨在根据中定义的配置促进MCP服务器的执行 cline_mcp_settings.json。它支持可重用的服务器进程和受控清理,允许使用同一服务器实例执行多个操作。

您可以从命令行调用它,也可以将其用作您自己的TypeScript项目中的库,甚至可以从其他MCP服务器调用。

特性

  • 跨多个调用重用服务器进程
  • 优雅的终止和超时处理
  • 自动服务器生命周期管理
  • TypeScript支持
  • 错误处理和日志

安装

npm install

CLI使用情况

该软件包包括一个用于与MCP服务器交互的命令行界面。

命令

列出工具

列出指定MCP服务器的所有可用工具:

npm run cli -- list-tools 

例子:

npm run cli -- list-tools sequential-thinking

运行服务器

使用可选工具名称和参数运行指定的MCP服务器:

npm run cli -- runserver  [tool-name] [params] [options]
# or
npm run cli -- runserver  [params] [options] # uses first available tool

选项:

  • --text:仅输出响应中的文本内容,而不是完整的JSON

示例:

# Run a specific tool
npm run cli -- runserver sequential-thinking sequentialthinking '{"thought": "Initial thought", "thoughtNumber": 1, "totalThoughts": 5, "nextThoughtNeeded": true}'

# Use first available tool
npm run cli -- runserver sequential-thinking '{"thought": "Initial thought", "thoughtNumber": 1, "totalThoughts": 5, "nextThoughtNeeded": true}'

# Output only text content
npm run cli -- runserver sequential-thinking sequentialthinking '{"thought": "Initial thought", "thoughtNumber": 1, "totalThoughts": 1}' --text

程序化使用

基础示例

import { runServer, terminateServer } from 'mcp-runner';

async function main() {
  try {
    // First call (specific tool)
    const result1 = await runServer('openrouterai', 'chat_completion', {
      messages: [
        { role: 'user', content: 'Say hello!' }
      ]
    });
    console.log('Result 1:', result1);

    // Second call (uses first available tool)
    const result2 = await runServer('openrouterai', undefined, {
      messages: [
        { role: 'user', content: 'How are you?' }
      ]
    });
    console.log('Result 2:', result2);

    // Terminate server when done
    await terminateServer();
  } catch (error) {
    console.error('Error:', error);
    await terminateServer();
  }
}

错误处理

SDK包括全面的错误处理:

  • 服务器进程错误
  • 工具执行错误
  • 优雅终止的超时处理
  • 自动清除错误

API

runServer(服务器名称:字符串,参数:记录\)

使用提供的参数在指定的服务器上运行工具。在明确终止之前,服务器进程将重复用于后续调用。

参数:

  • serverName:配置中的服务器名称
  • params:传递给服务器工具的参数

返回:使用服务器的响应解析Promise

terminateServer()

终止SDK管理的服务器进程。应在所有操作完成后调用。

返回:当服务器终止时解析的Promise

建筑

服务器管理器

ServerManager 类被实现为管理MCP服务器进程生命周期的单例。主要职责包括:

  • 流程生命周期管理
  • 客户端连接处理
  • 优雅的终止
  • 错误处理和日志

管理器确保在任何给定时间只有一个服务器进程在运行,并提供启动、重用和终止服务器的方法。

配置

SDK从以下位置读取服务器配置 cline_mcp_settings.json,它应该位于标准配置目录中。每个服务器配置包括:

{
  "command": "string",
  "args": "string[]",
  "env": "Record",
  "disabled": "boolean",
  "alwaysAllow": "string[]"
}

发展

建筑

npm run build

运行测试

npm test

许可证

此项目根据Mozilla公共许可证2.0获得许可-请参阅 许可证 文件以获取详细信息。

贡献

欢迎投稿!请随时提交拉取请求。

目录标签

目录标签

命令行工具TypeScript服务器管理developer-toolsmcp-runnertypescript-sdkmcp-serversMCP协议本地部署CLI工具SDK

接入字段

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

未说明

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

none

工具数量(toolCount,工具数)

0

资源数量(resourceCount,资源数)

0

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

0

权限和风险

未说明none部署方式未说明

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

安装前确认

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

仍需确认:installCommand

来源信息

继续浏览同类 MCP