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 cartinteractive_chat.py- Interactive chat with the shopping agent
License
Apache License 2.0
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3adaba8be85ba747d473bf96770f0f702dfa4b4a2447233512a0f035a68bd21f
|
|
| MD5 |
ca6a226507d3378b3d576ba235c28f36
|
|
| BLAKE2b-256 |
29fbac7166859c8fba37bee70b2d4ea0ed77fa4ae3b4bf73144b38b20792b1f7
|
Provenance
The following attestation bundles were made for langchain_ucp-0.1.1.tar.gz:
Publisher:
publish.yml on muzaffersenkal/langchain-ucp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_ucp-0.1.1.tar.gz -
Subject digest:
3adaba8be85ba747d473bf96770f0f702dfa4b4a2447233512a0f035a68bd21f - Sigstore transparency entry: 845058970
- Sigstore integration time:
-
Permalink:
muzaffersenkal/langchain-ucp@b5aca709c21220aa43b18d63a073e2cbd89e2028 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/muzaffersenkal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b5aca709c21220aa43b18d63a073e2cbd89e2028 -
Trigger Event:
release
-
Statement type:
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2acbbd96485f444e0bc0b642b1ba547f657eb568959d1e3270b044b2b3e3fab1
|
|
| MD5 |
098b54b2c19c69fe26148c9b6c38e606
|
|
| BLAKE2b-256 |
d67707bf915fe2c4c2d647ab5feadd9f0ca65f7e9380c18a448cf54203214c92
|
Provenance
The following attestation bundles were made for langchain_ucp-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on muzaffersenkal/langchain-ucp
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
langchain_ucp-0.1.1-py3-none-any.whl -
Subject digest:
2acbbd96485f444e0bc0b642b1ba547f657eb568959d1e3270b044b2b3e3fab1 - Sigstore transparency entry: 845058975
- Sigstore integration time:
-
Permalink:
muzaffersenkal/langchain-ucp@b5aca709c21220aa43b18d63a073e2cbd89e2028 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/muzaffersenkal
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@b5aca709c21220aa43b18d63a073e2cbd89e2028 -
Trigger Event:
release
-
Statement type: