Metadata-Version: 2.5
Name: scrapely-mcp
Version: 0.1.1
Summary: Scrapely MCP Server for Python
Project-URL: Homepage, https://mcp.scrape.ly
Author: Scrapely
License: MIT License
        
        Copyright (c) 2025 Scrapely
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE.md
Keywords: actors,mcp,model context protocol,scrapely,server
Classifier: Environment :: Console
Classifier: Intended Audience :: Developers
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Topic :: Software Development :: Libraries
Requires-Python: >=3.11
Requires-Dist: algoliasearch>=3.0.0
Requires-Dist: analytics-python>=1.4
Requires-Dist: httpx>=0.27.0
Requires-Dist: jsonschema>=4.23.0
Requires-Dist: mcp>=1.9.0
Requires-Dist: pydantic>=2.11.0
Requires-Dist: scrapely-client-python>=1.0.0
Requires-Dist: sentry-sdk>=2.0.0
Requires-Dist: starlette>=0.38.0
Requires-Dist: uvicorn>=0.30.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.24.0; extra == 'dev'
Requires-Dist: pytest>=8.0.0; extra == 'dev'
Requires-Dist: respx>=0.21.0; extra == 'dev'
Requires-Dist: ruff>=0.8.0; extra == 'dev'
Description-Content-Type: text/markdown

# scrapely-mcp-python

Scrapely MCP server for Python. It exposes
Scrapely Actors, storage, runs, tasks, and documentation to MCP clients over **stdio** and
**streamable HTTP** transports, with dynamic per-Actor tools, MCP-Apps widget support,
Skyfire/x402 agentic payments, Segment telemetry, and Sentry instrumentation.

## Install

```bash
python -m venv .venv && source .venv/bin/activate
pip install -e .
# The local Scrapely API client is expected as a sibling checkout:
pip install -e ../scrapely-client-python
```

## Run (stdio)

```bash
export SCRAPELY_TOKEN=...   # or keep a token in ~/.scrapely/credentials.json
scrapely-mcp-server --actors=username/actor-name
scrapely-mcp-server --tools=docs                      # public tools only, no token needed
scrapely-mcp-server --tools=actors,runs,storage       # category selection
scrapely-mcp-server --ui=apps                         # force MCP Apps (widget) mode
```

Dev server (stdio, or streamable HTTP on localhost with `--http`):

```bash
python -m scrapely_mcp.dev_server --http --port 8000
```

## Library surface

```python
from scrapely_mcp import ActorsMcpServer, create_stateless_server
```

- `ActorsMcpServer(options)` — the facade: `load_tools_from_input(input, client)`,
  `add_tool`, `remove_tool`, `connect(transport)`, `close()`.
- `create_stateless_server(input, options)` — per-request composition for stateless hosts.

## Tool categories

`actors`, `docs`, `runs`, `storage`, `tasks`, `dev` — selected via `--tools`/`Input.tools`;
Actor full names (e.g. `scrapely/web-scraper`) are also valid selectors and become dynamic
tools generated from the Actor's real input schema.

## Implementation notes

- **MCP SDK**: official Python `mcp` package (low-level `Server`).
- **Validation**: `jsonschema` with AJV-compatible semantics (array coercion,
  additional-property stripping, ReDoS keyword removal) — see `utils/ajv.py`.
- **Web widgets**: the React widget bundle stays JavaScript; the built HTML assets are
  shipped under `scrapely_mcp/web/` and served as MCP resources (`resources/widgets.py`).
- **Payments**: Skyfire and x402 agentic-payment providers; payment error payloads
  (e.g. x402 `402` payment-required responses) are surfaced directly by the client
  (`utils/payment_errors.py`).
- **Eval harness** (`evals/`): intentionally not included in this package; the unit
  test suites live under `tests/` (pytest).
- **Logging**: a stdlib wrapper provides the structured logging call surface,
  including `softFail` and the log-aggregator "error"-word sanitization.

## Tests

```bash
pip install -e .[dev]
pytest
```
