@topline-build/harness-mcp 0.4.0 → 0.5.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 ADDED
@@ -0,0 +1,17 @@
1
+ # Changelog
2
+
3
+ All notable customer-visible Build MCP changes are recorded here. A source change is not a published package or customer release.
4
+
5
+ ## Unreleased
6
+
7
+ ## 0.5.1 - 2026-09-18
8
+
9
+ - Harden the bundled Claude certification script with strict tool isolation, effective-runtime proof, and noninteractive JSONL validation.
10
+ - Update certification setup documentation and regression coverage.
11
+ - Harden live certification CI and add an exact-version website documentation dispatch probe.
12
+
13
+ ## 0.5.0
14
+
15
+ - Add local artifact initialization and package inspection.
16
+ - Add workspace and draft discovery, durable deployment progress, trusted smoke validation, and plan-bound draft cleanup.
17
+ - Add strict tool schemas, safety annotations, structured recovery guidance, OAuth hardening, and package-boundary protections.
package/README.md CHANGED
@@ -1,128 +1,104 @@
1
1
  # Topline Build MCP
2
2
 
3
- Local stdio MCP connector for deploying Topline artifact app drafts from Codex,
4
- Claude Code, or another local MCP host.
3
+ Local stdio MCP connector for creating, inspecting, and deploying private Topline artifact app drafts from Codex, Claude Code, or another MCP host.
5
4
 
