@comforge/mcp 0.4.0 → 0.6.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/README.md CHANGED
@@ -68,7 +68,9 @@ Results are versioned and bounded (about 48,000 characters), paginated with `cur
68
68
  | `registerComforgeTools` | `@comforge/mcp` | The native tools on an application's existing `McpServer`, next to its own tools (unreleased) |
69
69
  | `createEngineeringHost`, `sqliteOperationStore`, `fetchTransport` | `@comforge/mcp/host` | The same engineering services for an application's own server |
70
70
 
71
- Composition: `registerComforgeTools(server, options)` registers exactly the tools `createComforgeMcpServer` would, with the same schemas and handlers, onto a server you already have. A name the server already holds is refused before anything is registered; comforge never renames a tool. Checkout-free repositories (`remoteRepositories`) serve evidence reads, and with `remote.governance` also `comforge_publish_specification`, `comforge_publish_review` and `comforge_publish_comment`, under the host's per-command write credential, durable operation store and authorization (operator-mode repositories only; owner-grant repositories need a checkout).
71
+ Composition: `registerComforgeTools(server, options)` registers exactly the tools `createComforgeMcpServer` would, with the same schemas and handlers, onto a server you already have. A name the server already holds is refused before anything is registered; comforge never renames a tool. Checkout-free repositories (`remoteRepositories`) serve evidence reads, and with `remote.governance` also `comforge_publish_specification`, `comforge_publish_review` and `comforge_publish_comment`, under the host's per-command write credential, durable operation store and authorization (operator-mode repositories only; owner-grant repositories need a checkout). A host can limit a repository's publications with `governance(...).commands`; a command outside it is refused as `operation-not-served`, and `comforge_capabilities` lists only those per repository.
72
+
73
+ Reads report GitHub's refusal of the server's own read credential as `credential-rejected` (401) or `credential-forbidden` (403), never as `unauthorized`, which is a write's authorization refusal. `comforge_pr` with `include: ["checks"]` returns an explicit aggregate over the head commit's check runs: `state` (`passing`, `failing`, `pending`, `neutral`, `none`), `ok` (`state === "passing"`), per-conclusion `counts`, and `required: {evaluated: false}`, because commit statuses and required checks are not read. A `passing` state is what the observed check runs say, never merge readiness: it does not mean branch protection, required checks or commit statuses are satisfied.
72
74
 
73
75
  Credentials stay server-owned and are never returned. Writes are authorized by the repository's trusted configuration in `@comforge/cli` (an owner-signed grant or operator mode), never by the server or a tool input. Over HTTP, tools that run repository commands are neither listed nor callable unless the host supplies an `IsolationProvider`.
74
76
 
package/dist/host.d.ts CHANGED
@@ -112,6 +112,17 @@ export interface RemoteGovernanceHost {
112
112
  authorize(request: RemoteAuthorizationRequest): RemoteAuthorizationDecision | Promise<RemoteAuthorizationDecision>;
113
113
  /** The writer's correlation-marker namespace; default the configuration's `security.markerNamespace`. */
114
114
  markerNamespace?: string;
115
+ /**
116
+ * The login the credential for `command` acts as (0.4.1), or undefined to read it from GitHub.
117
+ * Required for a GitHub App installation token, which cannot read `GET /user`.
118
+ */
119
+ identity?(command: RemoteGovernanceCommand): string | undefined;
120
+ /**
121
+ * The publications this host serves for this repository (0.6.0); undefined serves every command
122
+ * the principal's profiles reach. A command outside the list is refused before any read or
123
+ * authorization (`operation-not-served`), and `comforge_capabilities` lists only these.
124
+ */
125
+ commands?: readonly RemoteGovernanceCommand[];
115
126
  }
116
127
  export interface RemoteHost {
117
128
  trustedConfig(binding: RemoteRepositoryBinding): TrustedConfigSnapshot | Promise<TrustedConfigSnapshot>;
package/dist/results.d.ts CHANGED
@@ -37,6 +37,9 @@ export declare const MCP_CODES: {
37
37
  readonly "config-missing": "the host supplied no trusted configuration for this repository";
38
38
  readonly "config-stale": "the host's trusted configuration snapshot is older than allowed";
39
39
  readonly "config-mismatch": "the configuration is not the pinned one, or not what GitHub holds at its revision";
40
+ readonly "credential-rejected": "GitHub did not accept the server's read credential (401)";
41
+ readonly "credential-forbidden": "GitHub refused this read for the server's credential (403): it lacks the permission or repository access";
42
+ readonly "operation-not-served": "the host does not serve this governed publication for this repository";
40
43
  };
41
44
  /** Replaces every value a caller must never see: the call's credentials and secret-like text. */
42
45
  export declare function redact(value: unknown, secrets: readonly string[]): unknown;
package/dist/results.js CHANGED
@@ -33,6 +33,9 @@ export const MCP_CODES = {
33
33
  "config-missing": "the host supplied no trusted configuration for this repository",
34
34
  "config-stale": "the host's trusted configuration snapshot is older than allowed",
35
35
  "config-mismatch": "the configuration is not the pinned one, or not what GitHub holds at its revision",
36
+ "credential-rejected": "GitHub did not accept the server's read credential (401)",
37
+ "credential-forbidden": "GitHub refused this read for the server's credential (403): it lacks the permission or repository access",
38
+ "operation-not-served": "the host does not serve this governed publication for this repository",
36
39
  };
37
40
  const HINTS = {
38
41
  "authorization-required": "the trusted configuration has no security.authorization; that is an owner decision",
@@ -49,6 +52,9 @@ const HINTS = {
49
52
  "unknown-repository": "comforge_capabilities lists the repositories you may use",
50
53
  "checkout-required": "use a local stdio server bound to a checkout of this repository",
51
54
  "config-stale": "the host refreshes its snapshot; retry later",
55
+ "credential-rejected": "the server's own read credential is invalid or expired; the server owner replaces it. No grant changes this",
56
+ "credential-forbidden": "the server's own read credential lacks this read's GitHub permission (for example Checks: read on a private repository); the server owner widens that credential's read permissions. No grant or write authorization changes this",
57
+ "operation-not-served": "comforge_capabilities lists the governed publications per repository",
52
58
  };
53
59
  /** Retrying the same call can help only for transient failures, never for a refusal. */
54
60
  const RETRYABLE = new Set(["git-failed", "github-failed", "io", "ledger"]);
package/dist/tools.d.ts CHANGED
@@ -17,7 +17,7 @@ export declare const SERVER_NAME = "comforge-mcp";
17
17
  * Reported as `serverInfo.version`. A literal on purpose: a bundler cannot resolve a runtime
18
18
  * read of package.json. test/version.test.ts fails when it differs from package.json.
19
19
  */
20
- export declare const SERVER_VERSION = "0.4.0";
20
+ export declare const SERVER_VERSION = "0.6.0";
21
21
  export interface CallContext {
22
22
  principal: Principal;
23
23
  binding: RepositoryBinding | null;
@@ -54,6 +54,41 @@ export declare const REMOTE_READ_TOOLS: readonly ToolName[];
54
54
  * read back exactly as with a checkout.
55
55
  */
56
56
  export declare const REMOTE_GOVERNANCE_TOOLS: readonly ToolName[];
57
+ /**
58
+ * The check runs of one head commit as an explicit aggregate (0.6.0). Until 0.5.0 `ok` was the
59
+ * required-check result with no required list, so it was false for every pull request.
60
+ *
61
+ * - `state`: `failing` when any completed run concluded outside success/skipped/neutral (failure,
62
+ * cancelled, timed_out, action_required, stale, startup_failure or an unknown conclusion);
63
+ * else `pending` when any run is not completed; else `passing` when at least one run succeeded;
64
+ * else `neutral` (every run skipped or neutral); `none` when the commit has no check run.
65
+ * - `ok` is `state === "passing"`.
66
+ * - Only check runs are read. Commit statuses and the repository's required checks are not, so
67
+ * `required` says so instead of implying they passed.
68
+ */
69
+ export declare function summarizeChecks(runs: readonly {
70
+ name: string;
71
+ status: string;
72
+ conclusion: string | null;
73
+ }[]): {
74
+ ok: boolean;
75
+ state: string;
76
+ total: number;
77
+ counts: {
78
+ passed: number;
79
+ skipped: number;
80
+ neutral: number;
81
+ failing: number;
82
+ pending: number;
83
+ };
84
+ failing: string[];
85
+ pending: string[];
86
+ sources: string[];
87
+ required: {
88
+ evaluated: boolean;
89
+ reason: string;
90
+ };
91
+ };
57
92
  export declare const HANDLERS: {
58
93
  [N in ToolName]: (c: CallContext, input: Input<N>) => Promise<HandlerOutcome>;
59
94
  };
package/dist/tools.js CHANGED
@@ -19,7 +19,7 @@ export const SERVER_NAME = "comforge-mcp";
19
19
  * Reported as `serverInfo.version`. A literal on purpose: a bundler cannot resolve a runtime
20
20
  * read of package.json. test/version.test.ts fails when it differs from package.json.
21
21
  */
22
- export const SERVER_VERSION = "0.4.0";
22
+ export const SERVER_VERSION = "0.6.0";
23
23
  /** The host's credential provider, wrapped so every value it hands out is redacted later. */
24
24
  function credentialsFor(c) {
25
25
  const provider = c.binding ? c.host.credentials?.(c.binding, c.principal) : undefined;
@@ -179,6 +179,8 @@ async function remoteGovernance(c, tool) {
179
179
  const governance = host.governance?.(binding, c.principal);
180
180
  if (!governance)
181
181
  throw new ToolRefusal("checkout-required", `${tool} needs a repository checkout or host governance; ${binding.id} is served for reads only`, 1, { repository: binding.id });
182
+ if (governance.commands !== undefined && !governance.commands.includes(command))
183
+ throw new ToolRefusal("operation-not-served", `${command} is not a governed publication this server serves for ${binding.id}`, 1, { repository: binding.id, command });
182
184
  const { config } = await evidence(c);
183
185
  const token = governance.credentials(command);
184
186
  if (!token)
@@ -194,6 +196,7 @@ async function remoteGovernance(c, tool) {
194
196
  ...(host.fetchImpl ? { fetchImpl: host.fetchImpl } : {}),
195
197
  signal: c.signal,
196
198
  ...(governance.markerNamespace ? { markerNamespace: governance.markerNamespace } : {}),
199
+ ...((identity) => (identity !== undefined ? { identity } : {}))(governance.identity?.(command)),
197
200
  });
198
201
  }
199
202
  /** A checkout-free publication takes no grant: the host authorizes it (owner-grant repositories refuse). */
@@ -201,16 +204,72 @@ function noRemoteGrant(c, grant) {
201
204
  if (c.remote && grant !== undefined)
202
205
  throw new ToolRefusal("usage", "a grant is accepted only by a checkout-backed server; this repository is served without one");
203
206
  }
204
- /** GitHub adapter refusals as the CLI's codes; anything else is rethrown as internal. */
207
+ /** Check-run conclusions that never block: GitHub treats them as passing for required checks. */
208
+ const NON_BLOCKING = new Set(["success", "skipped", "neutral"]);
209
+ /**
210
+ * The check runs of one head commit as an explicit aggregate (0.6.0). Until 0.5.0 `ok` was the
211
+ * required-check result with no required list, so it was false for every pull request.
212
+ *
213
+ * - `state`: `failing` when any completed run concluded outside success/skipped/neutral (failure,
214
+ * cancelled, timed_out, action_required, stale, startup_failure or an unknown conclusion);
215
+ * else `pending` when any run is not completed; else `passing` when at least one run succeeded;
216
+ * else `neutral` (every run skipped or neutral); `none` when the commit has no check run.
217
+ * - `ok` is `state === "passing"`.
218
+ * - Only check runs are read. Commit statuses and the repository's required checks are not, so
219
+ * `required` says so instead of implying they passed.
220
+ */
221
+ export function summarizeChecks(runs) {
222
+ const completed = runs.filter((r) => r.status === "completed");
223
+ const failing = completed.filter((r) => !NON_BLOCKING.has(r.conclusion ?? "")).map((r) => r.name);
224
+ const pending = runs.filter((r) => r.status !== "completed").map((r) => r.name);
225
+ const count = (conclusion) => completed.filter((r) => r.conclusion === conclusion).length;
226
+ const passed = count("success");
227
+ const state = runs.length === 0
228
+ ? "none"
229
+ : failing.length > 0
230
+ ? "failing"
231
+ : pending.length > 0
232
+ ? "pending"
233
+ : passed > 0
234
+ ? "passing"
235
+ : "neutral";
236
+ return {
237
+ ok: state === "passing",
238
+ state,
239
+ total: runs.length,
240
+ counts: {
241
+ passed,
242
+ skipped: count("skipped"),
243
+ neutral: count("neutral"),
244
+ failing: failing.length,
245
+ pending: pending.length,
246
+ },
247
+ failing,
248
+ pending,
249
+ sources: ["check-runs"],
250
+ required: {
251
+ evaluated: false,
252
+ reason: "required checks and commit statuses are not read; state covers check runs only and is not merge readiness",
253
+ },
254
+ };
255
+ }
256
+ /**
257
+ * GitHub adapter refusals of a read as the server's codes; anything else is rethrown as internal.
258
+ * Every caller is a read, so a 401 or 403 is the server's own read credential being refused
259
+ * (0.6.0): `credential-rejected` / `credential-forbidden`, never `unauthorized`, which names an
260
+ * authorization (grant or host policy) refusal of a write and would point the caller at a grant.
261
+ */
205
262
  function githubRefusal(error) {
206
263
  if (error instanceof GitHubAdapterError) {
207
264
  const code = error.code === "not-found"
208
265
  ? "not-found"
209
- : error.code === "unauthorized" || error.code === "forbidden"
210
- ? "unauthorized"
211
- : error.code === "stale"
212
- ? "stale"
213
- : "github-failed";
266
+ : error.code === "unauthorized"
267
+ ? "credential-rejected"
268
+ : error.code === "forbidden"
269
+ ? "credential-forbidden"
270
+ : error.code === "stale"
271
+ ? "stale"
272
+ : "github-failed";
214
273
  throw new ToolRefusal(code, error.message.slice(0, 300), code === "github-failed" ? 3 : 1, {
215
274
  github: error.code,
216
275
  ...(typeof error.detail.status === "number" ? { status: error.detail.status } : {}),
@@ -255,9 +314,11 @@ export const HANDLERS = {
255
314
  .filter((b) => allowed.includes(b.id))
256
315
  .map((b) => ({
257
316
  repository: b.id,
258
- tools: c.remoteHost?.governance?.(b, c.principal)
259
- ? REMOTE_GOVERNANCE_TOOLS.filter((t) => c.server.tools.includes(t))
260
- : [],
317
+ tools: ((g) => g
318
+ ? REMOTE_GOVERNANCE_TOOLS.filter((t) => c.server.tools.includes(t) &&
319
+ (g.commands === undefined ||
320
+ g.commands.includes(GOVERNANCE_COMMAND[t])))
321
+ : [])(c.remoteHost?.governance?.(b, c.principal)),
261
322
  })),
262
323
  },
263
324
  }
@@ -415,17 +476,8 @@ export const HANDLERS = {
415
476
  },
416
477
  };
417
478
  let page;
418
- if (include.has("checks")) {
419
- const checks = await reads.getChecks(pr.head.sha);
420
- data.checks = {
421
- ok: checks.ok,
422
- total: checks.checks.length,
423
- failing: checks.checks
424
- .filter((x) => x.conclusion && !["success", "skipped", "neutral"].includes(x.conclusion))
425
- .map((x) => x.name),
426
- pending: checks.checks.filter((x) => x.status !== "completed").map((x) => x.name),
427
- };
428
- }
479
+ if (include.has("checks"))
480
+ data.checks = summarizeChecks((await reads.getChecks(pr.head.sha)).checks);
429
481
  if (include.has("files")) {
430
482
  const files = await reads.listPullRequestFiles(pr.number, pr.head.sha, detail ? { patches: true } : {});
431
483
  const p = paginate(files.files, input.cursor, input.pageSize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@comforge/mcp",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "description": "comforge-mcp: the governed agent lifecycle of @comforge/cli as a Model Context Protocol server. Intent-oriented tools over the published lifecycle services, capability profiles, a repository allowlist, server-owned credentials, stdio and Streamable HTTP. Remote execution is off unless the host supplies isolation. Never merges, deploys, approves or closes.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -29,7 +29,7 @@
29
29
  "./package.json": "./package.json"
30
30
  },
31
31
  "dependencies": {
32
- "@comforge/cli": "0.6.0",
32
+ "@comforge/cli": "0.7.0",
33
33
  "@comforge/core": "0.2.0",
34
34
  "@comforge/github": "0.6.0",
35
35
  "@comforge/ledger": "0.1.0",