@topline-build/harness-mcp 0.9.0 → 0.9.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 +13 -5
- package/README.md +3 -3
- package/dist/build-session-tools.d.ts +8 -0
- package/dist/build-session-tools.js +11 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.js +140 -30
- package/docs/generated/build-mcp-manifest.json +7 -2
- package/docs/generated/build-mcp-reference.md +2 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,11 +2,19 @@
|
|
|
2
2
|
|
|
3
3
|
All notable customer-visible Build MCP changes are recorded here. A source change is not a published package or customer release.
|
|
4
4
|
|
|
5
|
-
## 0.9.
|
|
5
|
+
## 0.9.1 - source candidate
|
|
6
|
+
|
|
7
|
+
- `--surface topline` no longer asks for `workspace:todo:write`. Topline retired that scope and leaves it out of every grant, so the package treated each fresh sign-in as incomplete and opened the browser again on the next launch (and twice during `topline-mcp login`). A retired scope named in `TOPLINE_MCP_SCOPES` or `--scopes` is dropped too. Existing sign-ins are reused without another approval.
|
|
8
|
+
- The default `build` surface lists and forwards hosted Build tools the way `--surface topline` does, so new hosted Build tools reach Codex, Claude Code and Cursor without a package release. Local tools (init, inspect, deploy, checkout, materialize and the rest of the package's own list) stay local and win over a hosted tool of the same name. Hosted `platform_create_artifact_app` and `platform_bedrock_local_token_command` stay off. A manual token on `build` keeps the package's own list.
|
|
9
|
+
- Build session tools (start, read and close a session, workspace SQL, checkout, materialize, assets, secrets, acceptance and validation) follow the hosted list, on `build` and on `--surface topline`: they are listed only while the connection's hosted tool list offers them. Today that list follows the granted scopes and the `harness.workforce` capability. OAuth users without the asset, secret, workspace SQL or validation scopes therefore no longer see those tools listed; Topline refused them anyway, and they come back after reconnecting with those scopes. Signed out, or before the first good listing, every session tool stays listed. A call to a hidden one returns `build_session_tool_unavailable` without reaching Topline and asks the host to list tools again; after a reconnect with a changed grant the call goes through to Topline. `platform_capability_status` is always listed.
|
|
10
|
+
- A failed hosted tool listing (network, 5xx, timeout or any error other than a rejected sign-in) keeps the last good list for the life of the process while the same sign-in holds, and lists the package's own tools before any good listing. The next tool call asks the host to list again, so one error never hides tools for the rest of the chat. A rejected sign-in (revoked or invalid refresh token, or a 401 from the hosted list) counts as signed out and clears the last good list, as does signing out. This applies to `--surface topline` too.
|
|
11
|
+
- Session tools that only forward to Topline take the hosted input schema when the hosted list provides one.
|
|
12
|
+
|
|
13
|
+
## 0.9.0 - 2026-10-14
|
|
6
14
|
|
|
7
15
|
- `platform_init_artifact_app` takes `shape: "web-and-api"` to scaffold one artifact with a static website part and an API part under one address, instead of two artifacts. `platform_inspect_artifact_app` lists an app's parts.
|
|
8
16
|
|
|
9
|
-
## 0.8.0 -
|
|
17
|
+
## 0.8.0 - 2026-10-13
|
|
10
18
|
|
|
11
19
|
- Add `--surface topline`: one Topline server per account. It runs the local Build tools and lists and forwards every hosted tool the person's grant allows (Workspace tools included), so assistants see one Topline entry.
|
|
12
20
|
- Add `topline-mcp login --url <account>`: opens the browser once during setup, saves the refresh token to the auth file the server reads, then records a code-free connection check so Topline Developer Access shows the computer as connected.
|
|
@@ -17,20 +25,20 @@ All notable customer-visible Build MCP changes are recorded here. A source chang
|
|
|
17
25
|
- Every request to the Topline account carries `x-topline-mcp-version`. Topline uses it to show "Update available" in Developer Access and, when this package is older than the account needs, to answer tool calls with `topline_mcp_update_required` and how to update (copy setup again).
|
|
18
26
|
- The combined server does not list or forward hosted `platform_create_artifact_app` or `platform_bedrock_local_token_command`; the local package, upload and deploy flow stays the only Build write path.
|
|
19
27
|
|
|
20
|
-
## 0.7.0 -
|
|
28
|
+
## 0.7.0 - 2026-10-12
|
|
21
29
|
|
|
22
30
|
- Add exactly six gated company-domain tools: connected-domain/status/recovery reads, owned-app address reads, single-use plan/apply, manager registration and ownership verification.
|
|
23
31
|
- Require explicit new scopes and account-bound Build OAuth; preserve manual-token behavior for legacy tools.
|
|
24
32
|
- Retain original keys and typed recovery context after a lost response. Domain reads never retry setup, apply an address, publish an app or write provider DNS.
|
|
25
33
|
- Discover enabled server capabilities and current hosted scoped contracts without initiating OAuth during discovery.
|
|
26
34
|
|
|
27
|
-
## 0.6.0 -
|
|
35
|
+
## 0.6.0 - 2026-10-12
|
|
28
36
|
|
|
29
37
|
- Add server-owned external build sessions, guarded artifact-private SQL, and full acceptance/reviewer forwarding.
|
|
30
38
|
- Check out exact artifact source and materialize selected assets through authenticated same-account transfers with hash, revision, archive and local-path checks.
|
|
31
39
|
- Bind local draft create/deploy to the existing session identity, checked-out version, inspected source hash and stable operation keys. Additional asset, secret-metadata and data-verification scopes require explicit consent.
|
|
32
40
|
|
|
33
|
-
## 0.5.3 -
|
|
41
|
+
## 0.5.3 - 2026-09-28
|
|
34
42
|
|
|
35
43
|
- Add tenant-scoped Storyboard state, guarded edit, and exact-draft publication tools to Build MCP.
|
|
36
44
|
- Check out the published Storyboard source for local Storybook iteration and submit source-only edits as a private, server-validated draft.
|
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ The first authenticated tool call normally opens Topline in a browser for OAuth
|
|
|
14
14
|
|
|
15
15
|
### One Topline server (0.8.0)
|
|
16
16
|
|
|
17
|
-
Topline Developer Access now sets up one Topline connection per account. Its plugin runs this package with `--surface topline`: the local Build tools plus every hosted tool your seat and grant allow, including Workspace tools, under one server entry. Sign in once during setup:
|
|
17
|
+
Topline Developer Access now sets up one Topline connection per account. Its plugin runs this package with `--surface topline`: the local Build tools plus every hosted tool your seat and grant allow, including Workspace tools, under one server entry. The default `build` surface does the same for hosted Build tools (0.9.1); local tools stay local. A manual `--token` on `build` keeps the package's own list. On both surfaces, build session tools follow the hosted list: they are listed only while the connection's hosted tool list offers them, and stay listed while signed out. If listing hosted tools fails temporarily, the server keeps the last good list for the same sign-in, or the package's own tools before the first one. Sign in once during setup:
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
20
|
npx -y @topline-build/harness-mcp login --url https://YOUR-TOPLINE-HOST
|
|
@@ -36,13 +36,13 @@ If a tool returns `authorization_required`, clear only that connection's OAuth c
|
|
|
36
36
|
|
|
37
37
|
Storyboard authoring uses separate `storyboard:read` and `storyboard:write` OAuth scopes. Request them explicitly with `--scopes` (or `TOPLINE_MCP_SCOPES`) and reconnect so Topline can approve the expanded grant; they are not part of the default artifact scopes. `platform_get_design_system_state` shows the published commit and current draft. `platform_checkout_design_system` creates a local checkout of that published source; run `npm ci` and `npm run storybook` there to iterate, then call `platform_submit_design_system_draft` with the exact published commit and draft ID from the state read. Wait for a successful server build, inspect the private preview, and call `platform_publish_design_system` with the reviewed run and commit values. Alternatively, `platform_edit_design_system` asks Topline's guarded coding agent to edit a draft in an existing writable Storyboard conversation. A timed-out write should be recovered by reading state before another submission. The separate Storybook reference MCP endpoint does not accept source writes.
|
|
38
38
|
|
|
39
|
-
|
|
39
|
+
Since 0.7.0 the package includes six company-domain tools for a compatible, explicitly enabled server. Request `harness:domains:read` and `harness:artifact:read` for discovery and owned-app address reads; add `harness:artifact:addresses:write` for plan/apply. Setup and full DNS/TLS details also require `harness:domains:manage` and the existing organization-manager capability. These scopes are never implicit defaults. All six require account-bound Build OAuth; unbound manual tokens cannot use them. Runtime discovery follows server gates and, once signed in, current hosted scopes and roles. The helper sends a tool-list change notification after first sign-in so clients can discover authorized setup and recovery selectors.
|
|
40
40
|
|
|
41
41
|
Read connected domains and the current address, show the exact `platform_plan_artifact_address` preview, then apply that single-use plan. Save every mutation key before calling. Recover a lost apply response through `platform_get_artifact_address` with the saved artifact ID and key. Recover a lost registration/verification response through `platform_read_artifact_domains` with its kind and key, even if the response containing the new domain ID was lost. Reads never replay writes. Pending, absent or expired receipts do not authorize a new key. A definite terminal DNS no-admission result permits a fresh verification key only within covered setup/retry intent, after a fresh generation read and the ten-second interval. Read-only polling stops after five minutes and reports the saved recovery context; it never verifies automatically. Saving an address does not publish the app, change access, or write DNS. Exact DNS records must be saved by the customer or a separately authorized DNS connection.
|
|
42
42
|
|
|
43
43
|
## Typical workflow
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Session authoring (published in 0.6.0) needs a compatible customer API. Start `platform_start_build_session` with an existing artifact's exact version or a new app manifest, a stable idempotency key and a Topline operation budget. External client model charges stay separate. For existing apps, `platform_checkout_artifact_app` writes exact saved source into a new local directory and returns its version, commit and source hash. Never reconstruct missing source from its manifest.
|
|
46
46
|
|
|
47
47
|
Keep Build and Workspace as separate same-account connections. Workspace supplies catalog, SQL and trusted calculations through `data:read`. Reusable assets, approved secret metadata, private table writes, validation and finite artifact data verification each require their separately consented Build scopes: `harness:assets:read`, `harness:secrets:metadata:read`, `harness:artifact:tables:write`, `harness:artifact:validate`, and `harness:artifact:data:verify`. The defaults remain the existing artifact scopes; request an expanded set explicitly and reconnect. Secret discovery returns approved references only, never values.
|
|
48
48
|
|
|
@@ -6,4 +6,12 @@ type Annotate = (name: string, policy: {
|
|
|
6
6
|
}) => ToolAnnotations;
|
|
7
7
|
export declare function externalBuildHelperTools(annotate: Annotate): ListToolsResult["tools"];
|
|
8
8
|
export declare const EXTERNAL_BUILD_FORWARD_TOOLS: Set<string>;
|
|
9
|
+
/**
|
|
10
|
+
* Session tools listed only while the hosted Build list offers them. Each
|
|
11
|
+
* calls the hosted tool of the same name; checkout and materialize then do
|
|
12
|
+
* their local transfer. Capability status stays listed so it can say why.
|
|
13
|
+
*/
|
|
14
|
+
export declare const EXTERNAL_BUILD_SESSION_TOOLS: ReadonlySet<string>;
|
|
15
|
+
/** Session tools that only call the hosted tool of the same name, so they can take its input schema. */
|
|
16
|
+
export declare const EXTERNAL_BUILD_SESSION_FORWARD_TOOLS: ReadonlySet<string>;
|
|
9
17
|
export {};
|
|
@@ -61,3 +61,14 @@ export const EXTERNAL_BUILD_FORWARD_TOOLS = new Set([
|
|
|
61
61
|
"platform_list_asset_folders", "platform_list_assets", "platform_list_build_secrets", "platform_add_acceptance_check", "platform_run_acceptance_checks",
|
|
62
62
|
"platform_record_acceptance_review", "platform_prepare_artifact_validation", "platform_request_artifact_validation", "platform_artifact_validation_status", "platform_answer_operator_prompt"
|
|
63
63
|
]);
|
|
64
|
+
/**
|
|
65
|
+
* Session tools listed only while the hosted Build list offers them. Each
|
|
66
|
+
* calls the hosted tool of the same name; checkout and materialize then do
|
|
67
|
+
* their local transfer. Capability status stays listed so it can say why.
|
|
68
|
+
*/
|
|
69
|
+
export const EXTERNAL_BUILD_SESSION_TOOLS = new Set([
|
|
70
|
+
...[...EXTERNAL_BUILD_FORWARD_TOOLS].filter((name) => name !== "platform_capability_status"),
|
|
71
|
+
"platform_checkout_artifact_app", "platform_materialize_assets"
|
|
72
|
+
]);
|
|
73
|
+
/** Session tools that only call the hosted tool of the same name, so they can take its input schema. */
|
|
74
|
+
export const EXTERNAL_BUILD_SESSION_FORWARD_TOOLS = new Set([...EXTERNAL_BUILD_SESSION_TOOLS].filter((name) => EXTERNAL_BUILD_FORWARD_TOOLS.has(name)));
|
package/dist/index.d.ts
CHANGED
|
@@ -3,9 +3,10 @@ import { type CallToolResult, type ListToolsResult } from "@modelcontextprotocol
|
|
|
3
3
|
export interface HarnessMcpStdioOptions {
|
|
4
4
|
apiUrl: string;
|
|
5
5
|
/**
|
|
6
|
-
* Defaults to the Build MCP
|
|
7
|
-
*
|
|
8
|
-
*
|
|
6
|
+
* Defaults to the Build MCP: local Build tools plus the hosted Build tools
|
|
7
|
+
* the person's OAuth grant allows. `topline` is the one server per account:
|
|
8
|
+
* local Build tools plus every hosted tool the person's grant allows. Use
|
|
9
|
+
* harness only for legacy deployments.
|
|
9
10
|
*/
|
|
10
11
|
surface?: McpSurface;
|
|
11
12
|
token?: string;
|
|
@@ -39,7 +40,7 @@ type ToolProgressReporter = (progress: number, message: string) => void | Promis
|
|
|
39
40
|
export type McpSurface = "build" | "topline" | "harness";
|
|
40
41
|
export declare const DEFAULT_MCP_PROTOCOL_VERSION = "2025-11-25";
|
|
41
42
|
export declare const BUILD_MCP_SERVER_NAME = "topline-build-stdio";
|
|
42
|
-
export declare const HARNESS_MCP_VERSION = "0.9.
|
|
43
|
+
export declare const HARNESS_MCP_VERSION = "0.9.1";
|
|
43
44
|
export declare const DEFAULT_OAUTH_SCOPES: readonly string[];
|
|
44
45
|
/** The Topline server's scopes: Build and Workspace. Consent shows what the seat allows. */
|
|
45
46
|
export declare const TOPLINE_OAUTH_SCOPES: readonly string[];
|
|
@@ -72,6 +73,7 @@ export declare function cliInfo(argv: string[]): string | null;
|
|
|
72
73
|
export declare function createHarnessMcpStdioServer(opts: HarnessMcpStdioOptions, toolAllowlist?: readonly string[]): McpServer;
|
|
73
74
|
export declare function callHarnessTool(opts: HarnessMcpStdioOptions, name: string, args: unknown, hooks?: {
|
|
74
75
|
onProgress?: ToolProgressReporter;
|
|
76
|
+
inputSchema?: ListToolsResult["tools"][number]["inputSchema"];
|
|
75
77
|
}): Promise<CallToolResult>;
|
|
76
78
|
export declare function deployArtifactApp(opts: HarnessMcpStdioOptions, input: Record<string, unknown>, onProgress?: ToolProgressReporter): Promise<{
|
|
77
79
|
operationId: string | null;
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { createServer } from "node:http";
|
|
|
6
6
|
import os from "node:os";
|
|
7
7
|
import path from "node:path";
|
|
8
8
|
import { gzipSync } from "node:zlib";
|
|
9
|
-
import { externalBuildHelperTools, EXTERNAL_BUILD_FORWARD_TOOLS } from "./build-session-tools.js";
|
|
9
|
+
import { externalBuildHelperTools, EXTERNAL_BUILD_FORWARD_TOOLS, EXTERNAL_BUILD_SESSION_FORWARD_TOOLS, EXTERNAL_BUILD_SESSION_TOOLS } from "./build-session-tools.js";
|
|
10
10
|
import { domainHelperTools, DOMAIN_FORWARD_TOOLS, DOMAIN_ERROR_CODES } from "./domain-tools.js";
|
|
11
11
|
import { boundedTransfer, extractArtifactSourceArchive, MAX_SOURCE_ARCHIVE_BYTES, safeSourcePath } from "./source-checkout.js";
|
|
12
12
|
import { Server as McpServer } from "@modelcontextprotocol/sdk/server/index.js";
|
|
@@ -17,7 +17,7 @@ const MCP_SURFACES = ["build", "topline", "harness"];
|
|
|
17
17
|
export const DEFAULT_MCP_PROTOCOL_VERSION = "2025-11-25";
|
|
18
18
|
const DEFAULT_TIMEOUT_MS = 120_000;
|
|
19
19
|
export const BUILD_MCP_SERVER_NAME = "topline-build-stdio";
|
|
20
|
-
export const HARNESS_MCP_VERSION = "0.9.
|
|
20
|
+
export const HARNESS_MCP_VERSION = "0.9.1";
|
|
21
21
|
export const DEFAULT_OAUTH_SCOPES = Object.freeze(["harness:artifact:read", "harness:artifact:write", "harness:artifact:deploy", "harness:artifact:delete"]);
|
|
22
22
|
/** The Topline server's scopes: Build and Workspace. Consent shows what the seat allows. */
|
|
23
23
|
export const TOPLINE_OAUTH_SCOPES = Object.freeze([
|
|
@@ -26,11 +26,16 @@ export const TOPLINE_OAUTH_SCOPES = Object.freeze([
|
|
|
26
26
|
"harness:secrets:metadata:read", "harness:domains:read", "harness:domains:manage", "harness:artifact:addresses:write",
|
|
27
27
|
"storyboard:read", "storyboard:write",
|
|
28
28
|
"docs:read", "chat:read", "chat:write", "workspace:write", "workspace:delete", "workspace:content:read",
|
|
29
|
-
"workspace:content:write", "workspace:content:delete", "workspace:
|
|
29
|
+
"workspace:content:write", "workspace:content:delete", "workspace:skills:read",
|
|
30
30
|
"workspace:skills:write", "workspace:access:manage", "schedules:read", "schedules:write", "schedules:delete",
|
|
31
31
|
"workforce:read", "workforce:write", "memory:read", "preferences:write", "glossary:read", "glossary:write",
|
|
32
32
|
"company_knowledge:propose", "company_knowledge:write", "customer_profiles:read", "data:read"
|
|
33
33
|
]);
|
|
34
|
+
/**
|
|
35
|
+
* Scopes Topline no longer grants. It drops them from every grant, so asking for one
|
|
36
|
+
* makes a fresh grant look incomplete and reopens the browser on every launch.
|
|
37
|
+
*/
|
|
38
|
+
const RETIRED_OAUTH_SCOPES = new Set(["workspace:todo:write"]);
|
|
34
39
|
export const BUILD_MCP_SETUP_OPTIONS = Object.freeze([
|
|
35
40
|
{ flag: "--url", env: "TOPLINE_API_URL", aliases: ["PLATFORM_API_URL", "OVERSITE_API_URL"], required: true, description: "Topline tenant base URL. HTTPS is required except for loopback development." },
|
|
36
41
|
{ flag: "--workspace-root", env: "TOPLINE_WORKSPACE_ROOT", aliases: ["PLATFORM_WORKSPACE_ROOT"], default: "current working directory", description: "Local root that contains artifact app directories." },
|
|
@@ -81,7 +86,7 @@ export function parseHarnessOptions(argv, env = process.env, defaults = {}) {
|
|
|
81
86
|
const scopes = (getArg("--scopes") || firstEnv(env, "TOPLINE_MCP_SCOPES", "PLATFORM_MCP_SCOPES") || defaultScopes.join(" "))
|
|
82
87
|
.split(/[\s,]+/)
|
|
83
88
|
.map((scope) => scope.trim())
|
|
84
|
-
.filter(
|
|
89
|
+
.filter((scope) => scope && !RETIRED_OAUTH_SCOPES.has(scope));
|
|
85
90
|
return {
|
|
86
91
|
apiUrl: normalizedApiUrl,
|
|
87
92
|
surface: surfaceRaw,
|
|
@@ -179,8 +184,27 @@ export function cliInfo(argv) {
|
|
|
179
184
|
}
|
|
180
185
|
export function createHarnessMcpStdioServer(opts, toolAllowlist) {
|
|
181
186
|
let discoveredGrant = null;
|
|
187
|
+
// The last tools/list built from a successful hosted listing, bound to the
|
|
188
|
+
// sign-in it was made with. A temporary listing failure reuses it for the
|
|
189
|
+
// life of the process instead of hiding tools; signing out clears it.
|
|
190
|
+
let lastHostedListing = null;
|
|
191
|
+
let hostedListingFailed = false;
|
|
192
|
+
// Session tools the most recent listing left out; calls to them are refused.
|
|
193
|
+
let hiddenSessionTools = new Set();
|
|
194
|
+
// Hosted input schemas for session tools that only forward, from the last good listing.
|
|
195
|
+
let hostedSessionSchemas = new Map();
|
|
196
|
+
// Only the newest listing writes shared state, so a slow older one cannot overwrite it.
|
|
197
|
+
let listingGeneration = 0;
|
|
182
198
|
const grantTag = (stored) => stored?.accessToken && Date.parse(stored.accessTokenExpiresAt ?? "") > Date.now()
|
|
183
199
|
? JSON.stringify([stored.clientId, stored.resource, [...stored.scopes].sort()]) : null;
|
|
200
|
+
// Identifies one sign-in regardless of access-token expiry: each browser
|
|
201
|
+
// sign-in registers a new client.
|
|
202
|
+
const signInTag = async () => {
|
|
203
|
+
if (opts.token)
|
|
204
|
+
return "manual-token";
|
|
205
|
+
const stored = await readStoredOAuthCredentials(opts).catch(() => null);
|
|
206
|
+
return stored ? JSON.stringify([stored.issuer, stored.clientId, stored.resource, [...stored.scopes].sort()]) : null;
|
|
207
|
+
};
|
|
184
208
|
const allowedTools = toolAllowlist ? new Set(toolAllowlist) : null;
|
|
185
209
|
const listedTools = () => {
|
|
186
210
|
const listed = listTools();
|
|
@@ -191,35 +215,91 @@ export function createHarnessMcpStdioServer(opts, toolAllowlist) {
|
|
|
191
215
|
const listed = listedTools();
|
|
192
216
|
if (!servesBuild(opts) || (opts.token && mcpSurface(opts) !== "topline"))
|
|
193
217
|
return { tools: listed.tools.filter(tool => !DOMAIN_FORWARD_TOOLS.has(tool.name)) };
|
|
218
|
+
const generation = ++listingGeneration;
|
|
219
|
+
const newest = () => generation === listingGeneration;
|
|
220
|
+
let names = new Set();
|
|
221
|
+
// Signed out (or the sign-in was rejected): the package's own list, with
|
|
222
|
+
// session tools listed so first-run users see them.
|
|
223
|
+
const signedOut = () => {
|
|
224
|
+
if (newest()) {
|
|
225
|
+
lastHostedListing = null;
|
|
226
|
+
hiddenSessionTools = new Set();
|
|
227
|
+
hostedSessionSchemas = new Map();
|
|
228
|
+
}
|
|
229
|
+
return { tools: listed.tools.filter(tool => !DOMAIN_FORWARD_TOOLS.has(tool.name) || names.has(tool.name)).map(tool => tool.name === "platform_read_artifact_domains"
|
|
230
|
+
? { ...tool, inputSchema: { type: "object", additionalProperties: false, properties: { limit: { type: "integer", minimum: 1, maximum: 100 }, cursor: { type: "integer", minimum: 0, maximum: 10000 } } } }
|
|
231
|
+
: tool) };
|
|
232
|
+
};
|
|
194
233
|
// Public deployment metadata never initiates OAuth or changes consent.
|
|
195
234
|
// Unknown/old servers fail closed for this default-off family.
|
|
196
235
|
try {
|
|
197
236
|
const metadata = asRecord(await fetchJson({ ...opts, timeoutMs: Math.min(opts.timeoutMs, 5000) }, hostedMcpUrl(opts), { method: "GET" }));
|
|
198
|
-
|
|
237
|
+
names = new Set(Array.isArray(metadata.tools) ? metadata.tools.map(item => typeof item === "string" ? item : asRecord(item).name) : []);
|
|
199
238
|
// Listing never opens the browser, but it does refresh an expired access
|
|
200
|
-
// token so hosted tools still appear in a chat started hours later.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
239
|
+
// token so hosted tools still appear in a chat started hours later. A
|
|
240
|
+
// rejected sign-in counts as signed out; a temporary refresh failure
|
|
241
|
+
// after a good listing keeps that listing.
|
|
242
|
+
let bearer = null;
|
|
243
|
+
try {
|
|
244
|
+
bearer = await getBearerTokenWithoutSignIn(opts);
|
|
245
|
+
}
|
|
246
|
+
catch (error) {
|
|
247
|
+
if (lastHostedListing && !isSignInRejected(error))
|
|
248
|
+
throw error;
|
|
249
|
+
}
|
|
250
|
+
if (!bearer)
|
|
251
|
+
return signedOut();
|
|
252
|
+
let payload;
|
|
253
|
+
try {
|
|
254
|
+
payload = asRecord(await fetchJson({ ...opts, timeoutMs: Math.min(opts.timeoutMs, 5000) }, hostedMcpUrl(opts), {
|
|
204
255
|
method: "POST", headers: { authorization: `Bearer ${bearer}`, "content-type": "application/json", accept: "application/json, text/event-stream" },
|
|
205
256
|
body: JSON.stringify({ jsonrpc: "2.0", id: "domain-discovery", method: "tools/list", params: {} }),
|
|
206
257
|
}));
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (isSignInRejected(error))
|
|
261
|
+
return signedOut();
|
|
262
|
+
throw error;
|
|
263
|
+
}
|
|
264
|
+
const remote = asRecord(payload.result).tools;
|
|
265
|
+
if (!Array.isArray(remote))
|
|
266
|
+
throw new Error("domain_discovery_unavailable");
|
|
267
|
+
const contracts = new Map(remote.filter(isRecord).map(tool => [tool.name, tool]));
|
|
268
|
+
const hostedSchema = (name) => isRecord(contracts.get(name)?.inputSchema)
|
|
269
|
+
? contracts.get(name).inputSchema : undefined;
|
|
270
|
+
// Session tools follow the hosted list: listed only while it offers them.
|
|
271
|
+
const hidden = new Set(listed.tools.map(tool => tool.name).filter(name => EXTERNAL_BUILD_SESSION_TOOLS.has(name) && !contracts.has(name)));
|
|
272
|
+
const schemas = new Map(listed.tools.map(tool => tool.name)
|
|
273
|
+
.filter(name => EXTERNAL_BUILD_SESSION_FORWARD_TOOLS.has(name) && !hidden.has(name) && hostedSchema(name))
|
|
274
|
+
.map(name => [name, hostedSchema(name)]));
|
|
275
|
+
const local = listed.tools.filter(tool => !DOMAIN_FORWARD_TOOLS.has(tool.name) || (names.has(tool.name) && contracts.has(tool.name)))
|
|
276
|
+
.filter(tool => !hidden.has(tool.name))
|
|
277
|
+
.map(tool => DOMAIN_FORWARD_TOOLS.has(tool.name) ? { ...tool, inputSchema: contracts.get(tool.name).inputSchema }
|
|
278
|
+
: schemas.has(tool.name) ? { ...tool, inputSchema: schemas.get(tool.name) } : tool);
|
|
279
|
+
const tools = [...local, ...hostedOnlyTools(opts, remote, allowedTools)];
|
|
280
|
+
const signIn = await signInTag();
|
|
281
|
+
if (newest()) {
|
|
211
282
|
if (!opts.token)
|
|
212
283
|
discoveredGrant = grantTag(await readStoredOAuthCredentials(opts));
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
284
|
+
lastHostedListing = { tools, hiddenSessionTools: hidden, signIn };
|
|
285
|
+
hiddenSessionTools = hidden;
|
|
286
|
+
hostedSessionSchemas = schemas;
|
|
216
287
|
}
|
|
217
|
-
return { tools:
|
|
218
|
-
? { ...tool, inputSchema: { type: "object", additionalProperties: false, properties: { limit: { type: "integer", minimum: 1, maximum: 100 }, cursor: { type: "integer", minimum: 0, maximum: 10000 } } } }
|
|
219
|
-
: tool) };
|
|
288
|
+
return { tools: structuredClone(tools) };
|
|
220
289
|
}
|
|
221
290
|
catch {
|
|
222
|
-
|
|
291
|
+
// Network, 5xx or timeout: keep the last good listing while the same
|
|
292
|
+
// sign-in holds; before one exists, list the package's own tools. The
|
|
293
|
+
// next tool call asks the host to list again.
|
|
294
|
+
hostedListingFailed = true;
|
|
295
|
+
const last = lastHostedListing && lastHostedListing.signIn === await signInTag() ? lastHostedListing : null;
|
|
296
|
+
if (newest()) {
|
|
297
|
+
lastHostedListing = last;
|
|
298
|
+
hiddenSessionTools = last?.hiddenSessionTools ?? new Set();
|
|
299
|
+
if (!last)
|
|
300
|
+
hostedSessionSchemas = new Map();
|
|
301
|
+
}
|
|
302
|
+
return { tools: last ? structuredClone(last.tools) : listed.tools.filter(tool => !DOMAIN_FORWARD_TOOLS.has(tool.name)) };
|
|
223
303
|
}
|
|
224
304
|
});
|
|
225
305
|
mcp.setRequestHandler(CallToolRequestSchema, async (req, extra) => {
|
|
@@ -227,16 +307,24 @@ export function createHarnessMcpStdioServer(opts, toolAllowlist) {
|
|
|
227
307
|
throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${req.params.name}`);
|
|
228
308
|
}
|
|
229
309
|
const reportsProgress = req.params.name === "platform_deploy_artifact_app" || req.params.name === "platform_wait_artifact_deploy";
|
|
310
|
+
let refusedHidden = false;
|
|
230
311
|
try {
|
|
231
|
-
|
|
312
|
+
// A changed sign-in (for example a reconnect with new scopes) may offer
|
|
313
|
+
// the tool again; Topline still checks, so the call goes through.
|
|
314
|
+
if (hiddenSessionTools.has(req.params.name) && (opts.token || grantTag(await readStoredOAuthCredentials(opts)) === discoveredGrant)) {
|
|
315
|
+
refusedHidden = true;
|
|
316
|
+
return structuredToolError("build_session_tool_unavailable");
|
|
317
|
+
}
|
|
318
|
+
if (forwardsHostedSurface(opts) && !LOCAL_TOOL_NAMES.has(req.params.name)) {
|
|
232
319
|
if (!forwardsHostedTool(req.params.name))
|
|
233
320
|
throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${req.params.name}`);
|
|
234
321
|
// Workspace and other hosted tools: Topline checks scopes and seat.
|
|
235
322
|
return await forwardHostedTool(opts, req.params.name, req.params.arguments ?? {});
|
|
236
323
|
}
|
|
237
|
-
const result = await callHarnessTool(opts, req.params.name, req.params.arguments ?? {},
|
|
238
|
-
? { onProgress: (progress, message) => sendProgress(extra, progress, 1, message) }
|
|
239
|
-
:
|
|
324
|
+
const result = await callHarnessTool(opts, req.params.name, req.params.arguments ?? {}, {
|
|
325
|
+
...(reportsProgress ? { onProgress: (progress, message) => sendProgress(extra, progress, 1, message) } : {}),
|
|
326
|
+
inputSchema: hostedSessionSchemas.get(req.params.name)
|
|
327
|
+
});
|
|
240
328
|
return result;
|
|
241
329
|
}
|
|
242
330
|
catch (err) {
|
|
@@ -247,15 +335,24 @@ export function createHarnessMcpStdioServer(opts, toolAllowlist) {
|
|
|
247
335
|
return structuredToolError(redactSecrets(err instanceof Error ? err.message : String(err), opts));
|
|
248
336
|
}
|
|
249
337
|
finally {
|
|
338
|
+
let listChanged = false;
|
|
250
339
|
if (servesBuild(opts) && !opts.token) {
|
|
251
340
|
const currentGrant = grantTag(await readStoredOAuthCredentials(opts));
|
|
252
341
|
if (currentGrant !== discoveredGrant) {
|
|
253
342
|
discoveredGrant = currentGrant;
|
|
254
343
|
// First browser sign-in changes manager-only selector availability.
|
|
255
344
|
// Tell MCP hosts to rediscover before setup status/recovery calls.
|
|
256
|
-
|
|
345
|
+
listChanged = true;
|
|
257
346
|
}
|
|
258
347
|
}
|
|
348
|
+
if (hostedListingFailed || refusedHidden) {
|
|
349
|
+
// One failed listing, or a refused hidden tool, must not hide tools
|
|
350
|
+
// for the whole chat: the host lists again and sees current access.
|
|
351
|
+
hostedListingFailed = false;
|
|
352
|
+
listChanged = true;
|
|
353
|
+
}
|
|
354
|
+
if (listChanged)
|
|
355
|
+
await mcp.sendToolListChanged().catch(() => undefined);
|
|
259
356
|
}
|
|
260
357
|
});
|
|
261
358
|
return mcp;
|
|
@@ -265,7 +362,8 @@ export async function callHarnessTool(opts, name, args, hooks) {
|
|
|
265
362
|
const tool = listTools().tools.find((candidate) => candidate.name === name);
|
|
266
363
|
if (!tool)
|
|
267
364
|
throw new McpError(ErrorCode.InvalidParams, `Unknown tool: ${name}`);
|
|
268
|
-
|
|
365
|
+
// A forwarding session tool may be checked against the hosted schema it was listed with.
|
|
366
|
+
const inputError = validateJsonSchema(hooks?.inputSchema && EXTERNAL_BUILD_SESSION_FORWARD_TOOLS.has(name) ? hooks.inputSchema : tool.inputSchema, input);
|
|
269
367
|
if (inputError)
|
|
270
368
|
return toolError(`Invalid arguments for ${name}: ${inputError}`);
|
|
271
369
|
let result;
|
|
@@ -1613,16 +1711,22 @@ const LOCAL_TOOL_NAMES = new Set(BUILD_MCP_TOOLS.map((tool) => tool.name));
|
|
|
1613
1711
|
/**
|
|
1614
1712
|
* Hosted Build tools this package deliberately replaces with its own local
|
|
1615
1713
|
* flow (package, upload, deploy) or keeps off entirely. They are neither
|
|
1616
|
-
* listed nor forwarded on the combined server.
|
|
1714
|
+
* listed nor forwarded on the Build or combined server.
|
|
1617
1715
|
*/
|
|
1618
1716
|
const HOSTED_TOOLS_NOT_FORWARDED = new Set(["platform_create_artifact_app", "platform_bedrock_local_token_command"]);
|
|
1619
1717
|
const forwardsHostedTool = (name) => !LOCAL_TOOL_NAMES.has(name) && !HOSTED_TOOLS_NOT_FORWARDED.has(name);
|
|
1620
1718
|
/**
|
|
1621
|
-
*
|
|
1622
|
-
*
|
|
1719
|
+
* The combined Topline server, and the Build server signed in through OAuth,
|
|
1720
|
+
* list and forward hosted tools this package does not run locally. A local
|
|
1721
|
+
* tool always wins over a hosted tool of the same name.
|
|
1722
|
+
*/
|
|
1723
|
+
const forwardsHostedSurface = (opts) => mcpSurface(opts) === "topline" || (mcpSurface(opts) === "build" && !opts.token);
|
|
1724
|
+
/**
|
|
1725
|
+
* Hosted tools this package does not run locally (new hosted Build tools, or
|
|
1726
|
+
* Workspace tools on the combined server) are listed from Topline as-is.
|
|
1623
1727
|
*/
|
|
1624
1728
|
function hostedOnlyTools(opts, remote, allowedTools) {
|
|
1625
|
-
if (
|
|
1729
|
+
if (!forwardsHostedSurface(opts))
|
|
1626
1730
|
return [];
|
|
1627
1731
|
return remote.filter(isRecord)
|
|
1628
1732
|
.filter((tool) => typeof tool.name === "string" && forwardsHostedTool(tool.name) && (!allowedTools || allowedTools.has(tool.name)) && isRecord(tool.inputSchema))
|
|
@@ -1725,6 +1829,7 @@ const BUILD_MCP_RECOVERY_ERROR_VALUES = {
|
|
|
1725
1829
|
...Object.fromEntries([...DOMAIN_ERROR_CODES].map(code => [code, { retryable: false,
|
|
1726
1830
|
recoveryAction: "Read current domain/address state and the original receipt with the saved pre-call key. Retain the exact original input. Review changed state, scopes or configuration before any new plan/key; never assume a rejected delivery means no effect." }])),
|
|
1727
1831
|
domain_result_unknown: { retryable: false, recoveryAction: "The response did not establish an outcome. Recover the original receipt through platform_get_artifact_address (saved artifactId and apply key) or platform_read_artifact_domains (request/verify kind and key). Preserve the original plan/domain/input/key; an absent, pending or expired receipt does not authorize a fresh key. No mutation is replayed automatically." },
|
|
1832
|
+
build_session_tool_unavailable: { retryable: false, recoveryAction: "The connection's hosted Build tool list does not offer this build session tool, so the package does not list or run it. Call platform_capability_status to see what is missing, such as a scope or capability, and reconnect through browser sign-in with any missing scope. The package asks the host to list tools again, so the tool comes back once Topline offers it." },
|
|
1728
1833
|
authorization_required: { retryable: false, recoveryAction: "Clear only this connection's cached OAuth credentials, then reconnect the Build MCP through browser sign-in. If using a manual bearer token, replace the expired or revoked token. Recover existing artifact/deployment progress before retrying a write." },
|
|
1729
1834
|
platform_harness_timeout: { retryable: true, recoveryAction: "Retry the call. For a deployment, use platform_list_artifact_drafts to recover the artifact and platform_wait_artifact_deploy to resume progress." },
|
|
1730
1835
|
platform_mcp_tool_error: { retryable: false, recoveryAction: "Read the returned error code, correct the request or OAuth scopes, then retry." },
|
|
@@ -1889,6 +1994,11 @@ async function refreshOAuthToken(opts, stored) {
|
|
|
1889
1994
|
});
|
|
1890
1995
|
return credentialsFromTokenResponse(stored.issuer, stored.resource, stored.clientId, stored.scopes, token);
|
|
1891
1996
|
}
|
|
1997
|
+
/** The sign-in itself was refused (revoked, expired or invalid), as opposed to a temporary failure. */
|
|
1998
|
+
function isSignInRejected(err) {
|
|
1999
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
2000
|
+
return isRefreshTokenRejected(err) || /^(?:platform_harness|topline_oauth)_http_error:401(?::|$)/.test(message) || message === "missing_topline_refresh_token";
|
|
2001
|
+
}
|
|
1892
2002
|
function isRefreshTokenRejected(err) {
|
|
1893
2003
|
const message = err instanceof Error ? err.message : String(err);
|
|
1894
2004
|
return /^topline_oauth_http_error:(400|401):/.test(message) && /invalid_(grant|token)/i.test(message);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"schemaVersion": 1,
|
|
3
3
|
"package": {
|
|
4
4
|
"name": "@topline-build/harness-mcp",
|
|
5
|
-
"version": "0.9.
|
|
5
|
+
"version": "0.9.1",
|
|
6
6
|
"bin": {
|
|
7
7
|
"topline-mcp": "dist/cli.js"
|
|
8
8
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"defaultVersion": "2025-11-25",
|
|
13
13
|
"server": {
|
|
14
14
|
"name": "topline-build-stdio",
|
|
15
|
-
"version": "0.9.
|
|
15
|
+
"version": "0.9.1"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
"generatedFrom": {
|
|
@@ -337,6 +337,11 @@
|
|
|
337
337
|
"retryable": false,
|
|
338
338
|
"recoveryAction": "The response did not establish an outcome. Recover the original receipt through platform_get_artifact_address (saved artifactId and apply key) or platform_read_artifact_domains (request/verify kind and key). Preserve the original plan/domain/input/key; an absent, pending or expired receipt does not authorize a fresh key. No mutation is replayed automatically."
|
|
339
339
|
},
|
|
340
|
+
{
|
|
341
|
+
"code": "build_session_tool_unavailable",
|
|
342
|
+
"retryable": false,
|
|
343
|
+
"recoveryAction": "The connection's hosted Build tool list does not offer this build session tool, so the package does not list or run it. Call platform_capability_status to see what is missing, such as a scope or capability, and reconnect through browser sign-in with any missing scope. The package asks the host to list tools again, so the tool comes back once Topline offers it."
|
|
344
|
+
},
|
|
340
345
|
{
|
|
341
346
|
"code": "platform_harness_timeout",
|
|
342
347
|
"retryable": true,
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> Generated from `src/index.ts#BUILD_MCP_TOOLS`. Do not edit this file by hand.
|
|
4
4
|
|
|
5
|
-
Package: `@topline-build/harness-mcp@0.9.
|
|
5
|
+
Package: `@topline-build/harness-mcp@0.9.1`
|
|
6
6
|
Transport: `stdio`
|
|
7
7
|
Default protocol: `2025-11-25`
|
|
8
8
|
Canonical guide: https://topline.build/docs/build-mcp-guide
|
|
@@ -65,6 +65,7 @@ Tool failures set `isError: true` and return `structuredContent.error` with `cod
|
|
|
65
65
|
- `scope_required` (not automatically retryable): Reconnect the Build MCP and approve the requested scope.
|
|
66
66
|
- `domain_tools_require_build_oauth` (not automatically retryable): Read current domain/address state and the original receipt with the saved pre-call key. Retain the exact original input. Review changed state, scopes or configuration before any new plan/key; never assume a rejected delivery means no effect.
|
|
67
67
|
- `domain_result_unknown` (not automatically retryable): The response did not establish an outcome. Recover the original receipt through platform_get_artifact_address (saved artifactId and apply key) or platform_read_artifact_domains (request/verify kind and key). Preserve the original plan/domain/input/key; an absent, pending or expired receipt does not authorize a fresh key. No mutation is replayed automatically.
|
|
68
|
+
- `build_session_tool_unavailable` (not automatically retryable): The connection's hosted Build tool list does not offer this build session tool, so the package does not list or run it. Call platform_capability_status to see what is missing, such as a scope or capability, and reconnect through browser sign-in with any missing scope. The package asks the host to list tools again, so the tool comes back once Topline offers it.
|
|
68
69
|
- `platform_harness_timeout` (retryable): Retry the call. For a deployment, use platform_list_artifact_drafts to recover the artifact and platform_wait_artifact_deploy to resume progress.
|
|
69
70
|
- `platform_mcp_tool_error` (not automatically retryable): Read the returned error code, correct the request or OAuth scopes, then retry.
|
|
70
71
|
- `artifact_deploy_wait_timeout` (retryable): Call platform_wait_artifact_deploy again with the same artifactId and operationId.
|