Skip to main content

Agentic Scraper Provider SDK for Python

Server-side SDK for event-driven MCP Market monetization. Use it inside the MCP or API service you publish as a provider. It is separate from the Agentic Scraper client SDK used by consumers.

pip install agentic-scraper-provider-sdk

How charging works

For a Marketplace entry configured with provider_event pricing, the Agentic Scraper proxy forwards a signed x-agentic-charge-token header to your service. Report a configured event and count with charge(). Always use the returned chargedCount; it may be lower than requested when the buyer's remaining run budget is limited.

FastAPI / async example

import os

from fastapi import FastAPI, Request
from agentic_scraper_provider import AsyncAgenticProviderClient

provider = AsyncAgenticProviderClient(api_key=os.environ["AGENTIC_PROVIDER_API_KEY"])
app = FastAPI()

@app.post("/mcp")
async def mcp(request: Request):
    records = await load_records()
    result = await provider.charge(
        charge_token=request.headers["x-agentic-charge-token"],
        event_name="record-returned",
        count=len(records),
        idempotency_key=f"record-export:{request.headers.get('x-request-id')}",
        metadata={"requestedCount": len(records)},
    )
    return records[:result["chargedCount"]]

Flask / sync example

import os

from flask import Flask, request
from agentic_scraper_provider import AgenticProviderClient

provider = AgenticProviderClient(
    api_key=os.environ["AGENTIC_PROVIDER_API_KEY"],
)
app = Flask(__name__)

@app.post("/summarize")
def summarize():
    summary = create_summary(request.json["text"])
    result = provider.charge(
        charge_token=request.headers["x-agentic-charge-token"],
        event_name="summary-created",
        idempotency_key=f"summary:{request.headers.get('x-request-id')}",
    )
    return {"summary": summary} if result["chargedCount"] == 1 else {"summary": None}

Reliability rules

  • Use a stable idempotency_key for every logical event.
  • Return or process at most result["chargedCount"] units.
  • Both clients retry transport failures, HTTP 429, and 5xx responses while preserving the same idempotency key.
  • Validation and other 4xx errors are not retried.
  • Verification and production use the same charge() method. Verification returns verification: true and creates no billing activity.
  • Keep the provider API key and charge token on the server. Never expose or log them.

AgenticProviderClient is synchronous for Flask and other WSGI applications. AsyncAgenticProviderClient is intended for FastAPI and other ASGI services. The default API base URL is https://mcp.agenticscraper.com.

Full REST and SDK documentation is available at https://docs.agenticscraper.com.

Download files

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

Source Distribution

agentic_scraper_provider_sdk-0.1.0.tar.gz (3.0 kB view details)

Uploaded Source

Built Distribution

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

agentic_scraper_provider_sdk-0.1.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

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

File metadata

File hashes

Hashes for agentic_scraper_provider_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 b9f3c5a1230437edac4656e795d5bc321aebf685f1b8f597fe3aa183625cc1d2
MD5 3dc8abd064a659ec983d1d8a58449ab5
BLAKE2b-256 ed2598dffa90a301d935e9a689cbaceabaa45213fb19268252d8ea3669f85934

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_scraper_provider_sdk-0.1.0.tar.gz:

Publisher: provider-sdk-python-release.yml on berkbirkan/agentic-scraper-cloud

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

File details

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

File metadata

File hashes

Hashes for agentic_scraper_provider_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9fda907ef72808416f97c7b02492a0b045cc72b912b6546cc2d2180fc0826948
MD5 3696b8a607ea841979e7ee40885abd2e
BLAKE2b-256 423c1a7e3c2a74ae7015ec9bfd97acf3307d819d41849ff1114643416bc87e44

See more details on using hashes here.

Provenance

The following attestation bundles were made for agentic_scraper_provider_sdk-0.1.0-py3-none-any.whl:

Publisher: provider-sdk-python-release.yml on berkbirkan/agentic-scraper-cloud

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 Sentry Error logging StatusPage Status page