6
- The normal auth path is OAuth with browser approval. The helper stores OAuth
7
- refresh tokens in the user's local Topline config directory, outside the project
8
- repo.
5
+ The canonical customer guide is [Topline Build MCP documentation](https://topline.build/docs/build-mcp-guide). The package also ships a generated [runtime reference](docs/generated/build-mcp-reference.md) and [machine-readable manifest](docs/generated/build-mcp-manifest.json) for the exact package version.
9
6
 
10
- Required environment:
7
+ ## Quick start
11
8
 
12
- - `TOPLINE_API_URL` or `--url https://your-topline-host`
13
-
14
- Optional environment:
15
-
16
- - `TOPLINE_MCP_SURFACE` (`build` by default; `harness` for legacy compatibility)
17
- - `TOPLINE_MCP_PROTOCOL_VERSION`
18
- - `TOPLINE_WORKSPACE_ROOT`
19
- - `TOPLINE_MCP_AUTH_FILE`
20
- - `TOPLINE_MCP_SCOPES`
21
- - `TOPLINE_MCP_TIMEOUT_MS`
22
- - `TOPLINE_MCP_TOKEN` for advanced manual-token fallback
23
-
24
- Compatibility aliases are still accepted for older local setups:
9
+ ```bash
10
+ npx -y @topline-build/harness-mcp --url https://YOUR-TOPLINE-HOST
11
+ ```
25
12
 
26
- - `PLATFORM_API_URL`
27
- - `PLATFORM_MCP_TOKEN`
28
- - `PLATFORM_WORKSPACE_ROOT`
29
- - `PLATFORM_MCP_PROTOCOL_VERSION`
13
+ The first authenticated tool call normally opens Topline in a browser for OAuth approval. Refresh credentials are cached in the user's local Topline config directory, outside the project repository. Developer Access in Topline provides ready-to-use Codex and Claude Code configuration snippets without embedding a raw token.
30
14
 
31
- ## Usage
15
+ Set `TOPLINE_WORKSPACE_ROOT` when the MCP host starts outside the repository containing the artifact app:
32
16
 
33
17
  ```bash
18
+ TOPLINE_API_URL=https://YOUR-TOPLINE-HOST \
19
+ TOPLINE_WORKSPACE_ROOT=/path/to/workspace \
34
20
  npx -y @topline-build/harness-mcp
35
21
  ```
36
22
 
37
- For local checks:
23
+ Run `npx -y @topline-build/harness-mcp --help` for every supported flag and environment variable. `TOPLINE_MCP_TOKEN` is an advanced manual-token fallback; browser-approved OAuth is preferred.
38
24
 
39
- ```bash
40
- npx -y @topline-build/harness-mcp --help
41
- npx -y @topline-build/harness-mcp --url https://hawx.topline.build
42
- ```
25
+ ## Typical workflow
26
+
27
+ 1. Use `platform_init_artifact_app` to create a starter, or point at an existing artifact app.
28
+ 2. Use `platform_inspect_artifact_app` to check local package boundaries and record its bundle SHA-256.
29
+ 3. Use `platform_deploy_artifact_app` with that SHA-256 to create or update a private draft.
30
+ 4. Use `platform_wait_artifact_deploy`, `platform_run_artifact_smoke`, and `platform_validate_artifact` for durable deployment and render evidence.
31
+ 5. Use the plan-then-delete tools for reviewed cleanup.
43
32
 
44
- Set `TOPLINE_WORKSPACE_ROOT` when your MCP host starts outside the repo that
45
- contains the artifact app.
46
-
47
- The app can live anywhere under that workspace. For source tracking, the MCP
48
- maps ordinary local folders to `artifact-apps/<manifest-id>` while preserving
49
- existing `artifact-apps/<name>` roots and workspace-root (`.`) apps. Deploys
50
- report manifest, packaging, draft creation, upload, and trusted-deployment
51
- progress to clients that support MCP progress notifications.
52
- Every deploy also receives a deterministic retry key. If a client loses the
53
- response and repeats the call, Topline resumes the same private draft instead
54
- of creating an ordinary duplicate.
55
-
56
- Topline Developer Access provides Build MCP snippets for Codex and Claude Code.
57
- Those snippets contain no raw token; the first tool call opens a browser
58
- approval flow scoped to artifact building.
59
-
60
- ## Build workflow
61
-
62
- - `platform_init_artifact_app` creates a dependency-free starter in an empty
63
- local directory.
64
- - `platform_connection_check` completes the one-time verification shown in
65
- Developer Access.
66
- - `platform_list_build_workspaces` and `platform_list_artifact_drafts` discover
67
- valid placement targets and recover existing drafts without exposing chat or
68
- memory data.
69
- - `platform_deploy_artifact_app` packages the local app and deploys a private
70
- draft through Topline's trusted runtime. Its `operationId` can be passed to
71
- `platform_wait_artifact_deploy` for server-derived progress and recovery
72
- after a disconnected client.
73
- - `platform_run_artifact_smoke` reruns trusted draft rendering and returns the
74
- fresh evidence used by validation.
75
- - `platform_validate_artifact` returns bounded trusted smoke and rendered-page
76
- evidence without requiring the agent to hold a browser session.
77
- - `platform_artifact_status`, `platform_read_artifact_logs`, and
78
- `platform_open_artifact` inspect and hand off the draft.
79
- - `platform_plan_artifact_draft_delete` previews cleanup effects. Deletion uses
80
- a separately approved `harness:artifact:delete` scope, the exact artifact id,
81
- and the current plan token; stale plans fail closed.
82
-
83
- Tool failures include a stable error code, retryability, and a concrete
84
- recovery action in `structuredContent`.
85
-
86
- ## Live certification
87
-
88
- After building the package, a release operator can exercise the real MCP client
89
- protocol, workspace discovery, deploy/resume, smoke, validation, and cleanup
90
- planning against a tenant:
33
+ The generated reference is authoritative for tool names, input/output schemas, safety annotations, configuration, structured errors, and recovery guidance. Runtime `tools/list` and the reference are generated from the same registry.
34
+
35
+ ## Maintainers
36
+
37
+ See [Documentation maintenance](docs/DOCUMENTATION_MAINTENANCE.md) before changing tools, flags, authentication, errors, packaging, or releases. Validate with:
91
38
 
92
39
  ```bash
40
+ npm ci
41
+ npm run docs:check
42
+ npm run typecheck
43
+ npm test
93
44
  npm run build
94
- TOPLINE_API_URL=https://tenant.example \
95
- TOPLINE_MCP_TOKEN=... \
96
- TOPLINE_WORKSPACE_ROOT=/path/to/workspace \
97
- TOPLINE_CERTIFICATION_APP_DIR=artifact-apps/certification \
98
- npm run certify:live
45
+ npm pack --dry-run
99
46
  ```
100
47
 
101
- Set `TOPLINE_CERTIFICATION_CLEANUP=1` only when the certification draft should
102
- be removed after its cleanup plan is reviewed.
48
+ Client certification has two explicit phases and writes a machine-readable JSON
49
+ report. First run the read-only plan:
103
50
 
104
- ## Storybook
51
+ ```bash
52
+ TOPLINE_API_URL=https://YOUR-TOPLINE-HOST \
53
+ TOPLINE_WORKSPACE_ROOT=/path/to/workspace \
54
+ TOPLINE_CERTIFICATION_APP_DIR=artifact-apps/example \
55
+ npm run certify:clients -- --agent-mediated --output certification-plan.json
56
+ ```
105
57
 
106
- Use the `platform_storybook_access` tool to get the tenant Storybook preview URL
107
- and the HTTP MCP client config. For clients with HTTP MCP OAuth support, use
108
- the returned `cursorMcpJson`:
58
+ Review the reported bundle SHA-256. An authorized operator can then supply a
59
+ short-lived manual token and apply that exact reviewed bundle:
109
60
 
110
- ```json
111
- {
112
- "mcpServers": {
113
- "storybook": {
114
- "url": "https://your-topline-host/api/design-systems/storybook/mcp",
115
- "type": "http"
116
- }
117
- }
118
- }
61
+ ```bash
62
+ TOPLINE_MCP_TOKEN=... npm run certify:clients -- \
63
+ --phase apply \
64
+ --expected-bundle-sha256 <reviewed-sha256> \
65
+ --require-all \
66
+ --output certification-apply.json
119
67
  ```
120
68
 
121
- Storybook MCP access uses the harness bearer/OAuth credentials with
122
- `harness:artifact:read`; OAuth discovery is available at
123
- `/.well-known/oauth-protected-resource/mcp/build`.
124
-
125
- If your MCP client does not support HTTP MCP OAuth, use the returned
126
- `manualBearerMcpJson` template with a read-scoped `TOPLINE_MCP_TOKEN` in the
127
- client's secret mechanism. Opening the visual preview URL in a browser still
128
- requires a signed-in Topline session.
69
+ Normal customer setup should use browser-approved OAuth. The manual token is a
70
+ noninteractive certification boundary only; never put it in CLI arguments,
71
+ configuration files, reports, or logs. The report keeps actual CLI
72
+ configuration health, SDK-level `protocolToolDiscovery`, and the optional
73
+ provider-backed `clientMediatedRead` as separate evidence. `--agent-mediated`
74
+ can consume provider model quota and runs only for clients whose CLI can reject
75
+ user/global MCP configuration and disable every built-in tool. Claude Code is
76
+ currently the supported mediated client; Codex and Cursor report
77
+ `strict_client_tool_isolation_unavailable` instead of starting an agent with
78
+ broader access. The Claude process uses strict MCP configuration, bare mode,
79
+ no built-in tools, an allowlisted environment, an isolated OAuth cache, and a
80
+ server exposing only `platform_inspect_artifact_app`. Its bare noninteractive
81
+ permission bypass is accepted only when Claude's structured init event proves
82
+ that this is the sole effective tool and MCP server. The write credential is
83
+ available only to the direct exact-SHA apply path. Missing client CLIs, provider
84
+ login, URL/app inputs, or credentials produce explicit `skipped` results and
85
+ exit successfully by default; `--require-all` exits 2 for any skip. A failed
86
+ check exits 1. Cursor may report that project MCP approval is required; approve
87
+ it through Cursor, then rerun rather than changing global state from the
88
+ script. Cleanup is separate and runs only with
89
+ `TOPLINE_CERTIFICATION_CLEANUP=1`.
90
+
91
+ CI's no-network self-test sets top-level `evidenceMode` to `simulated`; it is a
92
+ schema/control-flow gate and must never be presented as live client evidence.
93
+
94
+ A weekly and manually dispatchable GitHub canary runs one real Claude Code
95
+ read-only call against the inert `fixtures/certification-app` package. It pins
96
+ the client version, caps provider spend at USD 0.25, exposes only
97
+ `platform_inspect_artifact_app`, passes an allowlisted process environment, and
98
+ uploads the redacted JSON report for seven days. It requires the dedicated
99
+ `TOPLINE_CERTIFICATION_ANTHROPIC_API_KEY` repository secret and fails closed
100
+ when that credential is absent. It performs no Topline API write or customer
101
+ deployment.
102
+
103
+ Local validation and certification do not publish npm, deploy Topline, merge a
104
+ documentation pull request, or release to customers.
package/dist/index.d.ts CHANGED
@@ -30,11 +30,24 @@ export interface PackedArtifactAppBundle {
30
30
  excluded: string[];
31
31
  }
32
32
  type ToolProgressReporter = (progress: number, message: string) => void | Promise<void>;
33
- export declare const HARNESS_MCP_VERSION = "0.4.0";
33
+ export declare const DEFAULT_MCP_PROTOCOL_VERSION = "2025-11-25";
34
+ export declare const BUILD_MCP_SERVER_NAME = "topline-build-stdio";
35
+ export declare const HARNESS_MCP_VERSION = "0.5.1";
36
+ export declare const DEFAULT_OAUTH_SCOPES: readonly string[];
37
+ export interface BuildMcpSetupOption {
38
+ readonly flag: string;
39
+ readonly env: string;
40
+ readonly aliases?: readonly string[];
41
+ readonly required?: boolean;
42
+ readonly default?: string | number;
43
+ readonly allowed?: readonly string[];
44
+ readonly description: string;
45
+ }
46
+ export declare const BUILD_MCP_SETUP_OPTIONS: readonly BuildMcpSetupOption[];
34
47
  export declare function parseHarnessOptions(argv: string[], env?: Record<string, string | undefined>): HarnessMcpStdioOptions;
35
48
  export declare function runHarnessMcpStdioCli(): Promise<void>;
36
49
  export declare function cliInfo(argv: string[]): string | null;
37
- export declare function createHarnessMcpStdioServer(opts: HarnessMcpStdioOptions): McpServer;
50
+ export declare function createHarnessMcpStdioServer(opts: HarnessMcpStdioOptions, toolAllowlist?: readonly string[]): McpServer;
38
51
  export declare function callHarnessTool(opts: HarnessMcpStdioOptions, name: string, args: unknown, hooks?: {
39
52
  onProgress?: ToolProgressReporter;
40
53
  }): Promise<CallToolResult>;
@@ -54,6 +67,26 @@ export declare function deployArtifactApp(opts: HarnessMcpStdioOptions, input: R
54
67
  create: unknown;
55
68
  deploy: unknown;
56
69
  }>;
70
+ export declare function inspectArtifactApp(opts: HarnessMcpStdioOptions, input: Record<string, unknown>): Promise<{
71
+ ok: boolean;
72
+ packageReady: boolean;
73
+ serverManifestValidationRequired: boolean;
74
+ appDir: string;
75
+ platformAppDir: string;
76
+ manifest: {
77
+ id: string | null;
78
+ manifestVersion: number | null;
79
+ title: string | null;
80
+ kind: string | null;
81
+ };
82
+ bundle: {
83
+ fileCount: number;
84
+ byteCount: number;
85
+ sha256: string;
86
+ excluded: string[];
87
+ };
88
+ nextAction: string;
89
+ }>;
57
90
  export declare function waitForArtifactDeploy(opts: HarnessMcpStdioOptions, input: Record<string, unknown>, onProgress?: ToolProgressReporter): Promise<Record<string, unknown>>;
58
91
  export declare function initArtifactApp(opts: HarnessMcpStdioOptions, input: Record<string, unknown>): Promise<{
59
92
  ok: boolean;
@@ -129,6 +162,11 @@ export declare function storybookAccess(opts: HarnessMcpStdioOptions): {
129
162
  };
130
163
  export declare function packArtifactAppDirectory(appDir: string, archivePrefix?: string): Promise<PackedArtifactAppBundle>;
131
164
  export declare function listTools(): ListToolsResult;
165
+ export interface BuildMcpRecoveryGuidance {
166
+ readonly retryable: boolean;
167
+ readonly recoveryAction: string;
168
+ }
169
+ export declare const BUILD_MCP_RECOVERY_ERRORS: Readonly<Record<string, BuildMcpRecoveryGuidance>>;
132
170
  export declare function getBearerToken(opts: HarnessMcpStdioOptions): Promise<string>;
133
171
  export declare function browserOpenCommand(url: string, platform?: string): {
134
172
  command: string;