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

@opencommerceprotocol/agent-discovery

v1.0.0

Published

Open Commerce Protocol — Agent discovery infrastructure: serve, discover, and bridge agent tools via /.well-known/agent.json

Readme

@opencommerceprotocol/agent-discovery

Agent discovery infrastructure for the Open Commerce Protocol. Implements the AGENT_DISCOVERY_PLAN specification — both the server-side SDK for registering agent tools, and the client-side SDK for agents to discover tools at any URL.

Installation

npm install @opencommerceprotocol/agent-discovery

Server-Side: Register Agent Tools

Use registerAgentTools to declare your tools and auto-generate the /.well-known/agent.json manifest.

import { registerAgentTools } from '@opencommerceprotocol/agent-discovery';
import { Hono } from 'hono';

const { manifest, middleware } = registerAgentTools({
  name: 'My Store',
  description: 'Agent-enabled shopping store',
  url: 'https://mystore.com',
  version: '1.0.0',
  tools: [
    {
      name: 'search_products',
      description: 'Search the product catalog',
      parameters: {
        type: 'object',
        properties: {
          query: { type: 'string', description: 'Search query' },
          limit: { type: 'number', description: 'Max results' },
        },
      },
      handler: async (params) => {
        const res = await fetch(`/api/products?q=${params.query}`);
        return res.json();
      },
    },
  ],
  auth: { type: 'none' },
  verticals: ['commerce'],
});

const app = new Hono();
middleware(app);  // serves /.well-known/agent.json and /.well-known/agent-tools

RegisterAgentToolsConfig

| Option | Type | Description | |--------|------|-------------| | name | string | Site display name | | description | string | Agent-friendly site description | | url | string | Site base URL | | version | string | API version | | tools | AgentToolConfig[] | Tool definitions | | auth | AgentAuth | Authentication config | | bridge | AgentBridge | Protocol bridge declarations | | verticals | AgentVertical[] | Site categories |

RegisterResult

interface RegisterResult {
  manifest: AgentManifest;       // The generated agent manifest
  middleware: HonoMiddleware;    // Hono app plugin — serves /.well-known/agent.json
  toJSON(): string;              // Manifest as JSON string
}

Server-Side: Hono Middleware

If you already have an AgentManifest, use agentDiscoveryMiddleware directly:

import { agentDiscoveryMiddleware } from '@opencommerceprotocol/agent-discovery';

const app = new Hono();
app.use(agentDiscoveryMiddleware(myManifest));

Client-Side: Discover Agent Tools

import { discoverAgent, discoverTools } from '@opencommerceprotocol/agent-discovery/client';

// Discover full agent manifest from a URL
const result = await discoverAgent('https://mystore.com');
if (result.found) {
  console.log(result.mode);      // 'direct' | 'ocp_fallback'
  console.log(result.manifest);  // AgentManifest
}

// Discover just the tool list
const tools = await discoverTools('https://mystore.com');
// AgentTool[] or empty array if not found

Discovery Modes

  1. Mode A (Direct): Fetches /.well-known/agent.json
  2. Mode B (OCP Fallback): Falls back to /.well-known/ocp.json for OCP-enabled sites

DiscoveryResult

interface DiscoveryResult {
  found: boolean;
  mode?: 'direct' | 'ocp_fallback';
  manifest?: AgentManifest;
  manifest_url?: string;
}

Protocol Bridge Mappers

Convert agent manifests to other protocol formats:

import { toMCPTools, toOpenAITools, toA2ATools, toA2AAgentCard, toOpenAPISpec } from '@opencommerceprotocol/agent-discovery';

// Convert to MCP tool definitions
const mcpTools = toMCPTools(manifest.tools);

// Convert to OpenAI function-calling format
const openAITools = toOpenAITools(manifest.tools);

// Convert to Google A2A tool definitions
const a2aTools = toA2ATools(manifest.tools);

// Convert to full A2A agent card
const agentCard = toA2AAgentCard(manifest);

// Generate OpenAPI 3.0 spec
const openAPISpec = toOpenAPISpec(manifest);

Security Layer

Request Signing (HMAC-SHA256)

import { signRequest, verifySignature } from '@opencommerceprotocol/agent-discovery';
import type { SignedHeaders } from '@opencommerceprotocol/agent-discovery';

// Agent signs outgoing requests
const headers: SignedHeaders = signRequest({
  method: 'POST',
  url: 'https://mystore.com/api/cart',
  body: JSON.stringify({ product_id: 'prod-001', quantity: 1 }),
  apiKey: 'my-api-key',
  secret: 'my-secret',
});
// headers: { 'X-OCP-Signature': '...', 'X-OCP-Timestamp': '...' }

// Server verifies incoming request
const valid = await verifySignature({
  method: 'POST',
  url: 'https://mystore.com/api/cart',
  body: rawBody,
  secret: 'my-secret',
  headers: req.headers,
});

Domain Verification

import { generateDomainVerificationTokens, verifyDomainOwnership } from '@opencommerceprotocol/agent-discovery';

// Generate verification tokens for a domain
const tokens = generateDomainVerificationTokens('mystore.com');
// tokens.file_token — place at /.well-known/agent-verify.txt
// tokens.dns_token — add as DNS TXT record

// Verify a domain (agent-side)
const verified = await verifyDomainOwnership('mystore.com', tokens.file_token);

OAuth2 Client Credentials

import { fetchOAuth2Token } from '@opencommerceprotocol/agent-discovery';
import type { OAuth2ClientConfig } from '@opencommerceprotocol/agent-discovery';

const config: OAuth2ClientConfig = {
  clientId: 'my-client-id',
  clientSecret: 'my-client-secret',
  tokenUrl: 'https://mystore.com/oauth/token',
  scopes: ['commerce:read', 'commerce:cart'],
};

const token = await fetchOAuth2Token(config);
// Use token.access_token in Authorization header

Rate Limit Parsing

import { parseRateLimit } from '@opencommerceprotocol/agent-discovery';
import type { RateLimitPolicy } from '@opencommerceprotocol/agent-discovery';

const policy: RateLimitPolicy = parseRateLimit(
  response.headers.get('RateLimit-Policy')
);
// { requestsPerWindow: 100, windowSecs: 3600, retryAfterSecs?: 60 }

Manifest Validation

import { validateManifest, isAgentManifest } from '@opencommerceprotocol/agent-discovery';

// Type guard
if (isAgentManifest(data)) {
  // data is AgentManifest
}

// Full validation
const result = validateManifest(data);
// { valid: boolean, errors: ValidationError[], warnings: ValidationWarning[] }

Key Types

import type {
  AgentManifest,
  AgentTool,
  AgentToolParameters,
  AgentAuth,          // { type: 'none' | 'api_key' | 'oauth2' | 'bearer' }
  OAuth2Config,
  ApiKeyConfig,
  AgentBridge,        // { mcp?, openai?, a2a?, openapi? }
  AgentVertical,      // 'commerce' | 'travel' | 'knowledge' | 'saas' | ...
} from '@opencommerceprotocol/agent-discovery';