Skip to main content

OpenTerms protocol integration for CrewAI: permission-aware AI agents

Project description

crewai-openterms

Permission-aware AI agents for CrewAI. Checks a domain's openterms.json before your agent acts, so it knows what it's allowed to do.

Install

pip install crewai-openterms

Two tools

OpenTermsCheckTool

A tool the agent calls to check permissions and get a structured result.

from crewai import Agent, Task, Crew
from crewai_openterms import OpenTermsCheckTool

checker = OpenTermsCheckTool()

researcher = Agent(
    role="Web Researcher",
    goal="Gather information from websites while respecting their terms",
    backstory=(
        "You are a thorough researcher. Before accessing any website, "
        "you always check its openterms.json permissions using the "
        "openterms_check tool."
    ),
    tools=[checker],
)

task = Task(
    description=(
        "Check whether github.com allows read_content and scrape_data. "
        "Report the results."
    ),
    expected_output="A summary of what actions are permitted on github.com.",
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()

OpenTermsGuardTool

A gate that returns clear go/no-go instructions. When a domain allows the action, the response also includes any discovered MCP servers and API specs from the site's discovery block.

from crewai import Agent, Task, Crew
from crewai_tools import ScrapeWebsiteTool
from crewai_openterms import OpenTermsGuardTool

guard = OpenTermsGuardTool()
scraper = ScrapeWebsiteTool()

researcher = Agent(
    role="Compliant Web Scraper",
    goal="Scrape websites for data, but only when permitted",
    backstory=(
        "Before scraping any site, you MUST use openterms_guard to check "
        "whether scraping is allowed. If the tool returns DENIED, do not "
        "proceed. If it returns ALLOWED, you may use the scrape tool."
    ),
    tools=[guard, scraper],
)

task = Task(
    description=(
        "Scrape pricing information from example.com. "
        "First check if scraping is permitted."
    ),
    expected_output="Pricing data or an explanation of why it could not be retrieved.",
    agent=researcher,
)

crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()

Strict mode

By default, if a domain has no openterms.json, the guard returns "PROCEED WITH CAUTION." In strict mode, it blocks instead:

guard = OpenTermsGuardTool(strict=True)

Discovery integration

When a domain's openterms.json includes a discovery block (v0.3.0), the guard tool surfaces MCP server URLs and API spec URLs in its response. This lets the agent know not just whether it can interact, but how:

ALLOWED: acme-corp.com permits 'api_access'. You may proceed.
MCP servers available: https://acme-corp.com/mcp/sse.
API specs available: https://api.acme-corp.com/v1/openapi.json.

Multi-agent example

from crewai import Agent, Task, Crew
from crewai_openterms import OpenTermsCheckTool, OpenTermsGuardTool

# Compliance agent checks permissions first
compliance = Agent(
    role="Compliance Officer",
    goal="Verify that all web interactions are permitted",
    tools=[OpenTermsCheckTool()],
    backstory="You check openterms.json for every domain before any agent acts.",
)

# Research agent does the actual work
researcher = Agent(
    role="Researcher",
    goal="Gather data from permitted sources",
    tools=[OpenTermsGuardTool()],
    backstory=(
        "You research topics online. Always use openterms_guard before "
        "accessing any site. If denied, skip that site and try another."
    ),
)

check_task = Task(
    description="Check permissions for github.com, stripe.com, and reddit.com for read_content and scrape_data.",
    expected_output="Permission matrix for all three domains.",
    agent=compliance,
)

research_task = Task(
    description="Using only permitted domains, gather information about API pricing trends.",
    expected_output="Summary of API pricing trends from permitted sources.",
    agent=researcher,
    context=[check_task],
)

crew = Crew(
    agents=[compliance, researcher],
    tasks=[check_task, research_task],
)

result = crew.kickoff()

Links

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

crewai_openterms-0.3.1.tar.gz (8.9 kB view details)

Uploaded Source

Built Distribution

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

crewai_openterms-0.3.1-py3-none-any.whl (8.5 kB view details)

Uploaded Python 3

File details

Details for the file crewai_openterms-0.3.1.tar.gz.

File metadata

  • Download URL: crewai_openterms-0.3.1.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for crewai_openterms-0.3.1.tar.gz
Algorithm Hash digest
SHA256 49d2333bf30e9733ae86aa9d8d806766b2ba7c2c8a3ba443a8800e28c83f0502
MD5 be6d2d36cba0c82aaccac8306816eed6
BLAKE2b-256 923849ed37be1a7fd036b493e889db08a70d50d889d91bd36b692c7f8a6b8cf4

See more details on using hashes here.

Provenance

The following attestation bundles were made for crewai_openterms-0.3.1.tar.gz:

Publisher: publish.yml on jstibal/crewai-openterms

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

File details

Details for the file crewai_openterms-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for crewai_openterms-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ad3e6b8c553fb90afb5df3e9f800adf793a63ae3de57cd88d3d8609d7cdd1f00
MD5 7af65134122c5e66984890309871f186
BLAKE2b-256 7cb0c722b48aec22adcdbcb187ba29a11e4dfefb2596088a1beadbb6bfa44cd9

See more details on using hashes here.

Provenance

The following attestation bundles were made for crewai_openterms-0.3.1-py3-none-any.whl:

Publisher: publish.yml on jstibal/crewai-openterms

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