@agent-infra/mcp-client

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

An MCP Client to run servers for Electron apps, support same-process approaching

原始使用文档
文档目录5 节
  1. @agent-infra/mcp-client
  2. 🚀 Features
  3. ⚡ Quick Start
  4. 🔍 Filtering Tools and Prompts
  5. 🙏 Credits

@agent-infra/mcp-client

NPM Downloads

✨ A unified MCP Client implemented in TypeScript, supporting four major transports out of the box: In-memory, Stdio, SSE (Server-Sent Events), and Streamable HTTP.

🚀 Features

  • 🟦 Written in TypeScript: Type-safe, modern, and easy to integrate.
  • 🔌 Multi-Transport Support: Out-of-the-box support for four major transports:
    • 🧠 In-memory: For fast, local tool integration.
    • 🖥️ Stdio: Communicate with tools via standard input/output, perfect for process-based tools.
    • 🔄 SSE (Server-Sent Events): Real-time, event-driven communication over HTTP.
    • 🌐 Streamable HTTP: Efficient, stream-based HTTP communication for scalable remote tools.
  • 🛠️ Unified API: Interact with all transports using a single, consistent interface.
  • 🧩 Highly Extensible: Easily add custom transports or tools as needed.
  • 🔍 Filtering Support: Filter tools and prompts using glob patterns with allow/block lists.

⚡ Quick Start

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'
  },
});

🔍 Filtering Tools and Prompts

You can filter tools and prompts using glob patterns with allow and block lists:

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');

Filter Rules:

  • Allow patterns: If specified, only items matching these patterns are included
  • Block patterns: Items matching these patterns are excluded
  • Pattern syntax: Uses minimatch glob patterns (*, **, ?, [...], etc.)
  • Processing order: Allow filter is applied first, then block filter

🙏 Credits

Thanks to:

版本与发布记录

@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 是什么?

An MCP Client to run servers for Electron apps, support same-process approaching

如何安装 @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 和提交记录判断。