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

@agenticforge/protocols

v1.0.2

Published

MCP / A2A / ANP protocol implementations for AgenticFORGE

Readme

@agenticforge/protocols

npm License: CC BY-NC-SA 4.0

AgenticFORGE 三大核心智能体通信协议的 TypeScript 实现:MCP、A2A、ANP。

安装

npm install @agenticforge/protocols

协议概览

| 协议 | 全称 | 主要用途 | 核心类 | |------|------|----------|--------| | MCP | Model Context Protocol | 工具调用、资源访问、提示词模板 | MCPServerMCPClient | | A2A | Agent-to-Agent Protocol | 智能体间通信与技能协作 | A2AServerA2AClientAgentNetwork | | ANP | Agent Network Protocol | 网络管理与服务发现 | ANPNetworkANPDiscoveryServiceInfo |

MCP

import {MCPServer, MCPClient} from "@agenticforge/protocols";

const server = new MCPServer("weather-server", "提供天气数据");
server.addTool(
  "get_weather",
  "获取城市天气",
  {type: "object", properties: {city: {type: "string"}}, required: ["city"]},
  async ({city}) => `${city} 天气:晴,25°C`,
);

// 内存模式(适合测试)
const client = new MCPClient(server);
await client.connect();
console.log(await client.callTool("get_weather", {city: "北京"}));
client.disconnect();

// HTTP 模式
await server.serve(8000);
const remote = new MCPClient("http://127.0.0.1:8000");
await remote.connect();

MCPServerBuilder — 链式 API

import {MCPServerBuilder} from "@agenticforge/protocols";

const server = new MCPServerBuilder("my-server")
  .withTool(
    "greet", "问候工具",
    {type: "object", properties: {name: {type: "string"}}, required: ["name"]},
    ({name}) => `你好,${name}!`,
  )
  .withResource("file://readme.txt", "说明文件", "项目说明", () => "欢迎使用!")
  .build();

A2A

import {A2AServer, A2AClient, AgentNetwork} from "@agenticforge/protocols";

const agent = new A2AServer({
  name: "calculator-agent",
  description: "处理算术任务",
  capabilities: {math: true},
});
agent.addSkill("add", "加法运算", (text) => {
  const [a, b] = text.split("+").map(Number);
  return String(a + b);
});
await agent.serve(5000);

const client = new A2AClient("http://localhost:5000");
const result = await client.executeSkill("add", "3 + 4");
console.log(result.result); // "7"

// 自动发现网络中的 Agent
const network = new AgentNetwork("my-network");
const count = await network.discoverAgents(["http://localhost:5000"]);
console.log(`发现 ${count} 个 Agent`);

ANP

import {ANPNetwork, ANPDiscovery, ServiceInfo} from "@agenticforge/protocols";

const discovery = new ANPDiscovery();
discovery.registerService(new ServiceInfo({
  serviceId: "calc-1",
  serviceType: "calculator",
  endpoint: "http://localhost:8001",
  capabilities: ["add", "subtract", "multiply"],
  metadata: {region: "cn-north"},
}));
const calculators = discovery.findServicesByType("calculator");
console.log(`找到 ${calculators.length} 个计算服务`);

const network = new ANPNetwork("prod-network");
network.addNode("node1", "http://localhost:8001", {role: "coordinator"});
network.addNode("node2", "http://localhost:8002", {role: "worker"});
network.connectNodes("node1", "node2");
const route = network.routeMessage("node1", "node2");
console.log(route); // ["node1", "node2"]
const status = network.getNetworkStatus();
console.log(status.healthStatus); // "healthy"

主要导出

基础

| 名称 | 说明 | |------|------| | ProtocolType | 枚举:MCPA2AANP | | Protocol | 所有协议的抽象基类 |

MCP

| 名称 | 说明 | |------|------| | MCPServer | 服务器,含工具/资源/提示词注册与内置 HTTP 服务 | | MCPServerBuilder | MCPServer 的链式构建器 | | MCPClient | 支持内存模式和 HTTP 模式的客户端 | | createExampleMCPServer | 工厂函数:含 calculatorgreet 工具的示例服务器 | | createContext / parseContext | 上下文对象辅助函数 | | createSuccessResponse / createErrorResponse | 响应构造辅助函数 |

A2A

| 名称 | 说明 | |------|------| | A2AServer | 含技能注册与 HTTP API 的智能体服务器 | | A2AClient | 内存模式或 HTTP 模式的 A2A 客户端 | | AgentNetwork | 管理多个 A2A Agent,支持自动发现 | | AgentRegistry | A2A Agent 中央注册中心 | | createExampleA2AServer | 工厂函数:含 calculategreet 技能的示例 Agent |

ANP

| 名称 | 说明 | |------|------| | ServiceInfo | 服务描述类(id、类型、端点、能力、元数据) | | ANPDiscovery | 服务注册与发现,支持类型/能力/元数据过滤 | | ANPNetwork | 网络拓扑管理:节点、连接、路由、广播 | | createExampleANPNetwork | 工厂函数:创建三节点示例网络 |

链接

致谢

本包是 AgenticFORGE 的一部分。AgenticFORGE 基于 Hello-Agents(CC BY-NC-SA 4.0)开发,感谢原项目作者及贡献者的杰出工作。MCP / A2A / ANP TypeScript 实现由 LittleBlacky 完成。