Skip to main content
Glama

Deploy with Vercel


架构

flowchart LR
    subgraph EXT [ Their AI client ]
        direction TB
        BA[Buyer agent<br/><i>Claude · ChatGPT · Gemini</i>]
    end

    subgraph PARLEY [ Your Parley deployment ]
        direction TB
        WK[".well-known/<br/>agent-commerce.json"]
        MCP["MCP endpoint<br/><b>/api/mcp</b>"]
        TOOLS["9 tools<br/><i>search · stock · order<br/>mandate · audit</i>"]
        SELLER["Seller agent<br/><i>persona + limits</i>"]
        DASH["Dashboard<br/><b>/dashboard</b>"]
        PG[("Postgres<br/>audit_log · mandates")]
    end

    subgraph STORE [ Your existing store ]
        direction TB
        API1["GET  search"]
        API2["GET  product"]
        API3["POST order"]
    end

    RZP[["Razorpay<br/>payment link"]]
    U([Customer])

    U --> BA
    BA <-->|"discovers"| WK
    BA <-->|"JSON-RPC"| MCP
    MCP --> TOOLS
    TOOLS <--> SELLER
    TOOLS -->|"read"| API1
    TOOLS -->|"read"| API2
    TOOLS -->|"write"| API3
    TOOLS -->|"log every decision"| PG
    TOOLS -->|"needs approval"| RZP
    PG --> DASH

    classDef ext fill:#1e293b,stroke:#475569,color:#e2e8f0
    classDef core fill:#0f2942,stroke:#2563eb,color:#dbeafe
    classDef store fill:#0f2e1f,stroke:#16a34a,color:#dcfce7
    classDef pay fill:#2e1f0f,stroke:#d97706,color:#fed7aa
    class BA ext
    class WK,MCP,TOOLS,SELLER,DASH,PG core
    class API1,API2,API3 store
    class RZP pay

Parley 从不写入您的数据库。 每一笔订单都通过您自己的 API 完成。

Related MCP server: Mercora

购买流程

sequenceDiagram
    autonumber
    actor C as Customer
    participant B as Buyer agent
    participant P as Parley
    participant S as Your store
    participant R as Razorpay

    C->>B: "Buy a navy tee under ₹1500"
    B->>P: search_products
    P->>S: GET search
    S-->>P: catalog
    P-->>B: normalized products

    B->>P: check_stock
    P->>S: GET product (live, never cached)
    S-->>P: stock: 8

    B->>P: create_order_and_pay
    Note over P: discount clamped in code

    P->>S: POST order
    alt Out of stock
        S-->>P: 409 out_of_stock
        P-->>B: blocked · nothing charged
    else Store is down
        S-->>P: 5xx
        P-->>B: unavailable · try again
    else Accepted
        S-->>P: order_id

        alt Mandate covers the amount
            P->>P: charge against cap
            P-->>B: completed · no human needed
        else No mandate
            P->>R: create payment link
            R-->>P: link
            P-->>B: awaiting approval
            B-->>C: pay here →
        end
    end

    P->>P: write audit_log row

开始之前

Parley 不运行您的商店。它对接您已有的商店。

如今几乎每个线上商家都已经有网站,而网站背后是真实的 API——也就是您自己的站点用来列出商品、检查库存和下订单的那些端点。Parley 接入的就是这些。这是唯一一个硬性要求。

您需要三个 HTTP 端点:

端点

它必须做什么

示例

搜索商品

返回您的商品目录,让代理能找到商品

GET /api/products

获取单个商品

返回单个商品及其实时库存

GET /api/products/:id

创建订单

预留库存并返回订单 ID

POST /api/orders

还有一个可选的:订单状态端点。不设置的话,Parley 会复用您的订单 API。

字段名和 JSON 结构由您决定——您在配置中映射它们,而不是在代码中,因此无需为了适配 Parley 而重写任何现有端点。

如果您还没有这些 API,Parley 就没有可连接的对象。 它从不抓取您的网站,也从不直接读取您的数据库。请先暴露这三个端点,然后再回来执行下面的步骤。

快速开始

1 · 克隆

git clone https://github.com/Mudavath-Giri-Naik/Parley.git
cd Parley
npm install

需要 Node 20+

2 · 配置

cp .env.example .env.local

设置以下四项:

