@spicrawl/mcp 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/LICENSE +61 -0
- package/README.md +411 -2
- package/dist/client.d.ts +89 -0
- package/dist/client.js +187 -0
- package/dist/client.js.map +1 -0
- package/dist/http.d.ts +27 -0
- package/dist/http.js +220 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.js +79 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +16 -0
- package/dist/server.js +141 -0
- package/dist/server.js.map +1 -0
- package/dist/tools/actions.d.ts +534 -0
- package/dist/tools/actions.js +103 -0
- package/dist/tools/actions.js.map +1 -0
- package/dist/tools/batch.d.ts +2 -0
- package/dist/tools/batch.js +307 -0
- package/dist/tools/batch.js.map +1 -0
- package/dist/tools/browser.d.ts +2 -0
- package/dist/tools/browser.js +101 -0
- package/dist/tools/browser.js.map +1 -0
- package/dist/tools/common.d.ts +64 -0
- package/dist/tools/common.js +64 -0
- package/dist/tools/common.js.map +1 -0
- package/dist/tools/docs.d.ts +12 -0
- package/dist/tools/docs.js +277 -0
- package/dist/tools/docs.js.map +1 -0
- package/dist/tools/pdf.d.ts +11 -0
- package/dist/tools/pdf.js +36 -0
- package/dist/tools/pdf.js.map +1 -0
- package/dist/tools/requests.d.ts +2 -0
- package/dist/tools/requests.js +71 -0
- package/dist/tools/requests.js.map +1 -0
- package/dist/tools/scrape.d.ts +2 -0
- package/dist/tools/scrape.js +213 -0
- package/dist/tools/scrape.js.map +1 -0
- package/dist/tools/screenshots.d.ts +15 -0
- package/dist/tools/screenshots.js +69 -0
- package/dist/tools/screenshots.js.map +1 -0
- package/dist/tools/sessions.d.ts +2 -0
- package/dist/tools/sessions.js +145 -0
- package/dist/tools/sessions.js.map +1 -0
- package/dist/tools/usage.d.ts +2 -0
- package/dist/tools/usage.js +93 -0
- package/dist/tools/usage.js.map +1 -0
- package/package.json +75 -4
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `@spicrawl/mcp` are documented here. This project follows
|
|
4
|
+
[Semantic Versioning](https://semver.org/).
|
|
5
|
+
|
|
6
|
+
## 0.1.1 — 2026-10-01
|
|
7
|
+
|
|
8
|
+
Documentation and package metadata only; the server and its 25 tools are unchanged.
|
|
9
|
+
|
|
10
|
+
- README rewritten for npmjs.com: hosted endpoint first, one-click install links for Cursor and VS Code, per-client setup for Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Gemini CLI and Codex, tool tables by group, a "which tool to use" guide, environment variables, self-hosting, FAQ and troubleshooting. Every link is absolute so it works on npm.
|
|
11
|
+
- `package.json`: `mcpName` (`io.github.Spicrawl/mcp`) for the official MCP registry, a new `description` and `keywords`, and `homepage` now points at https://docs.spicrawl.com/agents/mcp.
|
|
12
|
+
|
|
13
|
+
## 0.1.0 — 2026-10-01
|
|
14
|
+
|
|
15
|
+
First public release of the Spicrawl MCP server, published to npm as `@spicrawl/mcp` from https://github.com/Spicrawl/mcp with an npm provenance attestation.
|
|
16
|
+
|
|
17
|
+
- `npx -y @spicrawl/mcp` runs the stdio server for any MCP client (Claude Code, Claude Desktop, Cursor, VS Code, Codex, …), keyed by `SPICRAWL_API_KEY`. Installed globally, the command is `spicrawl-mcp` (`spicrawl-mcp-server` is an alias).
|
|
18
|
+
- `spicrawl-mcp --http` (or `node dist/http.js`) runs the Streamable HTTP server behind the hosted endpoint at https://mcp.spicrawl.com/mcp: per-caller bearer-token auth validated against the API, sessions pinned to the key that opened them, idle-session eviction and a `/healthz` liveness route.
|
|
19
|
+
- 25 tools: `spicrawl_scrape`; batch jobs (`spicrawl_batch_submit`, `_list`, `_status`, `_results`, `_task_content`, `_cancel`, `_retry`, `_add_items`, `_close`); browser sessions (`spicrawl_session_create`, `_list`, `_get`, `_context`, `_release`, `_delete`); usage and request history (`spicrawl_usage`, `_usage_summary`, `_usage_reconciliation`, `spicrawl_requests_list`, `spicrawl_request_get`); `spicrawl_browser_connect_url` (coming soon); and the docs (`spicrawl_docs_search`, `_read`, `_index`).
|
|
20
|
+
- Tools refuse unknown arguments instead of dropping them, and surface the platform's error codes and guidance.
|
|
21
|
+
- Screenshots come back as MCP image blocks and printed pages (`format: "pdf"`) as PDF resource blocks.
|
|
22
|
+
- `--version` and `--help`. The version reported to MCP clients and in the `User-Agent` (`spicrawl-mcp/<version>`) is read from package.json.
|
|
23
|
+
|
|
24
|
+
Previously developed in Spicrawl's private repository as the unpublished `spicrawl-mcp-server` 0.2.0; this is the same server under its public name.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
|
|
5
|
+
http://www.apache.org/licenses/
|
|
6
|
+
|
|
7
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
8
|
+
|
|
9
|
+
1. Definitions.
|
|
10
|
+
|
|
11
|
+
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
|
16
|
+
|
|
17
|
+
"You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License.
|
|
18
|
+
|
|
19
|
+
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
|
20
|
+
|
|
21
|
+
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types.
|
|
22
|
+
|
|
23
|
+
"Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below).
|
|
24
|
+
|
|
25
|
+
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
|
26
|
+
|
|
27
|
+
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
|
28
|
+
|
|
29
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
|
30
|
+
|
|
31
|
+
2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form.
|
|
32
|
+
|
|
33
|
+
3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed.
|
|
34
|
+
|
|
35
|
+
4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions:
|
|
36
|
+
|
|
37
|
+
You must give any other recipients of the Work or Derivative Works a copy of this License; and
|
|
38
|
+
|
|
39
|
+
You must cause any modified files to carry prominent notices stating that You changed the files; and
|
|
40
|
+
|
|
41
|
+
You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and
|
|
42
|
+
|
|
43
|
+
If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License.
|
|
44
|
+
|
|
45
|
+
5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
|
46
|
+
|
|
47
|
+
6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file.
|
|
48
|
+
|
|
49
|
+
7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License.
|
|
50
|
+
|
|
51
|
+
8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages.
|
|
52
|
+
|
|
53
|
+
9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability.
|
|
54
|
+
|
|
55
|
+
END OF TERMS AND CONDITIONS
|
|
56
|
+
|
|
57
|
+
Copyright 2026 Spicrawl
|
|
58
|
+
|
|
59
|
+
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
60
|
+
this file except in compliance with the License. You may obtain a copy of the
|
|
61
|
+
License at http://www.apache.org/licenses/LICENSE-2.0
|
package/README.md
CHANGED
|
@@ -1,3 +1,412 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Spicrawl MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The Spicrawl MCP server is a Model Context Protocol server that gives AI agents in Claude Code, Claude Desktop, Cursor, VS Code, Windsurf, Gemini CLI and Codex web scraping to Markdown, structured data extraction, screenshots, browser sessions and batch scraping as 25 native tools.
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@spicrawl/mcp)
|
|
6
|
+
[](https://www.npmjs.com/package/@spicrawl/mcp)
|
|
7
|
+
[](https://github.com/Spicrawl/mcp/blob/main/LICENSE)
|
|
8
|
+
[](https://github.com/Spicrawl/mcp/actions/workflows/ci.yml)
|
|
9
|
+
|
|
10
|
+
**[Docs](https://docs.spicrawl.com/agents/mcp)** · **[Get an API key](https://app.spicrawl.com/signup)** · **[TypeScript SDK](https://github.com/Spicrawl/sdk)** · **[CLI](https://github.com/Spicrawl/cli)** · **[Agent plugins](https://github.com/Spicrawl/agent-plugins)** · **[Changelog](https://github.com/Spicrawl/mcp/blob/main/CHANGELOG.md)**
|
|
11
|
+
|
|
12
|
+
<p>
|
|
13
|
+
<a href="https://cursor.com/en/install-mcp?name=spicrawl&config=eyJ1cmwiOiJodHRwczovL21jcC5zcGljcmF3bC5jb20vbWNwIiwiaGVhZGVycyI6eyJBdXRob3JpemF0aW9uIjoiQmVhcmVyICR7ZW52OlNQSUNSQVdMX0FQSV9LRVl9In19"><img src="https://cursor.com/deeplink/mcp-install-dark.svg" alt="Add Spicrawl MCP server to Cursor" height="32" /></a>
|
|
14
|
+
<a href="https://vscode.dev/redirect/mcp/install?name=spicrawl&inputs=%5B%7B%22type%22%3A%22promptString%22%2C%22id%22%3A%22spicrawl-api-key%22%2C%22description%22%3A%22Spicrawl%20API%20key%22%2C%22password%22%3Atrue%7D%5D&config=%7B%22type%22%3A%22http%22%2C%22url%22%3A%22https%3A%2F%2Fmcp.spicrawl.com%2Fmcp%22%2C%22headers%22%3A%7B%22Authorization%22%3A%22Bearer%20%24%7Binput%3Aspicrawl-api-key%7D%22%7D%7D"><img src="https://img.shields.io/badge/VS_Code-Install_Spicrawl_MCP-0098FF?style=for-the-badge&logo=visualstudiocode&logoColor=white" alt="Install Spicrawl MCP server in VS Code" height="32" /></a>
|
|
15
|
+
</p>
|
|
16
|
+
|
|
17
|
+
## Quickstart
|
|
18
|
+
|
|
19
|
+
1. Create an API key at [app.spicrawl.com](https://app.spicrawl.com/signup). Keys start with `spicrawl_live_` or `spicrawl_test_`.
|
|
20
|
+
2. Connect the **hosted endpoint**, `https://mcp.spicrawl.com/mcp` (MCP Streamable HTTP, nothing to install):
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
export SPICRAWL_API_KEY=spicrawl_live_...
|
|
24
|
+
claude mcp add --transport http spicrawl https://mcp.spicrawl.com/mcp \
|
|
25
|
+
--header "Authorization: Bearer $SPICRAWL_API_KEY"
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Codex: `codex mcp add spicrawl --url https://mcp.spicrawl.com/mcp --bearer-token-env-var SPICRAWL_API_KEY`
|
|
29
|
+
|
|
30
|
+
3. Or run it **locally over stdio** (Node.js 20+), for clients that only launch local servers:
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
claude mcp add spicrawl --env SPICRAWL_API_KEY=$SPICRAWL_API_KEY -- npx -y @spicrawl/mcp
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
4. Ask your agent: *"Use Spicrawl to read https://example.com/pricing as markdown and list each plan with its price."* It calls `spicrawl_scrape` and gets the page back as Markdown.
|
|
37
|
+
|
|
38
|
+
Both transports serve the same 25 `spicrawl_*` tools, and every call runs under your key with the same scopes, limits and credits as a direct API call.
|
|
39
|
+
|
|
40
|
+
## What it does
|
|
41
|
+
|
|
42
|
+
- **Scrape any URL to Markdown**, text, HTML, a JSON envelope or a printed PDF with one tool, `spicrawl_scrape`. Markdown is the default and strips the page to its main content.
|
|
43
|
+
- **Render JavaScript** with `render: true` (the `obscura` browser engine, 3 credits) or pin real Chromium with `engine: "chromium"` (8 credits). A plain fetch costs 1 credit, and `mode: "auto"` escalates fetch to browser and bills only the rung that worked ([price table](https://docs.spicrawl.com/credits)).
|
|
44
|
+
- **Extract structured data** with a CSS/XPath selector map (`extract`) or from the JSON-LD, OpenGraph, Twitter Card and microdata a page publishes (`autoparse`).
|
|
45
|
+
- **Drive the page** before capture with 8 typed browser actions: `click`, `fill`, `wait_for`, `wait_for_navigation`, `scroll` (including infinite scroll), `select`, `evaluate` and `screenshot`.
|
|
46
|
+
- **Return screenshots and PDFs the model can see**: screenshots arrive as MCP image blocks (up to 5 MB of base64 each) and printed pages as `application/pdf` resource blocks (up to 10 MB).
|
|
47
|
+
- **Batch scrape thousands of URLs** as one async job, up to 10,000 items per call, with 9 tools to submit, poll, page through results, retry, cancel and keep a job open for crawling.
|
|
48
|
+
- **Keep a logged-in browser** with persistent sessions: cookies, storage and a pinned engine reused across scrapes.
|
|
49
|
+
- **Answer "what did that cost?"** from usage and request-log tools, and **read the Spicrawl docs** from inside the agent.
|
|
50
|
+
|
|
51
|
+
## Which tool to use
|
|
52
|
+
|
|
53
|
+
- If you need one page's content or data now, use `spicrawl_scrape`.
|
|
54
|
+
- If the page is blank or a skeleton without JavaScript, call `spicrawl_scrape` again with `render: true`.
|
|
55
|
+
- If you know the page's structure, use `extract` with CSS selectors; if you don't, try `autoparse`.
|
|
56
|
+
- If you have more than about 20 URLs, use `spicrawl_batch_submit`, then `spicrawl_batch_status` and `spicrawl_batch_results`.
|
|
57
|
+
- If you discover URLs as you go (crawling), submit with `open: true`, append with `spicrawl_batch_add_items` and finish with `spicrawl_batch_close`.
|
|
58
|
+
- If you must log in first, use `spicrawl_session_create` and pass its `id` as `session_id` to `spicrawl_scrape`.
|
|
59
|
+
- If a call failed and you need to know why, use `spicrawl_request_get` with the request id, or `spicrawl_requests_list` with `only_errors`.
|
|
60
|
+
- If you are unsure of a parameter or an error code, use `spicrawl_docs_search` before guessing.
|
|
61
|
+
|
|
62
|
+
## Tools
|
|
63
|
+
|
|
64
|
+
25 tools, grouped by task. Tools reject unknown arguments, so a misspelt field fails with an error naming it instead of being silently dropped. Full argument reference: [docs.spicrawl.com/agents/mcp](https://docs.spicrawl.com/agents/mcp#tools).
|
|
65
|
+
|
|
66
|
+
### Scrape a website to Markdown
|
|
67
|
+
|
|
68
|
+
| Tool | What it does | Key parameters |
|
|
69
|
+
|---|---|---|
|
|
70
|
+
| `spicrawl_scrape` | Retrieve one URL as `markdown` (default), `text`, `html`, `json` or `pdf`, with optional rendering, extraction, links, screenshots and browser actions. | `url`, `format`, `render`, `engine`, `mode`, `main_content_only`, `include_tags`, `exclude_tags`, `extract`, `autoparse`, `links`, `screenshot`, `actions`, `wait_for`, `session_id`, `proxy`, `cache`, `max_cost` |
|
|
71
|
+
|
|
72
|
+
### Batch scrape many URLs
|
|
73
|
+
|
|
74
|
+
| Tool | What it does | Key parameters |
|
|
75
|
+
|---|---|---|
|
|
76
|
+
| `spicrawl_batch_submit` | Queue many URLs as one async job with shared settings; returns the job with `estimated_credits`. | `urls` or `items`, `render`, `format`, `open`, `max_attempts`, `credit_budget`, `max_cost` |
|
|
77
|
+
| `spicrawl_batch_list` | List the project's batch jobs, newest first. | `status`, `limit` (max 200), `cursor` |
|
|
78
|
+
| `spicrawl_batch_status` | One job's status and progress. | `job_id` |
|
|
79
|
+
| `spicrawl_batch_results` | A page of finished items; works while the job runs. | `job_id`, `status`, `limit` (max 5000), `cursor` |
|
|
80
|
+
| `spicrawl_batch_task_content` | The full payload of one item. | `job_id`, `seq` |
|
|
81
|
+
| `spicrawl_batch_cancel` | Cancel a job; finished items keep their results. | `job_id` |
|
|
82
|
+
| `spicrawl_batch_retry` | Re-queue every failed item. | `job_id` |
|
|
83
|
+
| `spicrawl_batch_add_items` | Append URLs to a job submitted with `open: true`. | `job_id`, `urls` or `items` |
|
|
84
|
+
| `spicrawl_batch_close` | Stop an open job accepting items so it can complete. | `job_id` |
|
|
85
|
+
|
|
86
|
+
### Browser sessions
|
|
87
|
+
|
|
88
|
+
| Tool | What it does | Key parameters |
|
|
89
|
+
|---|---|---|
|
|
90
|
+
| `spicrawl_session_create` | Create a persistent browser identity (cookies, storage, pinned engine). | `engine`, `ttl_seconds`, `session_context` |
|
|
91
|
+
| `spicrawl_session_list` | List sessions, newest first. | `status`, `engine`, `limit`, `cursor` |
|
|
92
|
+
| `spicrawl_session_get` | One session's status, engine, exit, usage and expiry. | `session_id` |
|
|
93
|
+
| `spicrawl_session_context` | Dump a live session's cookies and storage (contains secrets). | `session_id` |
|
|
94
|
+
| `spicrawl_session_release` | End a session; its record stays as `released`. | `session_id` |
|
|
95
|
+
| `spicrawl_session_delete` | Permanently delete a session and its state. | `session_id` |
|
|
96
|
+
|
|
97
|
+
### Usage and request history
|
|
98
|
+
|
|
99
|
+
| Tool | What it does | Key parameters |
|
|
100
|
+
|---|---|---|
|
|
101
|
+
| `spicrawl_usage` | Billing-grade usage over a date window (`read` scope). | `from`, `to`, `group_by`, `metrics` |
|
|
102
|
+
| `spicrawl_usage_summary` | Current-period totals (`read` scope). | none |
|
|
103
|
+
| `spicrawl_usage_reconciliation` | One day's drift between the request log and the billed rollup (`read` scope). | `day` |
|
|
104
|
+
| `spicrawl_requests_list` | Recent API calls with status, error code, engine, latency and credits. | `only_errors`, `status`, `limit`, `all_projects` |
|
|
105
|
+
| `spicrawl_request_get` | The full log record of one call. | `id` |
|
|
106
|
+
|
|
107
|
+
### Docs
|
|
108
|
+
|
|
109
|
+
| Tool | What it does | Key parameters |
|
|
110
|
+
|---|---|---|
|
|
111
|
+
| `spicrawl_docs_search` | Search the Spicrawl docs; an error code also links to its entry. | `query`, `limit` (1-20, default 8) |
|
|
112
|
+
| `spicrawl_docs_read` | Read one docs page as Markdown (truncated over 60,000 characters). | `path` |
|
|
113
|
+
| `spicrawl_docs_index` | The docs' `llms.txt`: every page with its title and `.md` link. | none |
|
|
114
|
+
|
|
115
|
+
### Coming soon
|
|
116
|
+
|
|
117
|
+
`spicrawl_browser_connect_url` will mint a single-use CDP WebSocket URL for driving a Spicrawl-hosted browser from Puppeteer or Playwright; remote browsers are not available yet. The schemas also accept `ai_extract`, `stealth`, `extract_preset`, `premium_proxy`, `proxy_country` and `sticky_key` ahead of launch. Agents should not send them yet.
|
|
118
|
+
|
|
119
|
+
## Example prompts
|
|
120
|
+
|
|
121
|
+
- *"Scrape https://example.com/pricing as markdown and summarise the plans."*
|
|
122
|
+
- *"Get the product name, price and stock status from this URL."* (`spicrawl_scrape` with `extract` or `autoparse`)
|
|
123
|
+
- *"Take a full-page screenshot of https://example.com after the cookie banner is gone."* (`render`, `actions`, `screenshot_fullpage`)
|
|
124
|
+
- *"Scrape these 500 URLs and give me each page title."* (`spicrawl_batch_submit`, then `spicrawl_batch_results`)
|
|
125
|
+
- *"Why did my last scrape fail?"* (`spicrawl_requests_list` with `only_errors`, then `spicrawl_request_get`)
|
|
126
|
+
- *"How many credits have I used this month?"* (`spicrawl_usage_summary`)
|
|
127
|
+
|
|
128
|
+
## Set up your MCP client
|
|
129
|
+
|
|
130
|
+
Put your key in `SPICRAWL_API_KEY` and reference it from the config where the client allows, so the key never lands in a committed file.
|
|
131
|
+
|
|
132
|
+
<details>
|
|
133
|
+
<summary><b>Claude Code</b></summary>
|
|
134
|
+
|
|
135
|
+
Hosted endpoint, stored for you only (add `--scope user` for every project):
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
claude mcp add --transport http spicrawl https://mcp.spicrawl.com/mcp \
|
|
139
|
+
--header "Authorization: Bearer $SPICRAWL_API_KEY"
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
To share it with a team, commit `.mcp.json` at the project root. Claude Code expands `${VAR}`, so each teammate's own key is used:
|
|
143
|
+
|
|
144
|
+
```json
|
|
145
|
+
{
|
|
146
|
+
"mcpServers": {
|
|
147
|
+
"spicrawl": {
|
|
148
|
+
"type": "http",
|
|
149
|
+
"url": "https://mcp.spicrawl.com/mcp",
|
|
150
|
+
"headers": { "Authorization": "Bearer ${SPICRAWL_API_KEY}" }
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
Or install the plugin, which bundles the MCP server and the Spicrawl agent skill:
|
|
157
|
+
|
|
158
|
+
```bash
|
|
159
|
+
claude plugin marketplace add Spicrawl/agent-plugins
|
|
160
|
+
claude plugin install spicrawl@spicrawl-plugins
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
Check with `claude mcp list`, or `/mcp` in a session. More: [docs.spicrawl.com/agents/claude-code](https://docs.spicrawl.com/agents/claude-code).
|
|
164
|
+
|
|
165
|
+
</details>
|
|
166
|
+
|
|
167
|
+
<details>
|
|
168
|
+
<summary><b>Claude Desktop</b></summary>
|
|
169
|
+
|
|
170
|
+
Claude Desktop's `claude_desktop_config.json` starts local (stdio) servers only, and custom connectors cannot send an `Authorization` header, so run the package locally. The file is at `~/Library/Application Support/Claude/claude_desktop_config.json` on macOS and `%APPDATA%\Claude\claude_desktop_config.json` on Windows:
|
|
171
|
+
|
|
172
|
+
```json
|
|
173
|
+
{
|
|
174
|
+
"mcpServers": {
|
|
175
|
+
"spicrawl": {
|
|
176
|
+
"command": "npx",
|
|
177
|
+
"args": ["-y", "@spicrawl/mcp"],
|
|
178
|
+
"env": { "SPICRAWL_API_KEY": "spicrawl_live_..." }
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
Restart Claude Desktop after saving.
|
|
185
|
+
|
|
186
|
+
</details>
|
|
187
|
+
|
|
188
|
+
<details>
|
|
189
|
+
<summary><b>Cursor</b></summary>
|
|
190
|
+
|
|
191
|
+
Use the **Add to Cursor** button above, or add this to `.cursor/mcp.json` in the project (or `~/.cursor/mcp.json` for every project). Cursor resolves `${env:NAME}` in `url` and `headers`, so start Cursor from an environment where `SPICRAWL_API_KEY` is set:
|
|
192
|
+
|
|
193
|
+
```json
|
|
194
|
+
{
|
|
195
|
+
"mcpServers": {
|
|
196
|
+
"spicrawl": {
|
|
197
|
+
"url": "https://mcp.spicrawl.com/mcp",
|
|
198
|
+
"headers": { "Authorization": "Bearer ${env:SPICRAWL_API_KEY}" }
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
More: [docs.spicrawl.com/agents/cursor](https://docs.spicrawl.com/agents/cursor).
|
|
205
|
+
|
|
206
|
+
</details>
|
|
207
|
+
|
|
208
|
+
<details>
|
|
209
|
+
<summary><b>VS Code (GitHub Copilot)</b></summary>
|
|
210
|
+
|
|
211
|
+
Use the **Install in VS Code** button above, or add this to `.vscode/mcp.json`. VS Code uses the `servers` key, and the input variable makes it ask for the key once and store it securely, so the file is safe to commit:
|
|
212
|
+
|
|
213
|
+
```json
|
|
214
|
+
{
|
|
215
|
+
"inputs": [
|
|
216
|
+
{ "type": "promptString", "id": "spicrawl-api-key", "description": "Spicrawl API key", "password": true }
|
|
217
|
+
],
|
|
218
|
+
"servers": {
|
|
219
|
+
"spicrawl": {
|
|
220
|
+
"type": "http",
|
|
221
|
+
"url": "https://mcp.spicrawl.com/mcp",
|
|
222
|
+
"headers": { "Authorization": "Bearer ${input:spicrawl-api-key}" }
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
VS Code does not expand `${env:...}` inside `headers`, so use the input variable. More: [docs.spicrawl.com/agents/github-copilot](https://docs.spicrawl.com/agents/github-copilot).
|
|
229
|
+
|
|
230
|
+
</details>
|
|
231
|
+
|
|
232
|
+
<details>
|
|
233
|
+
<summary><b>Windsurf (Devin Desktop)</b></summary>
|
|
234
|
+
|
|
235
|
+
Windsurf is now named Devin Desktop. For the default **Devin Local** agent, add the server in local scope (saved to the gitignored `.devin/mcp_config.local.json`):
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
devin mcp add spicrawl https://mcp.spicrawl.com/mcp -H "Authorization: Bearer $SPICRAWL_API_KEY"
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
For the legacy **Cascade** agent, edit `~/.config/devin/mcp_config.json` (`%APPDATA%\devin\mcp_config.json` on Windows). Cascade reads the URL from `serverUrl` and replaces `${env:...}`:
|
|
242
|
+
|
|
243
|
+
```json
|
|
244
|
+
{
|
|
245
|
+
"mcpServers": {
|
|
246
|
+
"spicrawl": {
|
|
247
|
+
"serverUrl": "https://mcp.spicrawl.com/mcp",
|
|
248
|
+
"headers": { "Authorization": "Bearer ${env:SPICRAWL_API_KEY}" }
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
253
|
+
|
|
254
|
+
More: [docs.spicrawl.com/agents/windsurf](https://docs.spicrawl.com/agents/windsurf).
|
|
255
|
+
|
|
256
|
+
</details>
|
|
257
|
+
|
|
258
|
+
<details>
|
|
259
|
+
<summary><b>Gemini CLI</b></summary>
|
|
260
|
+
|
|
261
|
+
Gemini CLI strips variables whose names contain `KEY`, `TOKEN` or `AUTH` before expanding headers, so export the key under another name:
|
|
262
|
+
|
|
263
|
+
```bash
|
|
264
|
+
export SPICRAWL_MCP_BEARER="$SPICRAWL_API_KEY"
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
Then add to `~/.gemini/settings.json` (or `.gemini/settings.json` for one project). Streamable HTTP uses the `httpUrl` key:
|
|
268
|
+
|
|
269
|
+
```json
|
|
270
|
+
{
|
|
271
|
+
"mcpServers": {
|
|
272
|
+
"spicrawl": {
|
|
273
|
+
"httpUrl": "https://mcp.spicrawl.com/mcp",
|
|
274
|
+
"headers": { "Authorization": "Bearer $SPICRAWL_MCP_BEARER" }
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
```
|
|
279
|
+
|
|
280
|
+
Or: `gemini mcp add --scope user --transport http --header 'Authorization: Bearer $SPICRAWL_MCP_BEARER' spicrawl https://mcp.spicrawl.com/mcp`. Run `/mcp` to check. More: [docs.spicrawl.com/agents/gemini-cli](https://docs.spicrawl.com/agents/gemini-cli).
|
|
281
|
+
|
|
282
|
+
</details>
|
|
283
|
+
|
|
284
|
+
<details>
|
|
285
|
+
<summary><b>Codex</b></summary>
|
|
286
|
+
|
|
287
|
+
Codex reads the key from the environment each time it connects, so the key never lands in a file:
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
codex mcp add spicrawl --url https://mcp.spicrawl.com/mcp --bearer-token-env-var SPICRAWL_API_KEY
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
The equivalent `~/.codex/config.toml` (or `.codex/config.toml` in a trusted project):
|
|
294
|
+
|
|
295
|
+
```toml
|
|
296
|
+
[mcp_servers.spicrawl]
|
|
297
|
+
url = "https://mcp.spicrawl.com/mcp"
|
|
298
|
+
bearer_token_env_var = "SPICRAWL_API_KEY"
|
|
299
|
+
```
|
|
300
|
+
|
|
301
|
+
Local stdio instead:
|
|
302
|
+
|
|
303
|
+
```toml
|
|
304
|
+
[mcp_servers.spicrawl]
|
|
305
|
+
command = "npx"
|
|
306
|
+
args = ["-y", "@spicrawl/mcp"]
|
|
307
|
+
env = { SPICRAWL_API_KEY = "spicrawl_live_..." }
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
More: [docs.spicrawl.com/agents/codex](https://docs.spicrawl.com/agents/codex).
|
|
311
|
+
|
|
312
|
+
</details>
|
|
313
|
+
|
|
314
|
+
<details>
|
|
315
|
+
<summary><b>Any other MCP client</b></summary>
|
|
316
|
+
|
|
317
|
+
| Setting | Value |
|
|
318
|
+
|---|---|
|
|
319
|
+
| Transport | Streamable HTTP |
|
|
320
|
+
| URL | `https://mcp.spicrawl.com/mcp` |
|
|
321
|
+
| Header | `Authorization: Bearer <your key>` |
|
|
322
|
+
|
|
323
|
+
A stdio-only client runs `npx -y @spicrawl/mcp` with `SPICRAWL_API_KEY` in its environment. The server accepts API keys only, not OAuth. Setup pages for more clients (OpenCode, Zed, JetBrains, Cline, Goose and others): [docs.spicrawl.com/agents/mcp](https://docs.spicrawl.com/agents/mcp).
|
|
324
|
+
|
|
325
|
+
</details>
|
|
326
|
+
|
|
327
|
+
## Environment variables
|
|
328
|
+
|
|
329
|
+
| Variable | Default | Used by | Purpose |
|
|
330
|
+
|---|---|---|---|
|
|
331
|
+
| `SPICRAWL_API_KEY` | none (required) | stdio | Your API key. The HTTP server ignores it and uses each caller's bearer token. |
|
|
332
|
+
| `SPICRAWL_BASE_URL` | `https://api.spicrawl.com` (stdio), `http://127.0.0.1:8080` (HTTP) | both | The Spicrawl API the tools call. |
|
|
333
|
+
| `SPICRAWL_PUBLIC_BASE_URL` | `SPICRAWL_BASE_URL` | both | The API as the end user reaches it, used only in URLs handed back. |
|
|
334
|
+
| `SPICRAWL_DOCS_URL` | `https://docs.spicrawl.com` | both | Docs base URL for the docs tools. Your key is never sent there. |
|
|
335
|
+
| `SPICRAWL_DOCS_HOST` | none | both | Legacy: an origin whose docs are at `/docs`. Read only when `SPICRAWL_DOCS_URL` is unset. |
|
|
336
|
+
| `SPICRAWL_MCP_ADDR` | `127.0.0.1:8090` | HTTP | Listen address, `host:port`. |
|
|
337
|
+
| `SPICRAWL_MCP_SESSION_IDLE_MS` | `1800000` (30 min) | HTTP | Idle MCP sessions are dropped after this long. |
|
|
338
|
+
|
|
339
|
+
With no docs variable set, a server pointed at a self-hosted API reads that API's own docs at `<SPICRAWL_PUBLIC_BASE_URL or SPICRAWL_BASE_URL>/docs`.
|
|
340
|
+
|
|
341
|
+
## Self-host the MCP server over HTTP
|
|
342
|
+
|
|
343
|
+
The hosted endpoint runs this package's Streamable HTTP server. To run your own:
|
|
344
|
+
|
|
345
|
+
```bash
|
|
346
|
+
SPICRAWL_MCP_ADDR=127.0.0.1:8090 \
|
|
347
|
+
SPICRAWL_BASE_URL=https://api.spicrawl.com \
|
|
348
|
+
npx -y @spicrawl/mcp --http
|
|
349
|
+
```
|
|
350
|
+
|
|
351
|
+
- `SPICRAWL_BASE_URL` **defaults to `http://127.0.0.1:8080`** in HTTP mode (a Spicrawl API on the same host), not to the public API. Set it to `https://api.spicrawl.com` to front the public API.
|
|
352
|
+
- MCP is served at `POST`/`GET`/`DELETE /mcp`; liveness at `GET /healthz` (no auth).
|
|
353
|
+
- Each caller sends their own key as `Authorization: Bearer spicrawl_live_...`. The key is checked against the API before a session opens (`401` if refused, `503` with `Retry-After` if the API cannot be reached), and a session is pinned to the key that opened it.
|
|
354
|
+
- The server speaks plain HTTP. Put it behind TLS before sending keys across a network.
|
|
355
|
+
|
|
356
|
+
Installed globally (`npm install -g @spicrawl/mcp`), the command is `spicrawl-mcp` (alias `spicrawl-mcp-server`), with `--http`, `--version` and `--help`.
|
|
357
|
+
|
|
358
|
+
## FAQ
|
|
359
|
+
|
|
360
|
+
### Is there a hosted Spicrawl MCP server?
|
|
361
|
+
Yes: `https://mcp.spicrawl.com/mcp`, MCP Streamable HTTP, authenticated with `Authorization: Bearer <API key>`, so there is nothing to install.
|
|
362
|
+
|
|
363
|
+
### Is Spicrawl free?
|
|
364
|
+
Spicrawl bills credits per successful request, and during the beta every organization gets one plan of 1,000 credits per month. Failed requests cost 0 credits; a cache hit is billed at the same price as the fetch that stored it. See [Credits](https://docs.spicrawl.com/credits).
|
|
365
|
+
|
|
366
|
+
### Does it render JavaScript?
|
|
367
|
+
Yes. Set `render: true` on `spicrawl_scrape` to run the page in a browser, or `mode: "auto"` to let Spicrawl escalate from a plain fetch only when needed.
|
|
368
|
+
|
|
369
|
+
### Does it work with Claude Code, Cursor and VS Code?
|
|
370
|
+
Yes, and with Claude Desktop, Windsurf, Gemini CLI, Codex and any client that speaks MCP Streamable HTTP with custom headers or launches stdio servers.
|
|
371
|
+
|
|
372
|
+
### Can it crawl a whole website?
|
|
373
|
+
There is no single crawl tool. Scrape a page with `links: true` to get its links, then feed them to an open batch job (`open: true` and `spicrawl_batch_add_items`).
|
|
374
|
+
|
|
375
|
+
### Does it support OAuth?
|
|
376
|
+
No. The server accepts Spicrawl API keys only; turn OAuth off for this server in clients that try it on a `401`.
|
|
377
|
+
|
|
378
|
+
### Should I use the MCP server, the SDK or the CLI?
|
|
379
|
+
Use the MCP server when an AI agent should call Spicrawl as tools. Use [`@spicrawl/sdk`](https://github.com/Spicrawl/sdk) in your own TypeScript or JavaScript code, [`@spicrawl/cli`](https://github.com/Spicrawl/cli) in a terminal or shell script, and the [REST API](https://docs.spicrawl.com/quickstart) from any other language.
|
|
380
|
+
|
|
381
|
+
## Troubleshooting
|
|
382
|
+
|
|
383
|
+
| Symptom | Fix |
|
|
384
|
+
|---|---|
|
|
385
|
+
| HTTP `401` or "Unauthorized: send your Spicrawl API key" | The header is missing, or the key is unknown, revoked or expired. Check that the variable is set in the environment the client started from. |
|
|
386
|
+
| The header contains a literal `${SPICRAWL_API_KEY}` | The client did not expand it. Use `${VAR}` in Claude Code, `${env:VAR}` in Cursor, `${input:id}` in VS Code, `bearer_token_env_var` in Codex. |
|
|
387
|
+
| HTTP `503` with `Retry-After` on connect | The server could not reach the API to check your key. Retry; your key is fine. |
|
|
388
|
+
| `ERR::AUTH::INSUFFICIENT_SCOPE` from a `spicrawl_usage*` tool | Grant the key the `read` scope in the dashboard. |
|
|
389
|
+
| `ERR::LIMIT::QUOTA_EXCEEDED` (HTTP 402) | The monthly credit allowance is used up. Not retryable until it resets. |
|
|
390
|
+
| "Unknown argument" on `spicrawl_scrape` | Use the tool's names: `render`, not `js_render`; `format`, not `response_format`. |
|
|
391
|
+
| Tools do not appear | Restart the client, and check the config key (`servers` in VS Code, `mcpServers` elsewhere). |
|
|
392
|
+
| `npx` not found (stdio) | Install Node.js 20 or later. |
|
|
393
|
+
|
|
394
|
+
`curl -i https://mcp.spicrawl.com/mcp` without a key answers `401`: the endpoint is reachable.
|
|
395
|
+
|
|
396
|
+
## Related packages
|
|
397
|
+
|
|
398
|
+
- [`@spicrawl/sdk`](https://github.com/Spicrawl/sdk): the official TypeScript SDK for the Spicrawl API.
|
|
399
|
+
- [`@spicrawl/cli`](https://github.com/Spicrawl/cli): the Spicrawl command-line interface.
|
|
400
|
+
- [Spicrawl/agent-plugins](https://github.com/Spicrawl/agent-plugins): plugins that bundle this server and the Spicrawl skill for Claude Code, Codex, Cursor, Gemini CLI and more.
|
|
401
|
+
|
|
402
|
+
## Links
|
|
403
|
+
|
|
404
|
+
- Documentation: [docs.spicrawl.com/agents/mcp](https://docs.spicrawl.com/agents/mcp)
|
|
405
|
+
- Docs for LLMs: [docs.spicrawl.com/llms.txt](https://docs.spicrawl.com/llms.txt)
|
|
406
|
+
- Dashboard and API keys: [app.spicrawl.com](https://app.spicrawl.com)
|
|
407
|
+
- Issues: [github.com/Spicrawl/mcp/issues](https://github.com/Spicrawl/mcp/issues)
|
|
408
|
+
- Security: [SECURITY.md](https://github.com/Spicrawl/mcp/blob/main/SECURITY.md). Never commit an API key; revoke a leaked one at [app.spicrawl.com](https://app.spicrawl.com).
|
|
409
|
+
|
|
410
|
+
## License
|
|
411
|
+
|
|
412
|
+
[Apache-2.0](https://github.com/Spicrawl/mcp/blob/main/LICENSE)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thin client over the Spicrawl REST API.
|
|
3
|
+
*
|
|
4
|
+
* Every MCP tool ultimately calls one of these methods. The client owns three
|
|
5
|
+
* things the tools should not each re-implement: authentication (the caller's
|
|
6
|
+
* API key as a bearer token), the base URL, and turning the platform's RFC 7807
|
|
7
|
+
* problem envelope into an actionable Error the agent can act on rather than a
|
|
8
|
+
* bare HTTP status.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* This package's version, read from package.json so the User-Agent, the MCP
|
|
12
|
+
* server's advertised version and the published package cannot drift. The
|
|
13
|
+
* path is relative to the compiled file (dist/client.js), and package.json
|
|
14
|
+
* ships with every npm package regardless of `files`.
|
|
15
|
+
*/
|
|
16
|
+
export declare const PACKAGE_VERSION: string;
|
|
17
|
+
/**
|
|
18
|
+
* Sent on every API call. The API classifies the client surface from it
|
|
19
|
+
* (cli / mcp / sdk / other) and records it on each request-log row, so MCP
|
|
20
|
+
* traffic is countable. The product token must stay `spicrawl-mcp/`.
|
|
21
|
+
*/
|
|
22
|
+
export declare const USER_AGENT: string;
|
|
23
|
+
/**
|
|
24
|
+
* The docs base URL from the environment, no trailing slash; page paths are
|
|
25
|
+
* appended to it directly (`<base>/errors`, `<base>/llms.txt`):
|
|
26
|
+
*
|
|
27
|
+
* 1. SPICRAWL_DOCS_URL, the full base (`https://docs.spicrawl.com`, or
|
|
28
|
+
* `http://host:8080/docs` on a self-hosted deployment);
|
|
29
|
+
* 2. SPICRAWL_DOCS_HOST + `/docs`, the legacy origin-only setting, which keeps
|
|
30
|
+
* its old meaning so an existing env file does not silently change;
|
|
31
|
+
* 3. a self-hosted API (SPICRAWL_PUBLIC_BASE_URL, else SPICRAWL_BASE_URL) +
|
|
32
|
+
* `/docs`, where every deployment serves its own docs;
|
|
33
|
+
* 4. https://docs.spicrawl.com, also when that API is the public one.
|
|
34
|
+
*
|
|
35
|
+
* Read from the raw environment, not the client's baseURL, so a stdio server
|
|
36
|
+
* with no base URL set points at the public docs rather than localhost.
|
|
37
|
+
*/
|
|
38
|
+
export declare function docsBaseFromEnv(env?: NodeJS.ProcessEnv): string;
|
|
39
|
+
/** The RFC 7807 problem shape every Spicrawl error uses. */
|
|
40
|
+
interface Problem {
|
|
41
|
+
code?: string;
|
|
42
|
+
title?: string;
|
|
43
|
+
detail?: string;
|
|
44
|
+
status?: number;
|
|
45
|
+
retryable?: boolean;
|
|
46
|
+
target_status?: number | null;
|
|
47
|
+
doc_url?: string;
|
|
48
|
+
}
|
|
49
|
+
/** A failed request, carrying the platform's own error code and guidance. */
|
|
50
|
+
export declare class ILayerError extends Error {
|
|
51
|
+
readonly code: string;
|
|
52
|
+
readonly status: number;
|
|
53
|
+
readonly retryable: boolean;
|
|
54
|
+
readonly docUrl?: string;
|
|
55
|
+
constructor(status: number, problem: Problem, fallback: string);
|
|
56
|
+
}
|
|
57
|
+
export interface ClientConfig {
|
|
58
|
+
baseURL?: string;
|
|
59
|
+
/**
|
|
60
|
+
* The API base URL as the MCP's USERS reach it, for URLs handed back to them
|
|
61
|
+
* (the browser tool's CDP URL). Differs from baseURL when the MCP talks to
|
|
62
|
+
* the API over loopback. Defaults to baseURL.
|
|
63
|
+
*/
|
|
64
|
+
publicBaseURL?: string;
|
|
65
|
+
apiKey: string;
|
|
66
|
+
timeoutMs?: number;
|
|
67
|
+
/**
|
|
68
|
+
* The public docs base (`https://docs.spicrawl.com`, `http://host:8080/docs`)
|
|
69
|
+
* the docs tools read from. Defaults to docsBaseFromEnv(). The API key is
|
|
70
|
+
* never sent there.
|
|
71
|
+
*/
|
|
72
|
+
docsBaseURL?: string;
|
|
73
|
+
}
|
|
74
|
+
export declare class ILayerClient {
|
|
75
|
+
readonly baseURL: string;
|
|
76
|
+
/** Base URL for URLs returned to the caller; never used for upstream calls. */
|
|
77
|
+
readonly publicBaseURL: string;
|
|
78
|
+
/** The caller's key. Read by tools that hand out URLs carrying it (browser). */
|
|
79
|
+
readonly apiKey: string;
|
|
80
|
+
/** Public docs base, e.g. https://docs.spicrawl.com; no trailing slash. */
|
|
81
|
+
readonly docsBaseURL: string;
|
|
82
|
+
private readonly timeoutMs;
|
|
83
|
+
constructor(config: ClientConfig);
|
|
84
|
+
/** POST /v1/scrape — retrieve, render, and extract one URL. */
|
|
85
|
+
scrape(params: Record<string, unknown>): Promise<unknown>;
|
|
86
|
+
/** Any REST call. Tools for newer endpoints use this directly. */
|
|
87
|
+
request(method: string, path: string, body?: Record<string, unknown>): Promise<unknown>;
|
|
88
|
+
}
|
|
89
|
+
export {};
|