@opencommerceprotocol/cli
v1.1.0
Published
Open Commerce Protocol — CLI tool for generating and validating OCP files
Downloads
219
Maintainers
Readme
@opencommerceprotocol/cli
Command-line tool for the Open Commerce Protocol. Set up, validate, and manage OCP for any website.
Installation
npm install -g @opencommerceprotocol/cli
# or use without installing:
npx @opencommerceprotocol/cli <command>Commands
ocp init
Interactive wizard to generate OCP files for your store.
ocp init
ocp init --output ./publicGenerates:
.well-known/ocp.json— manifestocp/products.jsonl— product feedocp.md— natural language store description
ocp crawl <url>
Crawl a website and extract Schema.org Product JSON-LD to generate OCP files automatically.
ocp crawl https://mystore.com
ocp crawl https://mystore.com --output ./ocp-output
ocp crawl https://mystore.com --max-products 500
ocp crawl https://mystore.com --product-pattern "/products/"
ocp crawl https://mystore.com --dry-run # list URLs without fetching
ocp crawl https://mystore.com --verbose # detailed per-URL output| Flag | Default | Description |
|------|---------|-------------|
| --output <dir> | ./ocp-output | Output directory |
| --concurrency <n> | 5 | Max concurrent requests |
| --delay <ms> | 200 | Delay between requests |
| --product-pattern <regex> | — | URL pattern for product pages |
| --max-products <n> | — | Maximum products to extract |
| --user-agent <string> | OCPBot/1.0 | Custom User-Agent |
| --include-variants | true | Extract product variants |
| --generate-agent-notes | true | Auto-generate agent_notes |
| --dry-run | false | List URLs without fetching |
| --resume | false | Resume interrupted crawl |
ocp validate <target>
Validate a live site or local directory. Shows a 0–100 quality score.
ocp validate https://mystore.com
ocp validate ./public # local directoryChecks:
- Manifest structure and required fields
- Product feed validity
robots.txthasOCP-Manifestdirectivellms.txthas Commerce sectionagent_notesquality scores
ocp generate
Generate OCP files from a product CSV, JSON, or JSONL file.
ocp generate --products catalog.csv
ocp generate --products catalog.json
ocp generate --products catalog.jsonl
ocp generate --products catalog.csv --config ocp.config.json --output ./publicCSV example:
id,name,price,currency,url,description
prod-001,Headphones,149.99,USD,https://mystore.com/headphones,Premium wireless headphones| Flag | Default | Description |
|------|---------|-------------|
| --products <file> | — | Input file (.csv, .json, or .jsonl) |
| --config <file> | — | OCP config file |
| --output <dir> | . | Output directory |
ocp bridge
Generate bridge configuration for other agent protocols.
ocp bridge --protocol mcp
ocp bridge --protocol ucp
ocp bridge --protocol a2a
ocp bridge --manifest .well-known/ocp.json --output ./bridge| Flag | Default | Description |
|------|---------|-------------|
| --protocol <protocol> | mcp | Target: mcp, ucp, or a2a |
| --manifest <file> | .well-known/ocp.json | OCP manifest file |
| --output <dir> | ./bridge | Output directory |
ocp robots [path]
Add the OCP-Manifest directive to your robots.txt.
ocp robots # updates ./robots.txt in place
ocp robots /etc/nginx/robots.txt
ocp robots --stdout # print to stdout
ocp robots --url https://mystore.com/.well-known/ocp.jsonResult in robots.txt:
OCP-Manifest: https://mystore.com/.well-known/ocp.jsonocp llms [path]
Generate or patch llms.txt with an OCP Commerce section.
ocp llms # updates ./llms.txt in place
ocp llms --stdout # print to stdout
ocp llms --full # also generate llms-full.txt with product descriptionsocp stats [url]
Analyze server access logs to understand AI agent traffic.
ocp stats --log /var/log/nginx/access.log
ocp stats https://mystore.com --log access.log --format nginx --days 30
ocp stats --log access.log --format apache
ocp stats --log access.log --format cloudflareReports:
- Total agent visits by bot (ChatGPT, Claude, Gemini, etc.)
- Products most viewed by agents
- Search queries agents used
- Agent traffic trends over time
| Flag | Default | Description |
|------|---------|-------------|
| --log <file> | — | Path to log file |
| --format <format> | nginx | Log format: nginx, apache, cloudflare |
| --days <n> | 30 | Number of days to analyze |
ocp test-agent <url>
Simulate an AI agent visiting your store and produce a pass/fail conformance report.
ocp test-agent https://mystore.com
ocp test-agent https://mystore.com --query "blue running shoes"
ocp test-agent https://mystore.com --verbose| Flag | Default | Description |
|------|---------|-------------|
| --query <query> | product | Test search query |
| --verbose | false | Show detailed output and sample agent_notes |
ocp preview <url>
Render what an AI agent sees when visiting your store.
ocp preview https://mystore.com
ocp preview https://mystore.com --products 10
ocp preview https://mystore.com --verbose| Flag | Default | Description |
|------|---------|-------------|
| --products <n> | 5 | Number of sample products to show |
| --verbose | false | Show full ocp.md and best/worst agent_notes |
ocp agent-discover <url>
Discover agent tools at any URL via /.well-known/agent.json or OCP fallback.
ocp agent-discover https://mystore.com
ocp agent-discover https://mystore.com --verbose
ocp agent-discover https://mystore.com --format json
ocp agent-discover https://mystore.com --format mcp
ocp agent-discover https://mystore.com --format openai| Flag | Default | Description |
|------|---------|-------------|
| --verbose | false | Show full tool list with descriptions |
| --format <format> | text | Output: text, json, mcp, openai |
CI/CD Integration
Validate on deploy (GitHub Actions)
- name: Validate OCP
run: npx @opencommerceprotocol/cli validate https://mystore.comCron sync with generate
# crontab: regenerate feed daily at midnight
0 0 * * * ocp generate --products /data/products.csv --output /var/www/htmlConfiguration File
Create ocp.config.json for generate:
{
"merchant": {
"name": "My Store",
"url": "https://mystore.com",
"currency": "USD"
},
"capabilities": {
"catalog": true,
"search": true,
"cart": true,
"checkout": "redirect"
}
}