MERCHANT_NAME="Your Store"
MERCHANT_SEARCH_API=https://yourstore.com/api/products
MERCHANT_STOCK_API=https://yourstore.com/api/products
MERCHANT_ORDER_API=https://yourstore.com/api/orders

然后设置 PRICE_UNIT 以匹配您的 API:

您的 API 对 ₹1,499 的商品返回 1499

PRICE_UNIT=major

您的 API 对 ₹1,499 的商品返回 149900

PRICE_UNIT=minor

→ 其他所有内容:docs/CONFIGURATION.md

3 · 添加数据库

任意 Postgres 均可。免费的 Supabase 或 Neon 都可以。

对其运行 supabase/0001_shared_schema.sql——它会创建数据表、parley_app 角色以及行级隔离策略。其验证查询的每一行都必须显示 PASS。

PARLEY_DB_URL=postgresql://parley_app:pass@host:5432/db?sslmode=require

以 parley_app 身份连接,而不是超级用户。超级用户会绕过行级安全,从而静默移除隔离层。

在 Supabase 上,请使用 pooler 连接字符串(项目设置 → 数据库 → 连接池)。直接的 db.<ref>.supabase.co 主机仅支持 IPv6,在大多数 IPv4 网络上无法解析。

4 · 添加支付密钥

从您的 Razorpay 控制台 → 设置 → API 密钥。

RAZORPAY_KEY_ID=rzp_test_xxxxx
RAZORPAY_KEY_SECRET=xxxxx

5 · 本地运行

npm run dev

打开 http://localhost:3000 并确认:

  • 没有"配置不完整"警告

  • 能力卡片显示绿色

  • 价格与您的真实商品目录一致

npm run test:regression

6 · 部署

npx vercel --prod

⚠️ 在 Vercel → 设置 → 环境变量中重新输入每个变量,然后重新部署。.env.local 不会被上传。

7 · 复制您的 MCP 链接

打开您部署后的 URL。点击 MCP 端点旁边的 复制。

https://your-project.vercel.app/api/mcp

8 · 连接到 Claude

设置 → 连接器 → 添加自定义连接器 → 粘贴 URL → 添加。

Claude 连接器文档 · 对于 ChatGPT,请参阅 OpenAI 的 MCP 文档 — 此处未测试

9 · 测试

粘贴到聊天中:

Show me what's in stock right now, with prices.
Then check live availability for one of them.

然后打开 /dashboard——每次调用都会连同其推理过程一起显示。


内置功能

🔒 折扣上限

在代码中强制执行,而非依赖提示词

💳 消费授权

无人值守购买仅在客户授权的额度内进行

📦 实时库存

绝不缓存,每次承诺前都会检查

📝 完整审计追踪

每个决策都以通俗易懂的推理记录在案

🔌 任意 API 结构

字段名通过配置映射,而非代码

🤝 议价

可选,通过 Claude 或 Gemini

命令

npm run dev                 # local dev server
npm run build               # production build
npm run test:regression     # end-to-end suite against a live deployment
npm run check:template      # verify no merchant values leaked into source
npm run typecheck           # tsc --noEmit

项目结构

app/
  api/mcp/route.ts          MCP endpoint
  dashboard/                audit trail UI
  page.tsx                  status page + copyable MCP link
lib/
  config.ts                 all env vars, validated once
  merchantApi.ts            field mapping, envelopes, refusals
  tools/                    one file per tool
  sellerAgent.ts            negotiation
scripts/
  regression.mjs            end-to-end tests

文档

  • 配置 — 每个环境变量、订单 API 契约

  • 限制 — 已知缺口,部署前请阅读

许可证

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    Enables AI agents to autonomously browse inventory, negotiate terms, manage carts, and execute secure payments on Shopify stores using standardized protocols. It provides a bridge for LLMs to handle the entire commerce lifecycle from discovery to order tracking through a verifiable mandate chain.
    5
    2
    MIT
  • F
    license
    Not graded
    quality
    B
    maintenance
    Enables AI agents to browse product catalogs and make purchases through a policy engine that enforces spending limits, requires human approval for certain amounts, and logs all actions to an audit trail.
    -
  • A
    license
    Not graded
    quality
    B
    maintenance
    Enables AI shopping agents to search products, check stock, apply promotions, manage cart sessions, and create cryptographically signed checkout sessions on e-commerce storefronts, while giving merchants analytics into agent intent and catalog demand gaps.
    MIT