@opencraw/mcp 0.1.44 → 0.1.47
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/README.md +27 -1
- package/dist/diff-tool/diff-tool.handler.d.ts +42 -0
- package/dist/diff-tool/index.d.ts +3 -0
- package/dist/docs-tool/docs-folder.repository.d.ts +24 -0
- package/dist/docs-tool/docs-root.client.d.ts +8 -0
- package/dist/docs-tool/docs-tool.handler.d.ts +21 -0
- package/dist/docs-tool/docs-topics.algorithm.d.ts +39 -0
- package/dist/docs-tool/index.d.ts +3 -0
- package/dist/index.d.ts +12 -1
- package/dist/index.esm.js +449 -6
- package/dist/list-tool/index.d.ts +3 -0
- package/dist/list-tool/list-recipes-tool.handler.d.ts +32 -0
- package/dist/main.d.ts +7 -0
- package/dist/probe-tool/index.d.ts +2 -0
- package/dist/probe-tool/probe-tool.handler.d.ts +27 -0
- package/dist/recipe-source/index.d.ts +3 -0
- package/dist/recipe-source/recipe-source.mapper.d.ts +21 -0
- package/dist/run-tool/index.d.ts +3 -0
- package/dist/run-tool/run-tool.handler.d.ts +51 -0
- package/dist/server/create-server.use-case.d.ts +11 -0
- package/dist/server/index.d.ts +2 -0
- package/dist/src/docs-tool/docs-folder.repository.d.ts +24 -0
- package/dist/src/docs-tool/docs-root.client.d.ts +8 -0
- package/dist/src/docs-tool/docs-tool.handler.d.ts +21 -0
- package/dist/src/docs-tool/docs-topics.algorithm.d.ts +39 -0
- package/dist/src/docs-tool/index.d.ts +3 -0
- package/dist/src/server/create-server.use-case.d.ts +1 -1
- package/dist/src/studio-tool/index.d.ts +2 -0
- package/dist/src/studio-tool/studio-command.client.d.ts +11 -0
- package/dist/src/studio-tool/studio-instance.repository.d.ts +22 -0
- package/dist/src/studio-tool/studio-tools.handler.d.ts +47 -0
- package/dist/studio-tool/index.d.ts +2 -0
- package/dist/studio-tool/studio-command.client.d.ts +11 -0
- package/dist/studio-tool/studio-instance.repository.d.ts +22 -0
- package/dist/studio-tool/studio-tools.handler.d.ts +47 -0
- package/dist/validate-tool/index.d.ts +3 -0
- package/dist/validate-tool/validate-tool.handler.d.ts +31 -0
- package/docs/how-it-works/01-recipes.md +698 -0
- package/docs/how-it-works/02-page-steps.md +672 -0
- package/docs/how-it-works/03-data-steps.md +813 -0
- package/docs/how-it-works/04-flow-steps.md +738 -0
- package/docs/how-it-works/05-templates-and-scope.md +428 -0
- package/docs/how-it-works/06-documents.md +1413 -0
- package/docs/how-it-works/07-mapping-and-transforms.md +699 -0
- package/docs/how-it-works/08-policies.md +405 -0
- package/docs/how-it-works/09-running.md +804 -0
- package/docs/how-it-works/README.md +225 -0
- package/docs/recipes/README.md +22 -0
- package/docs/recipes/access.md +440 -0
- package/docs/recipes/authoring.md +1503 -0
- package/docs/recipes/azure-durable.md +180 -0
- package/docs/recipes/captcha.md +204 -0
- package/docs/recipes/movies-example.md +12 -0
- package/docs/recipes/programmatic-authoring.md +101 -0
- package/docs/recipes/quick-guide.md +157 -0
- package/docs/recipes/vehicles-example.md +9 -0
- package/docs/recipes/worker-mode.md +221 -0
- package/docs/studio/manual.md +312 -0
- package/docs/studio/pdf-agreements.md +150 -0
- package/package.json +29 -4
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ directly: probe a page, validate recipes, run a crawl, list what's already autho
|
|
|
11
11
|
For a shared, remote endpoint that authors recipes where they will run (and publishes them to a crawl host), see
|
|
12
12
|
[`@opencraw/azure-durable`](https://github.com/Open-Craw/OpenCraw/blob/main/packages/azure-durable/README.md#write-recipes-over-mcp)'s `/mcp`.
|
|
13
13
|
|
|
14
|
-
This does **not** auto-author recipes from a sentence. The
|
|
14
|
+
This does **not** auto-author recipes from a sentence. The crawl tools are, `list_recipes` and `docs` aside, the same
|
|
15
15
|
primitives the `opencraw` cli gives a terminal; the calling agent still writes the JSON recipes, using `probe` and
|
|
16
16
|
`validate` to iterate, the same way this project's own example recipes were built by hand. An agent that
|
|
17
17
|
can write files passes their `paths`; one that can't (a chat-only host) passes the `recipes` inline.
|
|
@@ -116,6 +116,19 @@ call, for checking what already exists before writing a new recipe.
|
|
|
116
116
|
|
|
117
117
|
Returns `{ outputs: [{ path, id }], inputs: [{ path, id, output, mode }], others: string[] }`.
|
|
118
118
|
|
|
119
|
+
### `docs`
|
|
120
|
+
|
|
121
|
+
OpenCraw's own documentation, for an agent that has to write recipes right: the authoring guide (every step, selector, transform and policy), the
|
|
122
|
+
how-it-works chapters, the examples and the Studio manual. They ship inside the package.
|
|
123
|
+
|
|
124
|
+
| Input | Meaning |
|
|
125
|
+
|---|---|
|
|
126
|
+
| `topic?` | A document id (`recipes/authoring`, `how-it-works/06-documents`, `studio/manual`…). Leave out to list every document, with its title and size. |
|
|
127
|
+
| `section?` | A heading (or part of one) of that document: only that section comes back, subsections included. A long document answers with its outline until a section is asked for. |
|
|
128
|
+
|
|
129
|
+
Returns `{ topics, hint }` without a topic, `{ topic, text }` (or `{ topic, outline, note }` for a long document) with one, and `{ topic, section, text }`
|
|
130
|
+
with a section.
|
|
131
|
+
|
|
119
132
|
### `diff`
|
|
120
133
|
|
|
121
134
|
Compares two runs' JSON Lines files by record key: what was added, what was removed, and which fields changed,
|
|
@@ -131,6 +144,19 @@ Returns `{ added, removed, changed, unchanged, shrunk?, summary, changes }`: `su
|
|
|
131
144
|
reads, `changes` the first 200 changes (`removed`, `changed` with `fields: [{ field, before, after }]`, `added`),
|
|
132
145
|
and `shrunk` is set when the current run holds under half the records the previous one did.
|
|
133
146
|
|
|
147
|
+
### `studio_status`, `studio_open_recipe`, `studio_run_sample`
|
|
148
|
+
|
|
149
|
+
Drive the OpenCraw Studio the person has open, so they watch the recipe being built. A running Studio announces itself in `~/.opencraw/studio/<pid>-<port>.json`
|
|
150
|
+
(its address and its access token, readable by its owner only); these tools find it there, so nothing needs configuring. If several run, the newest is used.
|
|
151
|
+
|
|
152
|
+
| Tool | Input | Returns |
|
|
153
|
+
|---|---|---|
|
|
154
|
+
| `studio_status` | none | `{ running, url, folder?, pages, running? }`: whether Studio is up, the folder it has open, how many connections are listening (an open page holds a couple), the recipe being sampled. Without a Studio: `{ running: false, hint }`. |
|
|
155
|
+
| `studio_open_recipe` | `path` (a recipe file, a folder or a document), `workspace?` | `{ opened: true, pages }`, or `{ opened: false, hint }` when Studio runs but no page is open. The open page does it the way a Studio link does. |
|
|
156
|
+
| `studio_run_sample` | `recipeId`, `maxRecords?` (10), `waitSeconds?` (60) | `{ recipeId, state, result? }`: the counts, the first 20 records and rejections once finished. Studio must have the recipe's folder open (`studio_open_recipe` first). |
|
|
157
|
+
|
|
158
|
+
Picking a value on a page (`studio_pick`) is not here yet: it is still the person's click.
|
|
159
|
+
|
|
134
160
|
## Building
|
|
135
161
|
|
|
136
162
|
`nx build @opencraw/mcp`, `nx test @opencraw/mcp` (unit tests per tool), `nx run @opencraw/mcp:e2e`
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import type { RecordChange } from '@opencraw/core';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
/** Input schema for the `diff` tool. */
|
|
5
|
+
export declare const diffInputShape: {
|
|
6
|
+
previous: z.ZodString;
|
|
7
|
+
current: z.ZodString;
|
|
8
|
+
key: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
9
|
+
ignore: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
};
|
|
11
|
+
interface DiffArgs {
|
|
12
|
+
previous: string;
|
|
13
|
+
current: string;
|
|
14
|
+
key?: string[];
|
|
15
|
+
ignore?: string[];
|
|
16
|
+
}
|
|
17
|
+
/** What the `diff` tool returns. */
|
|
18
|
+
export interface DiffResult {
|
|
19
|
+
added: number;
|
|
20
|
+
removed: number;
|
|
21
|
+
changed: number;
|
|
22
|
+
unchanged: number;
|
|
23
|
+
/** Set when the current run lost most of the previous run's records. */
|
|
24
|
+
shrunk?: {
|
|
25
|
+
previous: number;
|
|
26
|
+
current: number;
|
|
27
|
+
};
|
|
28
|
+
/** The report a person reads, one line per change. */
|
|
29
|
+
summary: string[];
|
|
30
|
+
/** The changes, up to 200: removed, changed (with each field's before and after), added. */
|
|
31
|
+
changes: RecordChange[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The `diff` tool: compares two runs' records by key, so an agent watching a
|
|
35
|
+
* source can say what changed since last time instead of re-reading it all.
|
|
36
|
+
*
|
|
37
|
+
* @param args - The tool's parsed input.
|
|
38
|
+
* @returns The MCP tool result.
|
|
39
|
+
*/
|
|
40
|
+
export declare function diffTool(args: DiffArgs): Promise<CallToolResult>;
|
|
41
|
+
export {};
|
|
42
|
+
//# sourceMappingURL=diff-tool.handler.d.ts.map
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/** One document the server can show. */
|
|
2
|
+
export interface DocTopic {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** Its size in characters, so an agent knows to ask for a section of a long one. */
|
|
6
|
+
size: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* The documents under a docs folder: the Markdown files directly inside `recipes`, `how-it-works` and `studio` (their pictures and capture scripts are
|
|
10
|
+
* not documentation to read).
|
|
11
|
+
*
|
|
12
|
+
* @param root - The docs folder.
|
|
13
|
+
* @returns The topics, ordered by id.
|
|
14
|
+
*/
|
|
15
|
+
export declare function listTopics(root: string): Promise<DocTopic[]>;
|
|
16
|
+
/**
|
|
17
|
+
* One document's text.
|
|
18
|
+
*
|
|
19
|
+
* @param root - The docs folder.
|
|
20
|
+
* @param id - The topic id from `listTopics` (never a path: nothing outside the listed folders is read).
|
|
21
|
+
* @returns The Markdown, or `undefined` when there is no such topic.
|
|
22
|
+
*/
|
|
23
|
+
export declare function readTopic(root: string, id: string): Promise<string | undefined>;
|
|
24
|
+
//# sourceMappingURL=docs-folder.repository.d.ts.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Where the documentation is: a `docs` folder beside `dist` in the installed package (copied there at build), or the repository's own `docs` when the server runs
|
|
3
|
+
* from a checkout.
|
|
4
|
+
*
|
|
5
|
+
* @returns The docs folder.
|
|
6
|
+
*/
|
|
7
|
+
export declare function docsRoot(): string;
|
|
8
|
+
//# sourceMappingURL=docs-root.client.d.ts.map
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
/** Input schema for the `docs` tool. */
|
|
4
|
+
export declare const docsInputShape: {
|
|
5
|
+
topic: z.ZodOptional<z.ZodString>;
|
|
6
|
+
section: z.ZodOptional<z.ZodString>;
|
|
7
|
+
};
|
|
8
|
+
/**
|
|
9
|
+
* The `docs` tool: OpenCraw's own documentation, for an agent that has to write recipes right: the authoring guide (every step, selector, transform
|
|
10
|
+
* and policy), how it all works, the examples and the Studio manual. Without a topic it lists what there is; with one it gives the document, or just
|
|
11
|
+
* the section asked for, so a long guide costs only what is read.
|
|
12
|
+
*
|
|
13
|
+
* @param args - The tool's parsed input.
|
|
14
|
+
* @param root - The docs folder (the packaged copy, or the repository's).
|
|
15
|
+
* @returns The MCP tool result.
|
|
16
|
+
*/
|
|
17
|
+
export declare function docsTool(args: {
|
|
18
|
+
topic?: string;
|
|
19
|
+
section?: string;
|
|
20
|
+
}, root: string): Promise<CallToolResult>;
|
|
21
|
+
//# sourceMappingURL=docs-tool.handler.d.ts.map
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/** One heading of a document: how deep it is, its text and where its line is. */
|
|
2
|
+
export interface DocHeading {
|
|
3
|
+
level: number;
|
|
4
|
+
text: string;
|
|
5
|
+
line: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The topic id of a documentation file: its path under the docs folder, without the extension and with forward slashes, so `recipes/authoring.md` is
|
|
9
|
+
* `recipes/authoring`.
|
|
10
|
+
*
|
|
11
|
+
* @param relativePath - The file's path under the docs folder.
|
|
12
|
+
* @returns The id.
|
|
13
|
+
*/
|
|
14
|
+
export declare function topicIdOf(relativePath: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* The title of a document: its first top-level heading, else its id.
|
|
17
|
+
*
|
|
18
|
+
* @param markdown - The document.
|
|
19
|
+
* @param fallback - The id, when there is no heading.
|
|
20
|
+
* @returns The title.
|
|
21
|
+
*/
|
|
22
|
+
export declare function titleOf(markdown: string, fallback: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Every heading of a Markdown document, in order. A line inside a fenced code block is not a heading (a shell comment starts with `#` too).
|
|
25
|
+
*
|
|
26
|
+
* @param markdown - The document.
|
|
27
|
+
* @returns The headings.
|
|
28
|
+
*/
|
|
29
|
+
export declare function outlineOf(markdown: string): DocHeading[];
|
|
30
|
+
/**
|
|
31
|
+
* One section of a document: from the heading whose text contains `heading` (case-insensitive; an exact match wins over a partial one) to the next
|
|
32
|
+
* heading of the same or a higher level, so its subsections come with it.
|
|
33
|
+
*
|
|
34
|
+
* @param markdown - The document.
|
|
35
|
+
* @param heading - What the heading says, or part of it.
|
|
36
|
+
* @returns The section's text, or `undefined` when no heading matches.
|
|
37
|
+
*/
|
|
38
|
+
export declare function sectionOf(markdown: string, heading: string): string | undefined;
|
|
39
|
+
//# sourceMappingURL=docs-topics.algorithm.d.ts.map
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { main } from './main';
|
|
2
|
+
export { createServer } from './server';
|
|
3
|
+
export { probeTool, probeInputShape } from './probe-tool';
|
|
4
|
+
export { validateTool, validateInputShape } from './validate-tool';
|
|
5
|
+
export { diffTool, diffInputShape } from './diff-tool';
|
|
6
|
+
export type { DiffResult } from './diff-tool';
|
|
7
|
+
export type { ValidateResult } from './validate-tool';
|
|
8
|
+
export { runTool, runInputShape } from './run-tool';
|
|
9
|
+
export type { RunResult } from './run-tool';
|
|
10
|
+
export { listRecipesTool, listRecipesInputShape } from './list-tool';
|
|
11
|
+
export type { ListRecipesResult } from './list-tool';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|