@agent-infra/mcp-client

中文文档
1.2.29发布于 2025/12/15TypeScriptESM + CJS近 30 天下载 7543

运行 Electron apps 服务器的 MCP 客户端, 支持同一进程接近

中文使用文档
文档目录5 节
  1. @ agent-infra/mcp-客户端
  2. * 特性
  3. QQ 快速启动
  4. 过滤工具和提示
  5. • 信贷

@ agent-infra/mcp-客户端

NPM Downloads

QQ 在 TypeScript 中执行一个统一的 MCP 客户端, 支持四大运出框 : 记忆Stdio,SSE(服务生事件),以及 可流取的 HTTP。 。 。 .

* 特性

  • 🟦 在类型脚本中写入:类型安全,现代,并易于整合.
  • 🔌 多运输支助: 外出支持四大运输:
    • 🧠 记忆:为快速,本地工具集成.
    • 🖥️ 斯特迪奥:通过标准输入/输出与工具进行交流,适合基于进程的工具.
    • 🔄 SSE( 仆人事件): 实时,事件驱动的通信超過HTTP.
    • 🌐 可流取的 HTTP:高效,以流为基础的HTTP通信,用于可伸缩远程工具.
  • 🛠️ 统一 API: 与所有运输机使用单一,一致的接口进行交互.
  • 🧩 范围很广:根据需要方便地添加自定义运输或工具.
  • 🔍 过滤支持: 使用带有允许/块列表的 glob 模式过滤工具和提示.

QQ 快速启动

import { MCPClient } from '@agent-infra/mcp-client';

// type: module project usage
import { createServer as createFileSystemServer } from '@agent-infra/mcp-server-filesystem';
// commonjs project usage
// const { createServer as createFileSystemServer } = await import('@agent-infra/mcp-server-filesystem')

const mcpClient = new MCPClient([
  // In-memory
  {
    type: 'builtin',
    name: 'FileSystem',
    description: 'filesystem tool',
    mcpServer: createFileSystemServer({
      allowedDirectories: [omegaDir],
    }),
  },
  // stdio
  {
    type: 'stdio',
    name: 'FileSystem-Stdio',
    description: 'filesystem tool',
    command: 'npx',
    args: [
      '-y',
      '@agent-infra/mcp-server-filesystem'
    ]
  },
  // sse
  {
    type: 'sse',
    name: 'FileSystem-sse',
    description: 'filesystem tool',
    url: 'http://localhost:8889/sse'
  },
  // streamable-http
  {
    type: 'sse',
    name: 'FileSystem-http',
    description: 'filesystem tool',
    url: 'http://localhost:8889/mcp'
  }
]);


await mcpClient.listTools();
await mcpClient.listPrompts();
const result = await mcpClient.callTool({
  client: 'FileSystem-sse',
  name: 'list_directory',
  arguments: {
    path: '~/your_computer'
  },
});

过滤工具和提示

您可以使用 glob 模式过滤工具和提示, 包含允许和块列表 :

const mcpClient = new MCPClient([
  {
    type: 'builtin',
    name: 'FileSystem',
    description: 'filesystem tool',
    mcpServer: createFileSystemServer({
      allowedDirectories: [omegaDir],
    }),
    // Filter configuration
    filters: {
      tools: {
        allow: ['list_*', 'read_*'], // Only allow tools starting with 'list_' or 'read_'
        block: ['delete_*']          // Block any tools starting with 'delete_'
      },
      prompts: {
        allow: ['safe_*'],           // Only allow prompts starting with 'safe_'
        block: ['admin_*']           // Block prompts starting with 'admin_'
      }
    }
  }
]);

// List all tools (filtered)
const tools = await mcpClient.listTools();

// List all prompts (filtered)  
const prompts = await mcpClient.listPrompts();

// List tools from specific server
const serverTools = await mcpClient.listTools('FileSystem');

过滤规则 :

  • 允许模式: 如果指定, 只包含符合这些模式的项目
  • 块图案: 不包括符合这些模式的项目
  • 模式语法: 用途 小型匹配 平面图案( u)*, (中文(简体) ), **, (中文(简体) ), ?, (中文(简体) ), [...]页:1
  • 处理顺序: 允许先应用过滤器, 然后用块过滤器

• 信贷

感谢:

版本与发布记录

@agent-infra/mcp-client 共发布 74 个版本,首次发布于 2025/04/01;过去 12 个月发布了 5 个版本。

版本发布日期距今
1.2.29latest2025/12/1510 个月前
1.2.282025/12/1210 个月前
1.2.262025/11/2811 个月前
1.2.252025/11/2811 个月前
1.2.242025/11/2011 个月前
1.2.232025/09/091.2 年前

其他发布通道:beta → 1.2.16-beta.0。

关于 @agent-infra/mcp-client 的常见问题

@agent-infra/mcp-client 是什么?

运行 Electron apps 服务器的 MCP 客户端, 支持同一进程接近

如何安装 @agent-infra/mcp-client?

在项目目录运行 npm install @agent-infra/mcp-client,或使用 pnpm add / yarn add / bun add。

@agent-infra/mcp-client 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@agent-infra/mcp-client 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@agent-infra/mcp-client 可以商用吗?

@agent-infra/mcp-client 使用 未声明 许可。package.json 没有声明许可证。没有许可证的代码默认保留全部权利,商用前请联系作者或查看仓库中的 LICENSE 文件。以上为概括,不构成法律意见,请以许可原文为准。

@agent-infra/mcp-client 的下载量有多少?

根据 npm 官方下载统计,@agent-infra/mcp-client 在 2026/10/05 – 2026/11/03 这 30 天内被下载 7,543 次,日均约 251 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@agent-infra/mcp-client 还在维护吗?

最新版本 1.2.29 发布于 2025/12/15(10 个月前);至今共发布 74 个版本,其中过去 12 个月发布了 5 个;首次发布于 2025/04/01。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。