@rebilder/mcp-server 0.4.0 → 0.5.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/CHANGELOG.md +5 -0
- package/README.md +19 -15
- package/dist/bin.js +2868 -273
- package/dist/bin.js.map +1 -1
- package/dist/index.d.ts +197 -33
- package/dist/index.js +2927 -336
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ProbeOutcome } from '@rebilder/agent-readability/probe';
|
|
2
|
-
import { ArsVantage, ArsResult } from '@rebilder/agent-readability';
|
|
2
|
+
import { ArsVantage, ArsEvidence, ArsResult } from '@rebilder/agent-readability';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* json.ts — the JSON value type everything on the wire is expressed in, and the
|
|
@@ -95,35 +95,32 @@ declare function decodeFrame(value: JsonValue): DecodedFrame;
|
|
|
95
95
|
declare function decodeLine(line: string): DecodedFrame;
|
|
96
96
|
|
|
97
97
|
/**
|
|
98
|
-
* index-client.ts — the
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
112
|
-
*
|
|
113
|
-
* WHY THE DOMAIN IS VALIDATED BEFORE THE URL IS BUILT. The path segment comes
|
|
114
|
-
* from a tool argument, which in a prompt-injection scenario comes from a web
|
|
115
|
-
* page. Encoding is not enough on its own: a strict syntactic gate keeps
|
|
116
|
-
* "../../something", a URL, an IP literal or a 4 KB blob from ever becoming a
|
|
117
|
-
* request, and it is exactly the same check the badge endpoint runs before its
|
|
118
|
-
* DB read.
|
|
98
|
+
* index-client.ts — the Rebilder API client, and the only file in `src/` allowed
|
|
99
|
+
* to reference `fetch` (see `eslint.config.mjs`).
|
|
100
|
+
*
|
|
101
|
+
* By default (no `REBILDER_API_KEY` set), the only call this module makes to
|
|
102
|
+
* Rebilder is a READ of our public index: `GET /api/public/index/<domain>`.
|
|
103
|
+
* It sends no scan, no URL the user asked about, no page content, no hostname
|
|
104
|
+
* other than the domain the caller explicitly asked to look up, and no
|
|
105
|
+
* identifier of any kind — and it NEVER attaches `Authorization` even when an
|
|
106
|
+
* API key is configured.
|
|
107
|
+
*
|
|
108
|
+
* When `REBILDER_API_KEY` is explicitly configured, `listSiteFixes` and
|
|
109
|
+
* `verifyFix` send Bearer-authenticated requests to `/v1/site-fixes` and
|
|
110
|
+
* `/v1/site-fixes/verify` on `REBILDER_API_URL`. When `REBILDER_API_KEY` is
|
|
111
|
+
* unset, both methods return `{ kind: 'unauthenticated' }` without touching
|
|
112
|
+
* the network.
|
|
119
113
|
*/
|
|
120
114
|
|
|
121
115
|
declare const DEFAULT_INDEX_BASE_URL = "https://rebilder.com";
|
|
122
116
|
declare const INDEX_BASE_URL_ENV = "REBILDER_API_URL";
|
|
117
|
+
declare const API_KEY_ENV = "REBILDER_API_KEY";
|
|
118
|
+
declare const DEFAULT_VERIFY_TIMEOUT_MS = 15000;
|
|
123
119
|
/** Structural: the subset of `fetch` used here, so tests need no globals. */
|
|
124
120
|
type FetchLike = (url: string, init: {
|
|
125
|
-
method: 'GET';
|
|
121
|
+
method: 'GET' | 'POST';
|
|
126
122
|
headers: Record<string, string>;
|
|
123
|
+
body?: string;
|
|
127
124
|
signal: AbortSignal;
|
|
128
125
|
redirect: 'error';
|
|
129
126
|
}) => Promise<{
|
|
@@ -142,9 +139,85 @@ type IndexLookup = {
|
|
|
142
139
|
url: string;
|
|
143
140
|
detail: string;
|
|
144
141
|
};
|
|
142
|
+
interface ListSiteFixesParams {
|
|
143
|
+
readonly limit?: number;
|
|
144
|
+
readonly band?: string;
|
|
145
|
+
readonly platform?: string;
|
|
146
|
+
}
|
|
147
|
+
interface SiteFixItem {
|
|
148
|
+
readonly fixId: string;
|
|
149
|
+
readonly rank: number;
|
|
150
|
+
readonly band: string;
|
|
151
|
+
readonly title: string;
|
|
152
|
+
readonly summary: string;
|
|
153
|
+
readonly tierRequired: string;
|
|
154
|
+
readonly status: string;
|
|
155
|
+
readonly targetUrl: string | null;
|
|
156
|
+
readonly prompt: string | null;
|
|
157
|
+
readonly acceptanceCriteria: readonly string[];
|
|
158
|
+
readonly basis: string;
|
|
159
|
+
}
|
|
160
|
+
interface SiteFixesResponse {
|
|
161
|
+
readonly storeId: string;
|
|
162
|
+
readonly domain: string;
|
|
163
|
+
readonly plan: string;
|
|
164
|
+
readonly totalCount: number;
|
|
165
|
+
readonly fixes: readonly SiteFixItem[];
|
|
166
|
+
}
|
|
167
|
+
type ApiFailureCode = 'unauthorized' | 'forbidden' | 'not-found' | 'bad-request' | 'client-error' | 'server-error' | 'network-error' | 'invalid-response';
|
|
168
|
+
type SiteFixesResult = {
|
|
169
|
+
readonly kind: 'ok';
|
|
170
|
+
readonly url: string;
|
|
171
|
+
readonly data: SiteFixesResponse;
|
|
172
|
+
} | {
|
|
173
|
+
readonly kind: 'unauthenticated';
|
|
174
|
+
} | {
|
|
175
|
+
readonly kind: 'failed';
|
|
176
|
+
readonly url: string;
|
|
177
|
+
readonly status: number | null;
|
|
178
|
+
readonly code: ApiFailureCode;
|
|
179
|
+
readonly detail: string;
|
|
180
|
+
};
|
|
181
|
+
interface VerifyFixParams {
|
|
182
|
+
readonly fixId: string;
|
|
183
|
+
readonly url?: string;
|
|
184
|
+
}
|
|
185
|
+
interface VerifyFixCheck {
|
|
186
|
+
readonly name: string;
|
|
187
|
+
readonly passed: boolean;
|
|
188
|
+
readonly detail: string;
|
|
189
|
+
}
|
|
190
|
+
interface VerifyFixIndexNow {
|
|
191
|
+
readonly status: string;
|
|
192
|
+
readonly submittedCount: number;
|
|
193
|
+
}
|
|
194
|
+
interface VerifyFixResponse {
|
|
195
|
+
readonly fixId: string;
|
|
196
|
+
readonly url: string;
|
|
197
|
+
readonly verified: boolean;
|
|
198
|
+
readonly checkedAt: string;
|
|
199
|
+
readonly checks: readonly VerifyFixCheck[];
|
|
200
|
+
readonly indexNow?: VerifyFixIndexNow;
|
|
201
|
+
}
|
|
202
|
+
type VerifyFixResult = {
|
|
203
|
+
readonly kind: 'ok';
|
|
204
|
+
readonly url: string;
|
|
205
|
+
readonly data: VerifyFixResponse;
|
|
206
|
+
} | {
|
|
207
|
+
readonly kind: 'unauthenticated';
|
|
208
|
+
} | {
|
|
209
|
+
readonly kind: 'failed';
|
|
210
|
+
readonly url: string;
|
|
211
|
+
readonly status: number | null;
|
|
212
|
+
readonly code: ApiFailureCode;
|
|
213
|
+
readonly detail: string;
|
|
214
|
+
};
|
|
145
215
|
interface IndexClient {
|
|
146
216
|
readonly baseUrl: string;
|
|
217
|
+
readonly hasApiKey: boolean;
|
|
147
218
|
lookup(domain: string): Promise<IndexLookup>;
|
|
219
|
+
listSiteFixes(params?: ListSiteFixesParams): Promise<SiteFixesResult>;
|
|
220
|
+
verifyFix(params: VerifyFixParams): Promise<VerifyFixResult>;
|
|
148
221
|
}
|
|
149
222
|
/**
|
|
150
223
|
* A registrable domain and nothing else: labels of 1–63 chars from
|
|
@@ -162,10 +235,15 @@ declare function normalizeDomain(value: string): string;
|
|
|
162
235
|
* back to production rather than being honoured quietly.
|
|
163
236
|
*/
|
|
164
237
|
declare function resolveIndexBaseUrl(raw: string | undefined): string;
|
|
238
|
+
declare function resolveApiKey(raw: string | undefined): string | undefined;
|
|
165
239
|
declare function indexEntryUrl(baseUrl: string, domain: string): string;
|
|
240
|
+
declare function siteFixesUrl(baseUrl: string, params?: ListSiteFixesParams): string;
|
|
241
|
+
declare function verifyFixUrl(baseUrl: string): string;
|
|
166
242
|
interface IndexClientOptions {
|
|
167
243
|
readonly baseUrl?: string;
|
|
244
|
+
readonly apiKey?: string;
|
|
168
245
|
readonly timeoutMs?: number;
|
|
246
|
+
readonly verifyTimeoutMs?: number;
|
|
169
247
|
/** Injected in tests. Defaults to the platform `fetch`. */
|
|
170
248
|
readonly fetchImpl?: FetchLike;
|
|
171
249
|
}
|
|
@@ -283,12 +361,15 @@ declare function createServer(options: McpServerOptions): McpServer;
|
|
|
283
361
|
* and a fake index client and no globals. This file is the seam, and `bin.ts`
|
|
284
362
|
* is its only caller in production.
|
|
285
363
|
*
|
|
286
|
-
*
|
|
364
|
+
* THREE ENVIRONMENT VARIABLES, ALL READ ONCE AT STARTUP:
|
|
287
365
|
* - `REBILDER_MCP_PROBE_BUDGET` — the politeness soft cap. An env var and not a
|
|
288
366
|
* tool argument on purpose: the person who launched the process gets to raise
|
|
289
367
|
* it, a model reading a web page does not (design §5.2).
|
|
290
|
-
* - `REBILDER_API_URL` — the
|
|
291
|
-
*
|
|
368
|
+
* - `REBILDER_API_URL` — the Rebilder API base, for staging. Validated to
|
|
369
|
+
* https with no credentials, query, or fragment, and ignored otherwise.
|
|
370
|
+
* - `REBILDER_API_KEY` — optional store API key for authenticated fix-loop
|
|
371
|
+
* tools (`list_site_fixes`, `verify_fix`). When unset, local tools and
|
|
372
|
+
* `get_index_entry` remain credential-free.
|
|
292
373
|
*
|
|
293
374
|
* There is no environment variable that allows private hosts, plaintext http,
|
|
294
375
|
* a bigger body cap, or skipping robots.txt. That is not an oversight.
|
|
@@ -470,7 +551,7 @@ declare function untrustedNonce(source: string, text: string, attempt?: number):
|
|
|
470
551
|
declare function wrapUntrusted(block: UntrustedBlock): string;
|
|
471
552
|
|
|
472
553
|
/**
|
|
473
|
-
* schema.ts — the declared input and output schemas for the
|
|
554
|
+
* schema.ts — the declared input and output schemas for the eight tools.
|
|
474
555
|
*
|
|
475
556
|
* `outputSchema` is not decoration. A client that knows the shape of a result
|
|
476
557
|
* can render it, diff it, and validate it; a model that gets `structuredContent`
|
|
@@ -493,6 +574,12 @@ declare function wrapUntrusted(block: UntrustedBlock): string;
|
|
|
493
574
|
|
|
494
575
|
type JsonSchema = JsonObject;
|
|
495
576
|
declare const ARS_RESULT_SCHEMA: JsonSchema;
|
|
577
|
+
declare const CHECK_DOCS_INPUT: JsonSchema;
|
|
578
|
+
declare const LIST_SITE_FIXES_INPUT: JsonSchema;
|
|
579
|
+
declare const VERIFY_FIX_INPUT: JsonSchema;
|
|
580
|
+
declare const CHECK_DOCS_OUTPUT: JsonSchema;
|
|
581
|
+
declare const LIST_SITE_FIXES_OUTPUT: JsonSchema;
|
|
582
|
+
declare const VERIFY_FIX_OUTPUT: JsonSchema;
|
|
496
583
|
|
|
497
584
|
/**
|
|
498
585
|
* tools/types.ts — what a tool is, and the argument helpers every tool shares.
|
|
@@ -538,10 +625,87 @@ interface Tool {
|
|
|
538
625
|
}
|
|
539
626
|
|
|
540
627
|
/**
|
|
541
|
-
* tools/
|
|
542
|
-
*
|
|
543
|
-
*
|
|
544
|
-
*
|
|
628
|
+
* tools/check-docs.ts — "can a coding agent follow this docs page without getting stuck?"
|
|
629
|
+
*
|
|
630
|
+
* Uses `deps.scanner.scan(url, vantage)` — which routes exclusively through
|
|
631
|
+
* `probeStrict` with the mandatory politeness limiter and never imports
|
|
632
|
+
* `./probe/local`. Everything runs locally on the user's machine with zero
|
|
633
|
+
* telemetry: nothing is uploaded to Rebilder, no packages are installed, and
|
|
634
|
+
* no code is executed.
|
|
635
|
+
*
|
|
636
|
+
* Every byte derived from the fetched documentation page is returned with
|
|
637
|
+
* `origin: 'target'`, so `result.ts` automatically wraps the text summary in
|
|
638
|
+
* the content-nonce untrusted-content quarantine.
|
|
639
|
+
*/
|
|
640
|
+
|
|
641
|
+
type DocsFindingSeverity = 'blocking' | 'should-fix' | 'passed';
|
|
642
|
+
type DocsFindingCheck = 'fetch' | 'install' | 'code' | 'auth' | 'freshness';
|
|
643
|
+
interface DocsFinding {
|
|
644
|
+
readonly id: string;
|
|
645
|
+
readonly check: DocsFindingCheck;
|
|
646
|
+
readonly severity: DocsFindingSeverity;
|
|
647
|
+
readonly title: string;
|
|
648
|
+
readonly detail: string;
|
|
649
|
+
readonly evidence: readonly string[];
|
|
650
|
+
readonly fix: string | null;
|
|
651
|
+
}
|
|
652
|
+
interface DocsRetrievalSummary {
|
|
653
|
+
readonly browserStatus: number | null;
|
|
654
|
+
readonly agentStatus: number | null;
|
|
655
|
+
readonly agentContentType: string | null;
|
|
656
|
+
readonly markdown: 'negotiated' | 'alternate' | 'none';
|
|
657
|
+
readonly markdownUrl: string | null;
|
|
658
|
+
readonly serverHtmlCodeBlocks: number;
|
|
659
|
+
readonly llmsTxt: 'links-page' | 'links-section' | 'no-link' | 'missing' | 'unavailable';
|
|
660
|
+
}
|
|
661
|
+
interface DocsCheckReport {
|
|
662
|
+
readonly url: string;
|
|
663
|
+
readonly finalUrl: string;
|
|
664
|
+
readonly checkedAt: string;
|
|
665
|
+
readonly verdict: 'can-follow' | 'likely-stuck';
|
|
666
|
+
readonly stuckAt: readonly string[];
|
|
667
|
+
readonly analyzedSource: 'markdown' | 'html';
|
|
668
|
+
readonly 'fetch': DocsRetrievalSummary;
|
|
669
|
+
readonly installManagers: readonly string[];
|
|
670
|
+
readonly blocking: readonly DocsFinding[];
|
|
671
|
+
readonly shouldFix: readonly DocsFinding[];
|
|
672
|
+
readonly passed: readonly DocsFinding[];
|
|
673
|
+
readonly findings: readonly DocsFinding[];
|
|
674
|
+
readonly scope: string;
|
|
675
|
+
readonly untrustedContentNotice: string;
|
|
676
|
+
}
|
|
677
|
+
declare function analyzeDocsEvidence(evidence: ArsEvidence, checkedAt: Date): DocsCheckReport;
|
|
678
|
+
|
|
679
|
+
/**
|
|
680
|
+
* tools/list-site-fixes.ts — fetch the merchant's ranked `/console/fix` queue.
|
|
681
|
+
*
|
|
682
|
+
* Opt-in and authenticated via `REBILDER_API_KEY`. When `REBILDER_API_KEY` is
|
|
683
|
+
* unset, this tool fails locally with actionable setup guidance without making
|
|
684
|
+
* any network call, preserving zero-credential local operation for all other
|
|
685
|
+
* tools.
|
|
686
|
+
*
|
|
687
|
+
* Results cross a network boundary and include fields derived from observed
|
|
688
|
+
* site crawls and prompts, so every response (and API failure) routes through
|
|
689
|
+
* `origin: 'target'` untrusted-content quarantine.
|
|
690
|
+
*/
|
|
691
|
+
|
|
692
|
+
declare const listSiteFixesTool: Tool;
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* tools/verify-fix.ts — trigger independent live URL re-verification for a fix.
|
|
696
|
+
*
|
|
697
|
+
* Opt-in and authenticated via `REBILDER_API_KEY`. Validates `fixId` and any
|
|
698
|
+
* optional `url` syntactically before checking credentials or making a network
|
|
699
|
+
* request. Live-fetched check details come from the target origin and are
|
|
700
|
+
* quarantined with `origin: 'target'`.
|
|
701
|
+
*/
|
|
702
|
+
|
|
703
|
+
declare const verifyFixTool: Tool;
|
|
704
|
+
|
|
705
|
+
/**
|
|
706
|
+
* tools/index.ts — the registry. Eight tools, declaration order is `tools/list`
|
|
707
|
+
* order: local scan, compare, docs, explain, public index lookup, install
|
|
708
|
+
* snippet, and opt-in authenticated fix queue + live verification.
|
|
545
709
|
*/
|
|
546
710
|
|
|
547
711
|
declare const TOOLS: readonly Tool[];
|
|
@@ -567,7 +731,7 @@ declare function formatScanSummary(result: ArsResult): string;
|
|
|
567
731
|
|
|
568
732
|
declare const SERVER_NAME = "@rebilder/mcp-server";
|
|
569
733
|
declare const SERVER_TITLE = "Rebilder \u2014 Agent Readability";
|
|
570
|
-
declare const SERVER_VERSION = "0.
|
|
734
|
+
declare const SERVER_VERSION = "0.5.0";
|
|
571
735
|
/**
|
|
572
736
|
* The newest MCP revision this server implements. `2025-06-18` introduced tool
|
|
573
737
|
* `outputSchema` and `structuredContent`, which the design requires (§5.6), and
|
|
@@ -591,4 +755,4 @@ declare const LATEST_PROTOCOL_VERSION = "2025-11-25";
|
|
|
591
755
|
*/
|
|
592
756
|
declare const SUPPORTED_PROTOCOL_VERSIONS: readonly string[];
|
|
593
757
|
|
|
594
|
-
export { ARS_RESULT_SCHEMA, type CallToolResult, DEFAULT_INDEX_BASE_URL, ERROR_CODES, type Environment, type FetchLike, INDEX_BASE_URL_ENV, type IndexClient, type IndexLookup, type JsonRpcFailure, type JsonRpcResponse, type JsonRpcSuccess, type JsonSchema, LATEST_PROTOCOL_VERSION, type McpServer, type McpServerOptions, PROBE_BUDGET_ENV, SERVER_INSTRUCTIONS, SERVER_NAME, SERVER_TITLE, SERVER_VERSION, SUPPORTED_PROTOCOL_VERSIONS, type Scanner, type ServerDependencies, type StdioStreams, TOOLS, type Tool, type ToolDeps, type ToolReturn, UNTRUSTED_NOTICE, type UntrustedBlock, createDefaultScanner, createDependencies, createIndexClient, createLineReader, createServer, decodeFrame, decodeLine, encodeFrame, failure, findTool, formatScanSummary, indexEntryUrl, isValidDomain, listToolsResult, localFailure, normalizeDomain, probeBudgetFromEnv, resolveIndexBaseUrl, sanitizeUntrustedText, serveStdio, success, targetFailure, toCallToolResult, untrustedNonce, wrapUntrusted };
|
|
758
|
+
export { API_KEY_ENV, ARS_RESULT_SCHEMA, type ApiFailureCode, CHECK_DOCS_INPUT, CHECK_DOCS_OUTPUT, type CallToolResult, DEFAULT_INDEX_BASE_URL, DEFAULT_VERIFY_TIMEOUT_MS, type DocsCheckReport, type DocsFinding, type DocsFindingCheck, type DocsFindingSeverity, type DocsRetrievalSummary, ERROR_CODES, type Environment, type FetchLike, INDEX_BASE_URL_ENV, type IndexClient, type IndexClientOptions, type IndexLookup, type JsonRpcFailure, type JsonRpcResponse, type JsonRpcSuccess, type JsonSchema, LATEST_PROTOCOL_VERSION, LIST_SITE_FIXES_INPUT, LIST_SITE_FIXES_OUTPUT, type ListSiteFixesParams, type McpServer, type McpServerOptions, PROBE_BUDGET_ENV, SERVER_INSTRUCTIONS, SERVER_NAME, SERVER_TITLE, SERVER_VERSION, SUPPORTED_PROTOCOL_VERSIONS, type Scanner, type ServerDependencies, type SiteFixItem, type SiteFixesResponse, type SiteFixesResult, type StdioStreams, TOOLS, type Tool, type ToolDeps, type ToolReturn, UNTRUSTED_NOTICE, type UntrustedBlock, VERIFY_FIX_INPUT, VERIFY_FIX_OUTPUT, type VerifyFixCheck, type VerifyFixIndexNow, type VerifyFixParams, type VerifyFixResponse, type VerifyFixResult, analyzeDocsEvidence, createDefaultScanner, createDependencies, createIndexClient, createLineReader, createServer, decodeFrame, decodeLine, encodeFrame, failure, findTool, formatScanSummary, indexEntryUrl, isValidDomain, listSiteFixesTool, listToolsResult, localFailure, normalizeDomain, probeBudgetFromEnv, resolveApiKey, resolveIndexBaseUrl, sanitizeUntrustedText, serveStdio, siteFixesUrl, success, targetFailure, toCallToolResult, untrustedNonce, verifyFixTool, verifyFixUrl, wrapUntrusted };
|