blockflow-mcp 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +40 -2
- package/bridgeSession.mjs +163 -0
- package/format.mjs +132 -0
- package/index.d.mts +42 -0
- package/index.mjs +428 -0
- package/package.json +52 -4
- package/resources/README.md +800 -0
- package/resources/blocks.md +940 -0
- package/resources/llms.txt +25 -0
- package/resources/script.schema.json +3333 -0
- package/resources.mjs +67 -0
- package/scripts/pack.mjs +20 -0
- package/server.mjs +30 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 BlockFlow contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,41 @@
|
|
|
1
|
-
#
|
|
1
|
+
# blockflow-mcp
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
An [MCP](https://modelcontextprotocol.io) server for the [BlockFlow](https://github.com/akibh-dev/blockflow) browser extension. It lets an AI
|
|
4
|
+
assistant (Claude Code, Claude Desktop, any MCP client) look at pages, write BlockFlow workflows, validate them,
|
|
5
|
+
run them **in your own browser with your own logins**, read the failure and repair the workflow.
|
|
6
|
+
|
|
7
|
+
```text
|
|
8
|
+
MCP client ──stdio──▶ blockflow-mcp ──local socket──▶ blockflow-bridge ──native messaging──▶ BlockFlow extension
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
1. Install the BlockFlow extension and open its **Settings** page: switch on **Allow outside control** and copy the
|
|
14
|
+
extension id.
|
|
15
|
+
2. Install the native host once: `npx blockflow-bridge install --extension-id <id>` (add `--browser firefox` for
|
|
16
|
+
Firefox).
|
|
17
|
+
3. Add the server to your MCP client:
|
|
18
|
+
|
|
19
|
+
```json
|
|
20
|
+
{ "mcpServers": { "blockflow": { "command": "npx", "args": ["-y", "blockflow-mcp"] } } }
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Claude Code: `claude mcp add blockflow -- npx -y blockflow-mcp`.
|
|
24
|
+
|
|
25
|
+
## Tools
|
|
26
|
+
|
|
27
|
+
| Tool | What it does |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `snapshot_page` | Outline of a page (URL or open tab) with ready-to-use locators |
|
|
30
|
+
| `validate_workflow` | Checks a script or graph; issues come with a code, a JSON path and a hint |
|
|
31
|
+
| `run_workflow` | Runs an inline script or a saved workflow; returns status, the failing step, error code, locator, URL and a screenshot |
|
|
32
|
+
| `get_report` | JSON, JUnit or HTML report of runs |
|
|
33
|
+
| `import_workflow`, `list_workflows`, `stop_run`, `list_suites`, `run_suite` | Manage workflows and suites |
|
|
34
|
+
|
|
35
|
+
Resources: the usage guide, the block reference, the script JSON Schema and `llms.txt`. Prompt:
|
|
36
|
+
`write-and-repair-test` (snapshot → write → validate → run → repair).
|
|
37
|
+
|
|
38
|
+
Outside control is **off by default** and local only: nothing is reachable from the network. Every request is
|
|
39
|
+
listed on the extension's Settings page. Full documentation: [MCP Server wiki](https://github.com/akibh-dev/blockflow/wiki/MCP-Server).
|
|
40
|
+
|
|
41
|
+
License: MIT.
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// One lazily opened bridge connection shared by every tool call, with a single reconnect on a
|
|
2
|
+
// transport failure. The connector is injected (tests pass a fake); the default one loads
|
|
3
|
+
// `connectBridge` from blockflow-bridge/client on first use.
|
|
4
|
+
import { RPC_ERRORS } from 'blockflow-bridge/protocol';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* The interface of `connectBridge` from blockflow-bridge/client (tests implement it directly).
|
|
8
|
+
* `onNotification` gets the whole JSON-RPC notification `{jsonrpc, method, params}`.
|
|
9
|
+
* `closed` (optional) resolves when the connection ends; the session then reconnects on the next call.
|
|
10
|
+
* @typedef {{ onNotification?: (notification: { method: string, params: any }) => void, timeoutMs?: number }} CallOptions
|
|
11
|
+
* @typedef {{ call(method: string, params?: unknown, options?: CallOptions): Promise<any>, close(): void | Promise<void>, closed?: Promise<unknown> }} BridgeClient
|
|
12
|
+
* @typedef {() => Promise<BridgeClient>} BridgeConnector
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
/** Methods that are safe to send twice when the connection drops under them. */
|
|
16
|
+
const IDEMPOTENT = new Set(['hello', 'validate', 'list', 'report', 'blob.get', 'suite.list', 'stop', 'snapshot']);
|
|
17
|
+
|
|
18
|
+
const NOT_REACHABLE =
|
|
19
|
+
'BlockFlow is not reachable: is the browser open with Allow outside control on, and the bridge installed?';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* The default connector: `connectBridge` from `blockflow-bridge/client`, with the
|
|
23
|
+
* socket and token file from the environment (the client reads BLOCKFLOW_SOCKET / BLOCKFLOW_TOKEN_FILE).
|
|
24
|
+
* @param {{ socketPath?: string, tokenFile?: string, timeoutMs?: number }} [options]
|
|
25
|
+
* @returns {BridgeConnector}
|
|
26
|
+
*/
|
|
27
|
+
export function defaultConnector(options = {}) {
|
|
28
|
+
return async () => {
|
|
29
|
+
/** @type {any} */
|
|
30
|
+
let mod;
|
|
31
|
+
try {
|
|
32
|
+
mod = await import('blockflow-bridge/client');
|
|
33
|
+
} catch (error) {
|
|
34
|
+
const err = new Error(
|
|
35
|
+
`The blockflow-bridge client could not be loaded (${/** @type {Error} */ (error).message}). Reinstall blockflow-mcp.`,
|
|
36
|
+
);
|
|
37
|
+
throw err;
|
|
38
|
+
}
|
|
39
|
+
return mod.connectBridge({ client: 'blockflow-mcp', ...options });
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* @param {BridgeConnector} connect
|
|
45
|
+
*/
|
|
46
|
+
export function createBridgeSession(connect) {
|
|
47
|
+
/** @type {BridgeClient | null} */
|
|
48
|
+
let client = null;
|
|
49
|
+
/** Set when the current client's `closed` promise settles. */
|
|
50
|
+
let clientClosed = false;
|
|
51
|
+
/** @type {Promise<BridgeClient> | null} */
|
|
52
|
+
let pending = null;
|
|
53
|
+
|
|
54
|
+
async function get() {
|
|
55
|
+
if (client && !clientClosed) return client;
|
|
56
|
+
client = null;
|
|
57
|
+
pending ??= (async () => {
|
|
58
|
+
try {
|
|
59
|
+
const opened = await connect();
|
|
60
|
+
client = opened;
|
|
61
|
+
clientClosed = false;
|
|
62
|
+
Promise.resolve(opened.closed).then(
|
|
63
|
+
() => {
|
|
64
|
+
if (opened.closed && client === opened) clientClosed = true;
|
|
65
|
+
},
|
|
66
|
+
() => {},
|
|
67
|
+
);
|
|
68
|
+
return opened;
|
|
69
|
+
} finally {
|
|
70
|
+
pending = null;
|
|
71
|
+
}
|
|
72
|
+
})();
|
|
73
|
+
return pending;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function drop() {
|
|
77
|
+
const old = client;
|
|
78
|
+
client = null;
|
|
79
|
+
if (old) {
|
|
80
|
+
try {
|
|
81
|
+
void Promise.resolve(old.close()).catch(() => {});
|
|
82
|
+
} catch {
|
|
83
|
+
// already closed
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param {string} method
|
|
90
|
+
* @param {unknown} [params]
|
|
91
|
+
* @param {CallOptions} [options]
|
|
92
|
+
*/
|
|
93
|
+
async function call(method, params = {}, options = {}) {
|
|
94
|
+
let first;
|
|
95
|
+
try {
|
|
96
|
+
first = await get();
|
|
97
|
+
} catch {
|
|
98
|
+
// Connecting failed: try once more (the host may have just restarted).
|
|
99
|
+
first = await get();
|
|
100
|
+
}
|
|
101
|
+
try {
|
|
102
|
+
return await first.call(method, params, options);
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (!(await connectionLost(first, error))) throw error;
|
|
105
|
+
drop();
|
|
106
|
+
if (!IDEMPOTENT.has(method)) {
|
|
107
|
+
const err = /** @type {any} */ (
|
|
108
|
+
new Error(
|
|
109
|
+
`${/** @type {Error} */ (error)?.message ?? error} The connection dropped during ${method}, so it was not retried ` +
|
|
110
|
+
'(it changes state; a run may still be going in the browser). Call the tool again.',
|
|
111
|
+
)
|
|
112
|
+
);
|
|
113
|
+
err.code = /** @type {any} */ (error)?.code;
|
|
114
|
+
throw err;
|
|
115
|
+
}
|
|
116
|
+
const second = await get();
|
|
117
|
+
return second.call(method, params, options);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** True when `error` means the connection is gone (not an answer from the host or extension). */
|
|
122
|
+
async function connectionLost(used, error) {
|
|
123
|
+
const code = /** @type {any} */ (error)?.code;
|
|
124
|
+
if (typeof code !== 'number') return true;
|
|
125
|
+
if (code !== RPC_ERRORS.notConnected) return false;
|
|
126
|
+
// notConnected is also the host's answer "the extension is not connected"; only a closed socket counts.
|
|
127
|
+
await new Promise((done) => setImmediate(done));
|
|
128
|
+
return used !== client || clientClosed;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return {
|
|
132
|
+
call,
|
|
133
|
+
async close() {
|
|
134
|
+
const old = client;
|
|
135
|
+
client = null;
|
|
136
|
+
if (old) await old.close();
|
|
137
|
+
},
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const HINTS = {
|
|
142
|
+
[RPC_ERRORS.disabled]:
|
|
143
|
+
'In BlockFlow open Settings and switch on "Allow outside control" (it is off by default).',
|
|
144
|
+
[RPC_ERRORS.notConnected]:
|
|
145
|
+
'The bridge is running but the extension is not connected to it: open the browser with BlockFlow and switch on "Allow outside control" in Settings.',
|
|
146
|
+
[RPC_ERRORS.unauthorized]:
|
|
147
|
+
'The bridge token did not match. Restart the browser (the native host rewrites the token), or check BLOCKFLOW_TOKEN_FILE.',
|
|
148
|
+
[RPC_ERRORS.version]: 'blockflow-mcp and the BlockFlow extension speak different protocol versions: update both.',
|
|
149
|
+
[RPC_ERRORS.tooLarge]: 'The message is over 1 MB. Send a smaller workflow, or save it first and run it by id.',
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/** A readable one-paragraph message for any error from the bridge or the client. */
|
|
153
|
+
export function describeError(error) {
|
|
154
|
+
const e = /** @type {any} */ (error);
|
|
155
|
+
let message = typeof e?.message === 'string' && e.message ? e.message : String(error);
|
|
156
|
+
if (/ENOENT|ECONNREFUSED|ENOTSOCK|EACCES/.test(message) && !message.includes('not reachable')) {
|
|
157
|
+
message = `${NOT_REACHABLE} (${message})`;
|
|
158
|
+
}
|
|
159
|
+
let hint = typeof e?.code === 'number' ? HINTS[e.code] : undefined;
|
|
160
|
+
// The client reports a missing socket or a closed connection as notConnected too; its message says enough.
|
|
161
|
+
if (e?.code === RPC_ERRORS.notConnected && /not reachable|closed the connection/.test(message)) hint = undefined;
|
|
162
|
+
return hint && !message.includes(hint) ? `${message}\n${hint}` : message;
|
|
163
|
+
}
|
package/format.mjs
ADDED
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Text an LLM reads back from the tools: issues in the guide's repair format, compact run summaries.
|
|
2
|
+
|
|
3
|
+
/** `<level> <code> at <path>: <message> <hint>`, the format of the guide's Repair section. */
|
|
4
|
+
export function formatIssue(issue) {
|
|
5
|
+
const hint = issue.hint ? ` ${issue.hint}` : '';
|
|
6
|
+
return `${issue.level} ${issue.code} at ${issue.path || '/'}: ${issue.message}${hint}`;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function formatIssues(issues) {
|
|
10
|
+
if (!issues?.length) return 'No issues.';
|
|
11
|
+
const errors = issues.filter((issue) => issue.level === 'error').length;
|
|
12
|
+
const warnings = issues.filter((issue) => issue.level === 'warning').length;
|
|
13
|
+
return [`${errors} error(s), ${warnings} warning(s), ${issues.length - errors - warnings} note(s):`, ...issues.map((issue) => `- ${formatIssue(issue)}`)].join('\n');
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function formatDuration(ms) {
|
|
17
|
+
if (typeof ms !== 'number' || !Number.isFinite(ms)) return '?';
|
|
18
|
+
return ms < 1000 ? `${Math.round(ms)} ms` : `${(ms / 1000).toFixed(1)} s`;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Duration of a run from its ISO times, or undefined while it has no end. */
|
|
22
|
+
export function runDuration(run) {
|
|
23
|
+
if (!run?.startedAt || !run?.endedAt) return undefined;
|
|
24
|
+
const ms = Date.parse(run.endedAt) - Date.parse(run.startedAt);
|
|
25
|
+
return Number.isFinite(ms) ? ms : undefined;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The step id an author recognises: the id in the imported file when there was one. */
|
|
29
|
+
export function stepId(step) {
|
|
30
|
+
return step.sourceId ?? step.nodeId;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** The step that made the run fail: the last `failed` step (handled failures do not stop a run). */
|
|
34
|
+
export function failingStep(run) {
|
|
35
|
+
const steps = run?.steps ?? [];
|
|
36
|
+
for (let i = steps.length - 1; i >= 0; i -= 1) if (steps[i].status === 'failed') return steps[i];
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
const MARK = { passed: 'ok', failed: 'FAILED', handled: 'handled', skipped: 'skipped', running: 'running' };
|
|
41
|
+
|
|
42
|
+
function truncate(text, max) {
|
|
43
|
+
return text.length > max ? `${text.slice(0, max)}…` : text;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Structured summary of a run (also the tool's structuredContent). */
|
|
47
|
+
export function summarizeRun(run) {
|
|
48
|
+
const failing = failingStep(run);
|
|
49
|
+
return {
|
|
50
|
+
status: run.status,
|
|
51
|
+
runId: run.id,
|
|
52
|
+
workflowId: run.workflowId,
|
|
53
|
+
workflowName: run.workflowName,
|
|
54
|
+
durationMs: runDuration(run),
|
|
55
|
+
error: run.error,
|
|
56
|
+
failingStep: failing
|
|
57
|
+
? {
|
|
58
|
+
id: stepId(failing),
|
|
59
|
+
nodeId: failing.nodeId,
|
|
60
|
+
blockType: failing.blockType,
|
|
61
|
+
code: failing.code,
|
|
62
|
+
message: failing.error,
|
|
63
|
+
locator: failing.locator,
|
|
64
|
+
url: failing.url,
|
|
65
|
+
matches: failing.matches,
|
|
66
|
+
screenshot: failing.screenshot,
|
|
67
|
+
console: failing.console,
|
|
68
|
+
}
|
|
69
|
+
: undefined,
|
|
70
|
+
steps: (run.steps ?? []).map((step) => ({
|
|
71
|
+
id: stepId(step),
|
|
72
|
+
blockType: step.blockType,
|
|
73
|
+
status: step.status,
|
|
74
|
+
durationMs: step.durationMs,
|
|
75
|
+
attempts: step.attempts,
|
|
76
|
+
code: step.code,
|
|
77
|
+
error: step.error,
|
|
78
|
+
output: step.output,
|
|
79
|
+
})),
|
|
80
|
+
droppedSteps: run.droppedSteps,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** The compact text an LLM reads first: verdict, then what failed and where, then the step list. */
|
|
85
|
+
export function formatRunText(run) {
|
|
86
|
+
const summary = summarizeRun(run);
|
|
87
|
+
const lines = [
|
|
88
|
+
`Run ${String(run.status).toUpperCase()} in ${formatDuration(summary.durationMs)}: "${run.workflowName}" (run ${run.id}, workflow ${run.workflowId})`,
|
|
89
|
+
];
|
|
90
|
+
const failing = summary.failingStep;
|
|
91
|
+
if (failing) {
|
|
92
|
+
lines.push(`Failing step: ${failing.id} (${failing.blockType})`);
|
|
93
|
+
if (failing.code) lines.push(`Error code: ${failing.code}`);
|
|
94
|
+
if (failing.message) lines.push(`Message: ${failing.message}`);
|
|
95
|
+
if (failing.locator) lines.push(`Locator: ${failing.locator}`);
|
|
96
|
+
if (failing.url) lines.push(`Page URL: ${failing.url}`);
|
|
97
|
+
if (failing.matches?.length) lines.push(`Matches: ${failing.matches.join(' | ')}`);
|
|
98
|
+
const consoleLines = (failing.console ?? []).slice(-5).map((entry) => `${entry.level}: ${truncate(String(entry.text ?? ''), 200)}`);
|
|
99
|
+
if (consoleLines.length) lines.push(`Console: ${consoleLines.join(' | ')}`);
|
|
100
|
+
} else if (run.status !== 'passed' && run.error) {
|
|
101
|
+
lines.push(`Error: ${run.error}`);
|
|
102
|
+
}
|
|
103
|
+
lines.push('Steps:');
|
|
104
|
+
for (const step of run.steps ?? []) {
|
|
105
|
+
const detail = step.status === 'failed' || step.status === 'handled' ? ` ${step.code ?? ''} ${truncate(step.error ?? '', 160)}`.trimEnd() : '';
|
|
106
|
+
lines.push(`- ${stepId(step)} ${step.blockType} ${MARK[step.status] ?? step.status} ${formatDuration(step.durationMs)}${detail}`);
|
|
107
|
+
}
|
|
108
|
+
if (run.droppedSteps) lines.push(`(${run.droppedSteps} more steps not kept)`);
|
|
109
|
+
if (run.status !== 'passed') {
|
|
110
|
+
lines.push(
|
|
111
|
+
failing
|
|
112
|
+
? `Next: look up ${failing.code ?? 'the error'} in the guide's error-code table (resource blockflow://guide), fix step "${failing.id}" (snapshot_page for fresh locators), validate_workflow, then run_workflow again.`
|
|
113
|
+
: 'Next: read the error, fix the workflow, validate_workflow, then run_workflow again.',
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
return lines.join('\n');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Text for a finished suite: verdict, one line per workflow, skipped ones. */
|
|
120
|
+
export function formatSuiteText(result) {
|
|
121
|
+
const passed = result.runs.filter((run) => run.status === 'passed').length;
|
|
122
|
+
const ms = Date.parse(result.finishedAt) - Date.parse(result.startedAt);
|
|
123
|
+
const lines = [`Suite ${String(result.status).toUpperCase()} in ${formatDuration(ms)}: "${result.name}", ${passed}/${result.runs.length} workflow(s) passed`];
|
|
124
|
+
for (const run of result.runs) {
|
|
125
|
+
const failing = failingStep(run);
|
|
126
|
+
const detail = failing ? ` at ${stepId(failing)} (${failing.blockType}) ${failing.code ?? ''}: ${truncate(failing.error ?? '', 200)}` : run.status !== 'passed' && run.error ? `: ${run.error}` : '';
|
|
127
|
+
lines.push(`- ${run.workflowName} ${String(run.status).toUpperCase()} ${formatDuration(runDuration(run))} (run ${run.id})${detail}`);
|
|
128
|
+
}
|
|
129
|
+
if (result.skipped?.length) lines.push(`Skipped (stopOnFailure): ${result.skipped.join(', ')}`);
|
|
130
|
+
if (result.status !== 'passed') lines.push('Use get_report with a runId, or run_workflow on the failing workflow, to see its full steps.');
|
|
131
|
+
return lines.join('\n');
|
|
132
|
+
}
|
package/index.d.mts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Types for index.mjs (the package is plain ESM; these are for TypeScript users and the repo's tests).
|
|
2
|
+
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
3
|
+
|
|
4
|
+
export interface BridgeCallOptions {
|
|
5
|
+
/** Receives each `run.*` / `suite.progress` notification for this call: `{ jsonrpc, method, params }`. */
|
|
6
|
+
onNotification?: (notification: { jsonrpc?: '2.0'; method: string; params: any }) => void;
|
|
7
|
+
/** 0 = no limit. */
|
|
8
|
+
timeoutMs?: number;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/** What `connectBridge` from blockflow-bridge/client returns; a fake implements it in tests. */
|
|
12
|
+
export interface BridgeClient {
|
|
13
|
+
call(method: string, params?: unknown, options?: BridgeCallOptions): Promise<any>;
|
|
14
|
+
close(): void | Promise<void>;
|
|
15
|
+
/** Resolves when the connection ends. */
|
|
16
|
+
closed?: Promise<unknown>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface BridgeSession {
|
|
20
|
+
call(method: string, params?: unknown, options?: BridgeCallOptions): Promise<any>;
|
|
21
|
+
close(): Promise<void>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface BlockflowServerOptions {
|
|
25
|
+
/** Opens a bridge connection (default: `connectBridge` from blockflow-bridge/client). Called lazily, again after a drop. */
|
|
26
|
+
connect?: () => Promise<BridgeClient>;
|
|
27
|
+
/** Where resources are looked up: `<packageDir>/resources/*` first, then the repo's docs. */
|
|
28
|
+
resourceDirs?: { packageDir: string; repoDir: string };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createBlockflowServer(options?: BlockflowServerOptions): {
|
|
32
|
+
server: McpServer;
|
|
33
|
+
session: BridgeSession;
|
|
34
|
+
close(): Promise<void>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export function fetchBlob(session: Pick<BridgeSession, 'call'>, blobId: string): Promise<{ bytes: Buffer; mime?: string }>;
|
|
38
|
+
export function repairPrompt(url: string, goal: string): string;
|
|
39
|
+
export const INSTRUCTIONS: string;
|
|
40
|
+
export const VERSION: string;
|
|
41
|
+
/** The real connector: `connectBridge` from blockflow-bridge/client with these options (socket/token default from the environment). */
|
|
42
|
+
export function defaultConnector(options?: { socketPath?: string; tokenFile?: string; timeoutMs?: number }): () => Promise<BridgeClient>;
|