Skip to main content

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

Project description

langchain-w2a

LangChain integration for the Web2Agent Protocol.

Turns any W2A-enabled website's declared skills into LangChain tools — one tool per skill, with typed 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)

Quick start

import asyncio
from langchain_w2a import W2AToolkit
from langchain_openai import ChatOpenAI
from langchain.agents import AgentExecutor, create_tool_calling_agent
from langchain_core.prompts import ChatPromptTemplate

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

    for tool in tools:
        print(f"{tool.name}: {tool.description}")
    # w2a_protocol_validate_manifest: Validate an agents.json...
    # w2a_protocol_check_site: Check whether a website...
    # w2a_discover: Discover what a W2A-enabled website can do.
    # w2a_call_skill: Call a specific skill on a W2A-enabled website.

    llm = ChatOpenAI(model="gpt-4")
    prompt = ChatPromptTemplate.from_messages([
        ("system", "You are a helpful assistant with access to W2A tools."),
        ("human", "{input}"),
        ("placeholder", "{agent_scratchpad}"),
    ])

    agent = create_tool_calling_agent(llm, tools, prompt)
    executor = AgentExecutor(agent=agent, tools=tools, verbose=True)

    result = executor.invoke({"input": "Is stripe.com W2A enabled?"})
    print(result["output"])

asyncio.run(main())

Generic discover + call tools

If you don't know the site in advance, use the generic tools:

from langchain_w2a import W2ADiscoverTool, W2ASkillTool

tools = [W2ADiscoverTool(), W2ASkillTool()]

# Agent can now discover any site and call its skills
# Example agent reasoning:
# 1. Call w2a_discover("stripe.com") → see available skills
# 2. Call w2a_call_skill("stripe.com", "search_products", {"q": "..."})

Toolkit — one tool per skill

For a known site, the toolkit pre-binds the URL and creates dedicated tools:

from langchain_w2a import W2AToolkit

# Only public skills (no auth required) by default
toolkit = await W2AToolkit.from_url("mysite.com")

# Include auth-required skills (you handle auth via headers)
toolkit = await W2AToolkit.from_url("mysite.com", include_auth_required=True)

# Only specific skills
toolkit = await W2AToolkit.from_url("mysite.com", skill_ids=["search", "checkout"])

Requirements

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

License

Apache 2.0 — same as LangChain and A2A.

w2a-protocol.org · github.com/Nijjwol23/w2a

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.1.0.tar.gz (7.1 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.1.0-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: langchain_w2a-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 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.1.0.tar.gz
Algorithm Hash digest
SHA256 2272d8bf753c9aed26d499a47091e52f48da5f494b375ffe49457e6b73d30ef0
MD5 19f1077f5e303f32b8a6417ecbec485f
BLAKE2b-256 869165a02d63ef07893234cb9ff67ae22d7755883a5b289785fa509f550f0005

See more details on using hashes here.

File details

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

File metadata

  • Download URL: langchain_w2a-0.1.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.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7f3247eeae620c1380768c1dd64acaa0d977f145351c225ee7498c0a00bf2b3f
MD5 17321dceb5ff6014fa10e300e280bb48
BLAKE2b-256 abe1d88880f54889024e5d2e9b0fc818150957b7f492c9f6b9c0c49acb51851e

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