Token导航 LogoToken导航

MCP Server · 开发工具

Node Stdio Jsonrpc

一个基于stdio的JSON-RPC 2.0客户端库,用于与子进程进行通信,支持TypeScript类型安全,适用于语言服务器、CLI工具等场景。

未说明官方级别未说明来源级核验工具 0
开发工具TypeScriptSession认证

快速开始

公开资料没有提供安装命令,按仓库或官方文档接入。
作者 / 组织
gnana997
提供方
gnana997

工具数量

0

来源目录标注

资源数量

0

来源目录标注

提示词数量

0

来源目录标注

GitHub Star

2

仓库热度

收录来源

1 个

MCP World

选型结论

Node Stdio Jsonrpc 属于开发工具类 MCP Server,公开资料标注 0 个工具,通过传输方式未标注接入,客户端适配情况以官方文档为准,没有现成的安装命令;接入前要先准备 会话凭据。

分类

开发工具

传输方式

未说明

认证方式

会话凭据

部署方式

公开资料未说明

安装与配置

公开目录没有给出安装命令,需要按仓库 README安装;下面按同类条目的通用流程说明。

公开命令不是通用的启动方式,拼不出可靠配置示例;请在客户端 MCP 配置里按官方文档填写 command 和 args。

上手步骤

  1. 1

    先确认运行方式

    公开资料没有标注传输方式,先看仓库 README,确认是本地进程还是远程地址。

  2. 2

    获取服务

    公开目录没有给出安装命令,按仓库 README里的步骤安装或获取服务。

  3. 3

    写入客户端配置

    在客户端的 MCP 配置里填启动命令和参数,保存后完全退出客户端再打开,让新配置生效。

  4. 4

    验证是否可用

    连接成功后客户端会列出 0 个工具,随便调一个只读工具确认能返回结果。

接入前确认

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

公开资料仍需确认:安装命令

详细介绍

Nochen jsonrpc

基于stdio(子进程通信)的干净、开发人员友好的JSON-RPC 2.0客户端

建在上面 具有stdio传输层,用于使用行分隔的JSON与子进程通信。

非常适合为以下客户建立客户:

特性

✨ 清洁API -用于stdio JSON-RPC通信的简单直观的界面 🚀 TypeScript优先 -具有泛型的完全类型安全 📦 双包装 -ESM和CommonJS支持 🔄 事件驱动 -基于EventEmitter构建,用于通知和日志 🛡️ 健壮 -全面的错误处理和流程生命周期管理 🧪 测试良好 -47项测试,覆盖率超过81% 📝 有据可查 -示例和包含的TypeScript类型

安装

npm install node-stdio-jsonrpc

快速开始

import { StdioClient } from 'node-stdio-jsonrpc';

// Create a client that spawns a child process
const client = new StdioClient({
  command: 'node',
  args: ['./your-jsonrpc-server.js'],
  debug: true, // Optional: enable debug logging
});

// Connect to the server
await client.connect();

// Make a request
const result = await client.request('yourMethod', { param: 'value' });
console.log('Result:', result);

// Send a notification (no response expected)
client.notify('log', { level: 'info', message: 'Hello' });

// Listen for server notifications
client.on('notification', (method, params) => {
  console.log(`Server notification: ${method}`, params);
});

// Disconnect when done
await client.disconnect();

API 参考

StdioClient

通过stdio创建JSON-RPC客户端的主类。

构造函数
new StdioClient(config: StdioClientConfig)

配置选项:

选项类型默认值描述
commandstring*必需的*生成命令(例如。, 'node', 'python')
argsstring[][]传递给命令的参数
cwdstringprocess.cwd()子进程的工作目录
envNodeJS.ProcessEnvprocess.env环境变量
connectionTimeoutnumber10000连接超时(毫秒)
requestTimeoutnumber30000请求超时(毫秒)
debugbooleanfalse启用调试日志记录
方法
connect(): Promise

生成子进程并建立连接。

await client.connect();
disconnect(): Promise

终止子进程并清理资源。

await client.disconnect();
request(method: string, params?: unknown): Promise

