MCP客户端库

这是一个纯 ESM 的 MCP 客户端库,支持 SDK v2,可通过 Streamable HTTP、stdio 和 Bearer 认证连接 MCP 服务器,适用于在 Node.js 环境中调用 MCP 工具的场景。

  • by eliware
  • JavaScript
  • 本地部署
  • 更新于
在 GitHub 查看 eliware/mcp-client

使用说明

@eliware/mcp-client

Pure ESM MCP client for SDK v2, Streamable HTTP, stdio, and bearer authentication.

Table of Contents

Features

Connect to MCP servers through Streamable HTTP or stdio. Use bearer tokens, custom HTTP headers, token providers, and structured logs.

Requirements

Use Node.js 26 or later.

Setup

Install the package with npm install @eliware/mcp-client.

Usage

import { mcpClient } from "@eliware/mcp-client";

const client = await mcpClient({ url: "https://mcp.example.com/mcp" });

try {
  console.log(await client.listTools());
} finally {
  await client.close();
}

Read the documentation index, specifications, and release notes.

Development

Run npm ci to install locked dependencies. Read repository specifications for contributor requirements.

Testing

Run npm test for aggregate validation.

Troubleshooting

Read the troubleshooting guide for connection help.

Security

Keep access tokens, credentials, and private server data out of source files and logs.

API

Import mcpClient from @eliware/mcp-client. Read the API guide for options and return types.

Packaging

The package includes src/, docs/, README.md, AGENTS.md, LICENSE, RELEASE_NOTES.md, examples/, specs/, and .env.example. Use numeric MAJOR.MINOR.PATCH versions and a v<version> tag for each release. Run npm run pack to check package contents. Publish only after approved release steps.

Examples

Read the examples index for commands, results, permissions, and cleanup.

Support

For help, questions, or to chat with the author and community, visit:

eliware.org on Discord

Links

License

MIT © Eliware