npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@easbot/mcp

v0.3.23

Published

MCP (Model Context Protocol) integration library for EASBOT ecosystem

Readme

English | 中文

@easbot/mcp

MCP (Model Context Protocol) 集成库,为 EASBot 生态系统提供完整的 MCP 服务器和客户端实现。

基于 @modelcontextprotocol/sdk 构建,提供 stdio 和 HTTP 两种传输方式,支持工具注册和动态管理。

特性

  • 双传输支持: 支持 stdio(本地进程)和 HTTP(远程服务)两种传输方式
  • 服务器端实现: 创建和管理 MCP 服务器,向客户端提供工具和资源
  • 客户端实现: 连接到 MCP 服务器,调用远程工具和读取资源
  • 工具注册: 全局工具注册表,支持动态注册/注销工具
  • OAuth 认证: 支持 OAuth 2.0 认证,确保安全连接
  • 配置驱动: 支持从配置文件批量创建服务器实例
  • 完整的类型定义: 提供完整的 TypeScript 类型定义

快速开始

创建 MCP 服务器

import { HttpServerAdapter, ToolRegistry } from '@easbot/mcp';
import { z } from 'zod';

// 调用方自己 new ToolRegistry 并注册工具(构造注入模式)
const tools = new ToolRegistry();
tools.register({
  name: 'my-tool',
  description: '一个示例工具',
  inputSchema: z.object({ name: z.string() }),
  handler: async (args) => ({ content: [{ type: 'text', text: `Hello, ${args.name}!` }] })
});

// 创建并启动服务器(注入 tools)
const server = new HttpServerAdapter({
  id: 'my-server',
  name: 'My MCP Server',
  version: '1.0.0',
  transportType: 'http',
  url: 'http://localhost:3000'
}, tools);

await server.start();

连接到 MCP 服务器

import { MCPClient } from '@easbot/mcp';

const client = new MCPClient();

// 连接本地服务器
await client.connect('filesystem', {
  type: 'local',
  command: ['npx', '-y', '@modelcontextprotocol/server-filesystem', '/tmp']
});

// 查看客户端信息
console.log(client.info);

// 调用工具
const result = await client.callTool('read_file', { path: '/tmp/test.txt' });

// 断开连接
await client.disconnect();

从配置创建服务器

import { createServerFromConfig, createServersFromConfigMap, ToolRegistry } from '@easbot/mcp';

// 调用方自己 new ToolRegistry
const tools = new ToolRegistry();
tools.register({ name: 'shared-tool', handler: ... });

// 创建单个服务器
const server = await createServerFromConfig('my-server', {
  type: 'local',
  command: ['node', 'server.js']
}, tools);

// 从配置映射创建多个服务器(共享同一 ToolRegistry)
const servers = await createServersFromConfigMap({
  'server-1': { type: 'local', command: ['node', 'server1.js'] },
  'server-2': { type: 'remote', url: 'https://mcp.example.com' }
}, tools);

开发

# 安装依赖
pnpm install

# 构建
pnpm build

# 测试
pnpm test

# 类型检查
pnpm type-check

# 代码检查
pnpm lint

# 代码格式化
pnpm format

许可证

MIT