发送JSON-RPC请求并等待响应。

interface CalculateResult {
  sum: number;
}

const result = await client.request('calculate', {
  operation: 'add',
  a: 5,
  b: 3,
});

console.log(result.sum); // 8
notify(method: string, params?: unknown): void

发送JSON-RPC通知(预期无响应)。

client.notify('log', { level: 'info', message: 'Task completed' });
isConnected(): boolean

检查客户端当前是否已连接。

if (client.isConnected()) {
  console.log('Connected!');
}
事件

客户端扩展 EventEmitter 并发出以下事件:

事件参数描述
connected()连接建立时发出
disconnected()与服务器断开连接时发出
notification(method: string, params?: unknown)服务器发送了通知
error(error: Error)发生错误
log(message: string)服务器已写入stderr
client.on('connected', () => {
  console.log('Connected to server!');
});

client.on('disconnected', () => {
  console.log('Disconnected from server');
});

client.on('notification', (method, params) => {
  console.log(`Notification: ${method}`, params);
});

client.on('error', (error) => {
  console.error('Error:', error);
});

client.on('log', (message) => {
  console.log(`Server log: ${message}`);
});

StdioTransport

较低级别的运输实施。通常你会使用 StdioClient但是 StdioTransport 如果您需要直接控制,则可以使用。

import { StdioTransport } from 'node-stdio-jsonrpc/transport';
import { JSONRPCClient } from '@gnana997/node-jsonrpc';

const transport = new StdioTransport({
  command: 'node',
  args: ['./server.js'],
});

const client = new JSONRPCClient({ transport });
await client.connect();

例子

基础示例

import { StdioClient } from 'node-stdio-jsonrpc';

const client = new StdioClient({
  command: 'node',
  args: ['./echo-server.js'],
});

await client.connect();

const response = await client.request('echo', { message: 'Hello, World!' });
console.log(response); // { message: 'Hello, World!' }

await client.disconnect();

MCP客户端示例

非常适合连接到模型上下文协议服务器:

import { StdioClient } from 'node-stdio-jsonrpc';

const client = new StdioClient({
  command: 'npx',
  args: ['@modelcontextprotocol/server-filesystem', '~/Documents'],
  debug: true,
});

await client.connect();

// Initialize MCP session
const initResult = await client.request('initialize', {
  protocolVersion: '2024-11-05',
  capabilities: { roots: { listChanged: true } },
  clientInfo: { name: 'my-client', version: '1.0.0' },
});

client.notify('notifications/initialized');

// List available tools
const { tools } = await client.request('tools/list');
console.log('Available tools:', tools);

await client.disconnect();

看 MCP客户端示例 为了完整实施。

错误处理

import { StdioClient, JSONRPCError } from 'node-stdio-jsonrpc';

const client = new StdioClient({
  command: 'node',
  args: ['./server.js'],
});

try {
  await client.connect();

  const result = await client.request('someMethod', { param: 'value' });
  console.log('Success:', result);

} catch (error) {
  if (error instanceof JSONRPCError) {
    console.error('JSON-RPC Error:', error.code, error.message);
  } else {
    console.error('Connection/Transport Error:', error);
  }
} finally {
  if (client.isConnected()) {
    await client.disconnect();
  }
}

使用TypeScript

import { StdioClient } from 'node-stdio-jsonrpc';

// Define your request/response types
interface CalculateParams {
  operation: 'add' | 'subtract' | 'multiply' | 'divide';
  a: number;
  b: number;
}

interface CalculateResult {
  result: number;
}

const client = new StdioClient({
  command: 'node',
  args: ['./calculator-server.js'],
});

await client.connect();

// Type-safe requests
const result = await client.request('calculate', {
  operation: 'add',
  a: 10,
  b: 5,
} satisfies CalculateParams);

console.log(result.result); // TypeScript knows this is a number

await client.disconnect();

协议

