Skip to main content

LangChain toolkit for Universal Commerce Protocol (UCP)

Project description

LangChain UCP

LangChain toolkit for Universal Commerce Protocol (UCP).

Overview

langchain-ucp provides LangChain tools and toolkit for building AI agents that can interact with UCP-compliant merchants.

Installation

pip install langchain-ucp

Quick Start

from langchain_ucp import UCPToolkit, Product
from langchain_openai import ChatOpenAI
from langgraph.prebuilt import create_react_agent

# Define your product catalog (for agent-side discovery)
# Full product details come from the merchant via UCP
products = [
    Product(id="roses", title="Red Roses"),
    Product(id="tulips", title="Spring Tulips"),
    Product(id="orchid", title="White Orchid"),
]

# Create toolkit with product catalog
toolkit = UCPToolkit(
    merchant_url="http://localhost:8000",
    products=products,
)

# Create agent
llm = ChatOpenAI(model="gpt-4o")
agent = create_react_agent(llm, toolkit.get_tools())

# Run agent
result = await agent.ainvoke({
    "messages": [{"role": "user", "content": "I want to buy some red roses"}]
})

Product Catalog

The Product model is a temporary solution for agent-side discovery. It only requires the minimum fields needed for search.

Field Type Required Description
id str Yes Unique product identifier (must match merchant's product ID)
title str Yes Product display name (used for search)

Note: When UCP product discovery is implemented, the full product catalog (pricing, categories, descriptions, images) will be fetched directly from the merchant.

Available Tools

Tool Description
search_shopping_catalog Search the product catalog
add_to_checkout Add products to cart
remove_from_checkout Remove products from cart
update_checkout Update product quantities
get_checkout View current cart
update_customer_details Add buyer info and address
start_payment Prepare checkout for payment
complete_checkout Complete purchase
cancel_checkout Cancel checkout
get_order Get order details

Examples

See the examples directory for complete working examples:

  • basic_agent.py - Simple agent that adds items to cart
  • interactive_chat.py - Interactive chat with the shopping agent

License

Apache License 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

langchain_ucp-0.1.1.tar.gz (14.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

langchain_ucp-0.1.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_ucp-0.1.1.tar.gz.

File metadata

  • Download URL: langchain_ucp-0.1.1.tar.gz
  • Upload date:
  • Size: 14.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_ucp-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3adaba8be85ba747d473bf96770f0f702dfa4b4a2447233512a0f035a68bd21f
MD5 ca6a226507d3378b3d576ba235c28f36
BLAKE2b-256 29fbac7166859c8fba37bee70b2d4ea0ed77fa4ae3b4bf73144b38b20792b1f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_ucp-0.1.1.tar.gz:

Publisher: publish.yml on muzaffersenkal/langchain-ucp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_ucp-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: langchain_ucp-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for langchain_ucp-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2acbbd96485f444e0bc0b642b1ba547f657eb568959d1e3270b044b2b3e3fab1
MD5 098b54b2c19c69fe26148c9b6c38e606
BLAKE2b-256 d67707bf915fe2c4c2d647ab5feadd9f0ca65f7e9380c18a448cf54203214c92

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_ucp-0.1.1-py3-none-any.whl:

Publisher: publish.yml on muzaffersenkal/langchain-ucp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page