Skip to content

Commit c5361e2

Browse files
feat(connector-github): pin the two included MCP tools and record the listing provenance (#31647)
<!-- claude-projects-attribution: {"github_login":"os-steve"} --> _Requested by **Steve** · [project thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi99NHVBVyv4gRvhhpXs72Am2)_ Fixes #28647 Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:GitHub 连接器应用给它用到的两个 MCP 工具(`search_issues`、`issue_read`)各加了一个 sha256 锁定值,README 新增「Provenance」一节,写明上游地址、锁定值、谁在什么时候用什么 token 测的,以及上架清单 sha256 的算法和结果。 - 为什么改:按 #28590 的裁决 B,货架上的每个 MCP 应用都要锁定它包含的工具,清单的 sha256 就是这组锁定值的摘要;GitHub 以后改了工具定义,实例会降级并点名工具,而不是悄悄换行为。 - 风险与回滚:锁定值是 2026-11-06 维护者本机用权限较宽的 `gh` token 测的;如果只读 token 拿到的工具定义不同,连接器首次连接会降级并点名该工具(重测、换锁定值即可)。回滚就是 revert 本 PR。应用是私有包,不发 npm。 - 先看:`packages/apps/connector-github/src/connectors/github.connector.ts`(新增 `toolsSnapshot`)、`packages/apps/connector-github/README.md`(Provenance 一节)、`packages/apps/connector-github/test/listing.test.ts`(新的锁定值测试块)。 - 两分钟验证:`pnpm --filter @objectstack/connector-app-github test`,预期 2 个文件、18 个测试全绿,不访问 GitHub。 - 需要你做的:无,席位落地。 ## What changes - **`src/connectors/github.connector.ts`**: `providerConfig.toolsSnapshot` pins both included tools, with the digests posted on #30116 (comment 6691107153) verbatim: - `search_issues`: `443421e063c9330d4504a88b57def74d1f1e3d0793479068073630a1846eaeb0` - `issue_read`: `380e96f3d78b5c893668ab48a2d72191a3906bdc4e5e5c89f9e92c3e9de6c392` - **`README.md`**: a new `## Provenance` section, following the shape the Stripe and DocuSign apps use for their listing provenance (a README section; no manifest field carries provenance in this repository). It records `upstream` (the server URL), how `commit` is recorded (the repository commit the package is published from; a file cannot name the commit that contains it, so the publisher records it), the two pins, the measurement date (2026-11-06T17:27Z), who measured them (the maintainer, on their own machine), the token used (the maintainer's local `gh` CLI token, broader than read-only, as triage asked to record), the pin-set sha256 `e922e2420b05707fb3ec9df270009da30d57177c297a6d7c3ee0b4ccbbad7516`, and the exact recipe with a one-line `printf | sha256sum` that reproduces it. - **`test/fixtures/github-mcp-tools.json`** (new): the measurement's stdout from #30116, the two tool definitions included, so the pins are recomputed offline. - **`test/listing.test.ts`**: a new top-level `describe('connector-github tool pins')` in the existing listing harness. It fails when an included tool has no pin, a pin is not 64 lowercase hex, or a pin names a tool `include` leaves out; it recomputes both pins from the fixture with `computeMcpToolsSnapshot`; and it checks the README records the URL, each pin and the pin-set digest. No network call. - **`test/boot.test.ts`** (forced test edit): the fake MCP server now serves the measured definitions from the fixture instead of hand-written stand-ins. With the pins in place, the old stand-ins hash differently, so the instance would degrade with `CONNECTOR_UPSTREAM_CHANGED` and three boot tests would fail (measured below). The extra `issue_write` tool the app must not expose is kept. The pin-set digest recipe: serialize the `toolsSnapshot` record as JSON with keys sorted (UTF-16 code-unit order) and no whitespace, which for a record of strings is its RFC 8785 (JCS) form, then sha256 of the UTF-8 bytes, lowercase hex. The card names this `stableStringify`; no repository-wide `stableStringify` is exported (four private copies exist), so the README states the rules instead of a function name. No changeset: `@objectstack/connector-app-github` is `private: true`, so it publishes nothing; the PR carries `skip-changeset`. ## Tests - Step 0, offline recompute: `computeMcpToolsSnapshot` over the fixture's `tools` gives exactly the two posted digests (`search_issues MATCH`, `issue_read MATCH`), at `69244406`. - Base (`69244406`): `pnpm --filter @objectstack/connector-app-github test`: Test Files 2 passed, Tests 14 passed. - Head: the same command: Test Files 2 passed, Tests 18 passed; `typecheck` exit 0; `pnpm --filter @objectstack/connector-mcp test`: Test Files 9 passed, Tests 119 passed. - Ablations (each via `scripts/ablation-replace.mjs`, which restores and checks the blob; `git diff HEAD` empty after each): - Drop the `issue_read` pin: listing tests red, `expected [ 'issue_read: no pin' ] to deeply equal []`; 4 failed, 9 passed. - Malformed pin (the `search_issues` pin in uppercase hex): red, `expected [ Array(1) ] to deeply equal []`; 4 failed, 9 passed. - Boot fake back to the pre-pin stand-in definitions: 3 boot tests red, the instance `degraded` with `providerConfig.toolsSnapshot does not match the tools its MCP server serves: tool 'search_issues' changed …; tool 'issue_read' changed …`. This is the forced boot-test edit, measured. ## Acceptance notes - The pins were measured with the maintainer's local `gh` token, not a read-only one. If GitHub serves a read-only token different definitions for these two tools, the first connection degrades the instance naming the tool; re-measure with a read-only token and re-pin. Triage (6723942187) ruled that a follow-up, not a blocker. - The declaration above is measured, not copied: `toolsSnapshot` is an existing `providerConfig` key the `mcp` provider already reads; this PR adds data to it. The app's metadata format and the spec are unchanged. ## Verification All readings at head `9f1340c6`. - `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 50 commands; all 50 ran with exit 0. Reconciliation: `dispatch-gates --ran`: 50 derived, 50 run, 0 NOT-MEASURED, 0 UNRUN (exit 0). - Two of them first exited 3 on container prerequisites, not on the diff, and were green on rerun: `check-plugin-teardown-shape --self-test` (its pinned fixture commit was outside the shallow clone; fetched it), and `check:dual-build-cjs-loads` (needs every package's `dist/`; ran a full `pnpm build` under the verify lock, exit 0). - `pnpm exec eslint --no-inline-config packages/apps/connector-github` (the package has no lint script; root eslint on the directory): exit 0. - Full dogfood: not run, since the title has no `!` and there is no narrowing arm. <details><summary>Derived gate list (50, all exit 0)</summary> ```text node scripts/check-closing-keyword-parity.mjs (+ --self-test) node scripts/check-comment-mask-adoption.mjs (+ --self-test) node scripts/check-comment-mask-corpus.mjs node scripts/check-dts-emitted.mjs --self-test node scripts/check-issue-citations.mjs node scripts/check-plugin-teardown-shape.mjs (+ --self-test) node scripts/ci/assert-turbo-remote-cache.mjs --self-test node scripts/ci/plan-test-core-shards.mjs --self-test node scripts/ci/prune-turbo-cache.mjs --self-test node scripts/docs-audit/check-affected-docs.mjs node scripts/docs-audit/check-drift-comment.mjs pnpm --filter @objectstack/spec run check:duration-unit-keys pnpm --filter @objectstack/spec run check:template-manifests pnpm check:ci-filter-parity, closed-ceremony-text, cross-package-test-inputs, doc-authoring, driver-memory-census, dts-closure, dual-build-cjs-loads, engine-double-contract, gitlink-declared, issue-citations, keyed-text-bounds, lean-entry-closure, logger-receiver-detach, nul-bytes, objectql-double-limit, org-identifier, page-declaration-shape, platform-object-tenancy-census, published-files, query-options-erasure, refd-timer-probe, registry-log-declared, rest-log-spy-declared, slot-lookup, sourcemap-no-sources-content, system-context-census, test-source-alias, tier-file-adoption, type-check-coverage, type-check-debt, undeclared-dep-imports, vouch-for-reference-callers, watch-hint-literal, where-matcher ``` </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01ADHkmQCkyoaDHDp37j8kV2)_ Co-authored-by: Claude <noreply@anthropic.com>
1 parent 737b160 commit c5361e2

5 files changed

Lines changed: 356 additions & 11 deletions

File tree

‎packages/apps/connector-github/README.md‎

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,3 +68,60 @@ later node.
6868
and the connector allowlists two of them.
6969
- The token is a static personal token. Signing in with GitHub (OAuth) is not
7070
offered.
71+
72+
## Provenance
73+
74+
This app packages no vendor document: its upstream is GitHub's MCP server
75+
itself, and what it pins is the definition of each tool it includes. The
76+
listing's three provenance fields are:
77+
78+
- **upstream**: `https://api.githubcopilot.com/mcp/`, the server the
79+
`github_mcp` connector dials, with `X-MCP-Readonly: true`.
80+
- **commit**: the commit of this repository (`objectstack-ai/objectstack`)
81+
the package is published from. A file cannot name the commit that contains
82+
it, so the publisher records it.
83+
- **sha256**: the digest of the pin set below, pin-set sha256
84+
`e922e2420b05707fb3ec9df270009da30d57177c297a6d7c3ee0b4ccbbad7516`.
85+
86+
The connector's `providerConfig.toolsSnapshot` pins both included tools. Each
87+
pin is the sha256, in lowercase hex, of the tool's `{ name, description,
88+
inputSchema }` from the server's `tools/list` answer, written as canonical JSON
89+
(the `mcpToolDigest` recipe of `@objectstack/connector-mcp`):
90+
91+
| Tool | Pin |
92+
|:---|:---|
93+
| `search_issues` | `443421e063c9330d4504a88b57def74d1f1e3d0793479068073630a1846eaeb0` |
94+
| `issue_read` | `380e96f3d78b5c893668ab48a2d72191a3906bdc4e5e5c89f9e92c3e9de6c392` |
95+
96+
The maintainer measured them on 2026-11-06 at 17:27 UTC, on their own machine,
97+
by calling `initialize` and `tools/list` on the server with
98+
`X-MCP-Readonly: true` (the script and its full output are in
99+
[objectstack-ai/objectstack#30116](https://github.com/objectstack-ai/objectstack/issues/30116#issuecomment-6691107153)).
100+
The token was the maintainer's local GitHub CLI token, which carries broader
101+
scopes than this app needs, not a token made read-only for the run. GitHub's
102+
server can serve a different tool set to a token with other scopes, so if a
103+
read-only token is served different definitions, the connector says so on its
104+
first connection (below). The tool definitions that output carried are
105+
`test/fixtures/github-mcp-tools.json`; the package's tests recompute both pins
106+
from them and fail when a pin, this record or the fixture disagree, with no
107+
call to GitHub.
108+
109+
**The pin-set digest**, for anyone who recomputes it, such as the
110+
marketplace's ingestion: serialize the `toolsSnapshot` record as JSON with its
111+
keys sorted (UTF-16 code-unit order, as JavaScript's default sort) and no
112+
whitespace, which for a record of strings is its RFC 8785 (JCS) form; then
113+
take the sha256 of those UTF-8 bytes, in lowercase hex. For the pins above:
114+
115+
```bash
116+
printf '%s' '{"issue_read":"380e96f3d78b5c893668ab48a2d72191a3906bdc4e5e5c89f9e92c3e9de6c392","search_issues":"443421e063c9330d4504a88b57def74d1f1e3d0793479068073630a1846eaeb0"}' | sha256sum
117+
# e922e2420b05707fb3ec9df270009da30d57177c297a6d7c3ee0b4ccbbad7516 -
118+
```
119+
120+
**When GitHub changes a tool.** On every connection the connector hashes the
121+
tools the server lists and compares them with the pins. A pinned tool the
122+
server serves with a different description or input schema leaves
123+
`github_mcp` degraded with `CONNECTOR_UPSTREAM_CHANGED`, naming the tool. (A
124+
pinned tool the server no longer lists takes the path under Credentials
125+
instead, since a token's scopes can hide a tool too.) A changed tool is the
126+
signal to measure again, update the pins, this section and the fixture in the
127+
same change, and publish again. Never drop a pin to clear it.

‎packages/apps/connector-github/src/connectors/github.connector.ts‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ import { defineConnector } from '@objectstack/spec/integration';
2121
* `include` narrows those to the two this app's flows call. An `include`
2222
* entry the server does not list is refused at materialization, never
2323
* silently dropped.
24+
*
25+
* `toolsSnapshot` pins every included tool (ruling 6556740185, letter B: an
26+
* MCP app on the shelf ships one pin per tool it includes, and its listing's
27+
* sha256 is the digest of this pin set). Each value is `mcpToolDigest` of the
28+
* tool as GitHub's server listed it, measured on 2026-11-06; the README's
29+
* Provenance section records who measured them, with what token, and the
30+
* pin-set digest. A server that rewrites or stops serving a pinned tool
31+
* degrades the instance with `CONNECTOR_UPSTREAM_CHANGED`: that is the signal
32+
* to re-measure, re-pin and re-publish, never to drop the pin.
2433
*/
2534
export const GitHubMcpConnector = defineConnector({
2635
name: 'github_mcp',
@@ -37,6 +46,10 @@ export const GitHubMcpConnector = defineConnector({
3746
headers: { 'X-MCP-Readonly': 'true' },
3847
},
3948
include: ['search_issues', 'issue_read'],
49+
toolsSnapshot: {
50+
search_issues: '443421e063c9330d4504a88b57def74d1f1e3d0793479068073630a1846eaeb0',
51+
issue_read: '380e96f3d78b5c893668ab48a2d72191a3906bdc4e5e5c89f9e92c3e9de6c392',
52+
},
4053
},
4154
auth: { type: 'bearer', credentialRef: 'GITHUB_MCP_TOKEN' },
4255
});

‎packages/apps/connector-github/test/boot.test.ts‎

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
*/
1616

1717
import { describe, it, expect, beforeAll, afterAll } from 'vitest';
18+
import { readFileSync } from 'node:fs';
1819
import { fileURLToPath } from 'node:url';
1920
// Paid at module load, before vitest's clocked windows: both reach the whole
2021
// runtime through their `dist/` builds.
@@ -26,18 +27,17 @@ const APP_ROOT = fileURLToPath(new URL('..', import.meta.url));
2627
const REF = 'GITHUB_MCP_TOKEN';
2728
const FIXTURE_TOKEN = 'github_pat_fixture_not_a_real_token';
2829

29-
/** The tools the fake server lists: the two the app includes, and one it must not expose. */
30+
/**
31+
* The tools the fake server lists: the two the app includes, served exactly as
32+
* GitHub's server listed them when the app's `toolsSnapshot` was measured (the
33+
* fixture the README's Provenance names), so the pin check passes the way it
34+
* does against the real server; and one tool the app must not expose.
35+
*/
36+
const MEASURED = JSON.parse(
37+
readFileSync(new URL('./fixtures/github-mcp-tools.json', import.meta.url), 'utf8'),
38+
) as { tools: Array<{ name: string; description?: string; inputSchema: Record<string, unknown> }> };
3039
const TOOLS = [
31-
{ name: 'search_issues', description: 'Search issues', inputSchema: { type: 'object', properties: { query: { type: 'string' } }, required: ['query'] } },
32-
{
33-
name: 'issue_read',
34-
description: 'Get issue details',
35-
inputSchema: {
36-
type: 'object',
37-
properties: { method: { type: 'string' }, owner: { type: 'string' }, repo: { type: 'string' }, issue_number: { type: 'number' } },
38-
required: ['method', 'owner', 'repo', 'issue_number'],
39-
},
40-
},
40+
...MEASURED.tools,
4141
{ name: 'issue_write', description: 'Create or update issue', inputSchema: { type: 'object', properties: {} } },
4242
];
4343

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
{
2+
"measuredAt": "2026-11-06T17:27:01.144Z",
3+
"url": "https://api.githubcopilot.com/mcp/",
4+
"headers": {
5+
"X-MCP-Readonly": "true"
6+
},
7+
"toolsSnapshot": {
8+
"search_issues": "443421e063c9330d4504a88b57def74d1f1e3d0793479068073630a1846eaeb0",
9+
"issue_read": "380e96f3d78b5c893668ab48a2d72191a3906bdc4e5e5c89f9e92c3e9de6c392"
10+
},
11+
"tools": [
12+
{
13+
"name": "search_issues",
14+
"description": "Search issues using natural-language semantic matching. Best for conceptual or paraphrased queries (e.g. \"login fails after password reset\"). Already scoped to is:issue.",
15+
"inputSchema": {
16+
"type": "object",
17+
"properties": {
18+
"fields": {
19+
"type": "array",
20+
"items": {
21+
"type": "string",
22+
"enum": [
23+
"number",
24+
"title",
25+
"body",
26+
"state",
27+
"state_reason",
28+
"draft",
29+
"locked",
30+
"html_url",
31+
"user",
32+
"author_association",
33+
"labels",
34+
"assignee",
35+
"assignees",
36+
"milestone",
37+
"comments",
38+
"reactions",
39+
"created_at",
40+
"updated_at",
41+
"closed_at",
42+
"closed_by",
43+
"type",
44+
"repository_url",
45+
"pull_request",
46+
"field_values"
47+
]
48+
},
49+
"description": "Subset of fields to return for each issue result. If omitted, all fields are returned. Use this to reduce response size when you only need specific fields; omitting 'body', 'reactions', and 'labels' in particular drops the largest per-result data."
50+
},
51+
"order": {
52+
"type": "string",
53+
"description": "Sort order",
54+
"enum": [
55+
"asc",
56+
"desc"
57+
]
58+
},
59+
"owner": {
60+
"type": "string",
61+
"description": "Optional repository owner. If provided with repo, only issues for this repository are listed.",
62+
"x-mcp-header": "owner"
63+
},
64+
"page": {
65+
"type": "number",
66+
"description": "Page number for pagination (min 1)",
67+
"minimum": 1
68+
},
69+
"perPage": {
70+
"type": "number",
71+
"description": "Results per page for pagination (min 1, max 100)",
72+
"minimum": 1,
73+
"maximum": 100
74+
},
75+
"query": {
76+
"type": "string",
77+
"description": "The search query, as natural language. When the user gives alternative wordings, include them as plain words rather than joining them with OR."
78+
},
79+
"repo": {
80+
"type": "string",
81+
"description": "Optional repository name. If provided with owner, only issues for this repository are listed.",
82+
"x-mcp-header": "repo"
83+
},
84+
"sort": {
85+
"type": "string",
86+
"description": "Sort field by number of matches of categories, defaults to best match",
87+
"enum": [
88+
"comments",
89+
"reactions",
90+
"reactions-+1",
91+
"reactions--1",
92+
"reactions-smile",
93+
"reactions-thinking_face",
94+
"reactions-heart",
95+
"reactions-tada",
96+
"interactions",
97+
"created",
98+
"updated"
99+
]
100+
}
101+
},
102+
"required": [
103+
"query"
104+
]
105+
}
106+
},
107+
{
108+
"name": "issue_read",
109+
"description": "Get information about a specific issue in a GitHub repository.",
110+
"inputSchema": {
111+
"type": "object",
112+
"properties": {
113+
"issue_number": {
114+
"type": "number",
115+
"description": "The number of the issue"
116+
},
117+
"method": {
118+
"type": "string",
119+
"description": "The read operation to perform on a single issue.\nOptions are:\n1. get - Get issue details. Also returns best-effort hierarchy flags (`has_parent`, `has_children`); `parent` and `sub_issues_summary` are optional relationship summaries, and `closed_by_pull_requests` summarizes the pull requests configured to close the issue as `total_count` plus up to 5 `references`.\n2. get_comments - Get issue comments.\n3. get_sub_issues - Get sub-issues (children) of the issue.\n4. get_parent - Get the parent issue, if this issue is a sub-issue of another.\n5. get_labels - Get labels assigned to the issue.\n",
120+
"enum": [
121+
"get",
122+
"get_comments",
123+
"get_sub_issues",
124+
"get_parent",
125+
"get_labels"
126+
]
127+
},
128+
"owner": {
129+
"type": "string",
130+
"description": "The owner of the repository",
131+
"x-mcp-header": "owner"
132+
},
133+
"page": {
134+
"type": "number",
135+
"description": "Page number for pagination (min 1)",
136+
"minimum": 1
137+
},
138+
"perPage": {
139+
"type": "number",
140+
"description": "Results per page for pagination (min 1, max 100)",
141+
"minimum": 1,
142+
"maximum": 100
143+
},
144+
"repo": {
145+
"type": "string",
146+
"description": "The name of the repository",
147+
"x-mcp-header": "repo"
148+
}
149+
},
150+
"required": [
151+
"method",
152+
"owner",
153+
"repo",
154+
"issue_number"
155+
]
156+
}
157+
}
158+
]
159+
}

0 commit comments

Comments
 (0)