此库实现 JSON-RPC 2.0 超过 标准 (标准输入/输出)使用 行分隔JSON 框架:

  • 每条JSON消息都在自己的行上
  • 消息以以下方式终止 \n
  • stdin:客户端→ 服务器
  • stdout:服务器→ 客户端(JSON-RPC消息)
  • stderr:服务器日志(不是JSON-RPC)

消息格式

请求:

{"jsonrpc":"2.0","id":1,"method":"methodName","params":{"key":"value"}}

成功响应:

{"jsonrpc":"2.0","id":1,"result":{"data":"value"}}

错误响应:

{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"Error message"}}

通知(无id):

{"jsonrpc":"2.0","method":"notifyMethod","params":{"key":"value"}}

需求

  • Node.js 18或更高版本
  • TypeScript 5.x(如果使用TypeScript)

相关包

  • -核心JSON-RPC 2.0实现
  • -基于IPC的JSON-RPC(Unix套接字/Windows命名管道)

贡献

欢迎投稿!请看 贡献.md 作为指导方针。

许可证

MIT© 格纳997

更新日志

看 更改日志.md 版本历史。

______________________________________________________________________

内置❤️ 使用TypeScript和 @gnana997/节点jsonrpc

工具与能力

工具数量

0

资源数量

0

提示词数量

0

能力标签

JSON-RPCTypeScript本地部署进程通信开发工具语言服务器

数量来自来源目录的标注,具体工具清单以官方文档为准。

典型使用场景

让助手直接读代码

把仓库、提交记录和 issue 交给模型检索,补全和重构时不用来回复制文件。

在对话里跑命令

触发构建、测试和脚本,执行结果直接回到上下文,省去切终端。

接进开发流程

把 PR、CI 状态和代码审查接进助手,减少在几个工具之间跳。

选择建议

值得选的地方

  • 只提供 0 个工具,职责集中,接入后不容易误操作。
  • 公开说明写得比较完整,接入前能看清能力边界。

先想清楚的地方

  • 公开资料没有可直接复制的安装命令,第一次接入要自己找入口。
  • 需要自备会话凭据,没有凭据没法直接试。
  • 第三方目录整理,版本更新和行为细节以官方仓库为准。

更适合

  • 需要在开发工具场景里让模型直接调用外部能力的人。
  • 愿意照着官方文档一步步配环境的人。

不太适合

  • 暂时拿不到会话凭据的人。
  • 希望一条命令就装好、不想看文档的人。
  • 需要厂商级 SLA 和技术支持的生产环境。

同类对比

5 个同类
MCP Server工具数传输方式安装命令收录来源最后核验
Node Stdio Jsonrpc

MCP World · 本页

0未说明未标注1 个2026-05-17
Git 838e2ec1

MCP World

12stdio有2 个2026-05-17
Markitdown MCP 2c653a5f

MCP World

1stdio有1 个2026-05-17
Context7 MCP C671e75a

MCP World

0stdio有1 个2026-05-17
Context7 831acf40

MCP World

0stdio有1 个2026-05-17

按同分类和工具数量挑出最接近的几条,字段以各自详情页为准。

常见问题

5 条

Node Stdio Jsonrpc 怎么安装?

公开目录没有给出可以直接复制的安装命令,需要按仓库 README里的步骤安装;装好后写进客户端的 MCP 配置再重启。

Node Stdio Jsonrpc 怎么在 Claude Desktop、Cursor 里配置?

它是传输方式未标注,客户端配置里要写启动命令和参数,运行环境是 未标注;保存后完全退出客户端再打开,配置才会生效。

Node Stdio Jsonrpc 收费吗?

本站只整理公开资料,不代收费用,也没有标注具体价格。是否收费取决于服务本身和背后的接口额度,正式使用前按官方说明确认。

Node Stdio Jsonrpc 需要 API Key 吗?

公开资料标注的认证方式是会话凭据,也就是要先拿到凭据才能连上;凭据只填在自己本地的配置里,不要写进公开仓库。

Node Stdio Jsonrpc 支持哪些客户端?

公开资料没有标注具体客户端;能配置本地 MCP 命令的客户端都能接,配置方式参照官方文档。

来源信息

继续浏览同类 MCP