Skip to main content

LangChain integration for the Web2Agent Protocol — turn any W2A-enabled website into LangChain tools

Project description

langchain-w2a

PyPI version License: Apache 2.0 Tests

LangChain integration for the Web2Agent Protocol.

Turns any W2A-enabled website's declared skills into typed LangChain tools — one tool per skill, with Pydantic input schemas built from the site's agents.json.

pip install langchain-w2a

What is W2A?

W2A is an open standard where websites declare their capabilities at /.well-known/agents.json. Instead of crawling 40–50 pages to understand what a site does, your agent reads one file.

robots.txt  →  what not to crawl  (1994)
sitemap.xml →  where pages are    (2005)
agents.json →  what a site can do (2026)

Three ways to use it

1. Toolkit — typed tools from a known site

from langchain_w2a import W2AToolkit
from langchain.agents import create_agent

# Each W2A skill becomes a typed LangChain tool
toolkit = await W2AToolkit.from_url("w2a-protocol.org")
tools = toolkit.get_tools()

agent = create_agent(model="claude-sonnet-4-5-20250929", tools=tools)
agent.invoke({"messages": [("user", "Check if stripe.com is W2A enabled")]})

2. Generic discover + call tools

from langchain_w2a import W2ADiscoverTool, W2ASkillTool

tools = [W2ADiscoverTool(), W2ASkillTool()]
# Agent can now discover and call any W2A-enabled site at runtime

3. Direct invocation

from langchain_w2a import W2ADiscoverTool

discover = W2ADiscoverTool()
result = discover.invoke({"url": "w2a-protocol.org"})
print(result)  # JSON summary of site's declared skills

Standard tests

This package implements LangChain's standard test suite for tool integrations.

# Install test dependencies
pip install "langchain-w2a[test]"

# Run unit tests
pytest tests/unit_tests/

# Run integration tests (requires internet)
pytest tests/integration_tests/

Handling sites that haven't adopted W2A yet

result = discover.invoke({"url": "stripe.com"})
# "stripe.com has not adopted the W2A protocol yet —
#  no /.well-known/agents.json found.
#  Generate one at https://w2a-protocol.org/tools"

Tools fail gracefully on non-W2A sites so your agent can fall back to other strategies.


Requirements

  • Python 3.9+
  • langchain-core >= 0.2
  • w2a >= 0.1.0 (the W2A Python SDK)
  • pydantic >= 2.0

Documentation


License

Apache 2.0 — same as LangChain.

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_w2a-0.2.0.tar.gz (6.4 kB view details)

Uploaded Source

Built Distribution

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

langchain_w2a-0.2.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file langchain_w2a-0.2.0.tar.gz.

File metadata

  • Download URL: langchain_w2a-0.2.0.tar.gz
  • Upload date:
  • Size: 6.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for langchain_w2a-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7b6e63acd9aedd1d3bfebc4f41abce15eee1119293e2622da5716b097f6524f9
MD5 2f635df2e31c9390179cfa212e6f7151
BLAKE2b-256 0ba17fa2d3e1e94fb60e3b17db2beaba77423d562136154452415dea4ab6edf3

See more details on using hashes here.

File details

Details for the file langchain_w2a-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: langchain_w2a-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for langchain_w2a-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0fab01f7ca36c242f23d767744bdea24bcc8fbd6a4db851b1ec6b7c7d7802191
MD5 c3c30df063b525ce3d6e9a1800506ae3
BLAKE2b-256 4944a52097500e7f6f91677bbfa5269954280d26eca021779e8837ff8db214a0

See more details on using hashes here.

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