Skip to content

Commit b2acd87

Browse files
committed
Merge upstream main into fix/2578-refresh-resource-param
2 parents f0a907a + 77001c9 commit b2acd87

803 files changed

Lines changed: 24895 additions & 8499 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.claude/skills/test-quality/SKILL.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ where one exists; a rule with no stated why is a convention — follow it anyway
107107
silently become load-bearing.
108108
- Comments live next to the line they explain, not in docstrings; single backticks for code
109109
refs; match the surrounding comment density (one-liners next to one-liners). No
110-
`from __future__ import annotations` (py310+ repo).
110+
`from __future__ import annotations` (py311+ repo).
111111
- Test work doesn't change `src/` as a side effect — the one mechanical exception is deleting a
112112
pragma a new test now covers. If a test can't be written without a library change, raise it
113113
as a finding or defer the test; don't quietly edit `src/`.

‎.github/actions/conformance/client.py‎

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
json-schema-ref-no-deref - Connect, list tools (no $ref deref)
2121
json-schema-2020-12-preservation - List tools, echo the focal inputSchema back verbatim
2222
request-metadata - Connect with all callbacks; client stamps _meta
23-
http-standard-headers - Connect, call a tool (Mcp-* headers checked)
23+
http-standard-headers - Tool, resource and prompt round-trips (Mcp-* headers checked)
2424
http-invalid-tool-headers - List tools, call every surfaced tool (x-mcp-header filter)
2525
http-custom-headers - Replay the harness's toolCalls (x-mcp-header -> Mcp-Param-*)
2626
elicitation-sep1034-client-defaults - Elicitation with default accept callback
@@ -311,11 +311,24 @@ async def run_request_metadata(server_url: str) -> None:
311311

312312
@register("http-standard-headers")
313313
async def run_http_standard_headers(server_url: str) -> None:
314-
"""Connect on the modern path so Mcp-Method / Mcp-Name / MCP-Protocol-Version are sent (SEP-2243)."""
314+
"""Touch tools, resources and prompts on the modern path so each standard header is checked (SEP-2243).
315+
316+
The scenario inspects Mcp-Method on each request and Mcp-Name on tools/call,
317+
resources/read and prompts/get, and reports methods the client never sent as
318+
SKIPPED rather than failed, so exercise one of each. initialize and
319+
notifications/initialized stay SKIPPED: the modern path discovers via
320+
server/discover and never sends them.
321+
"""
315322
async with Client(server_url, mode=client_mode()) as client:
316-
await client.list_tools()
317-
result = await client.call_tool("add_numbers", {"a": 5, "b": 3})
318-
logger.debug(f"add_numbers result: {result}")
323+
tools = await client.list_tools()
324+
if tools.tools:
325+
await client.call_tool(tools.tools[0].name, _stub_required_args(tools.tools[0].input_schema))
326+
resources = await client.list_resources()
327+
if resources.resources:
328+
await client.read_resource(resources.resources[0].uri)
329+
prompts = await client.list_prompts()
330+
if prompts.prompts:
331+
await client.get_prompt(prompts.prompts[0].name)
319332

320333

321334
def _stub_required_args(input_schema: dict[str, Any]) -> dict[str, Any]:

‎.github/dependabot.yml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ updates:
1010
python-packages:
1111
patterns:
1212
- "*"
13+
python-security:
14+
applies-to: security-updates
15+
patterns:
16+
- "*"
1317
- package-ecosystem: "github-actions"
1418
directory: "/"
1519
schedule:

‎.github/scripts/docs_preview.js‎

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
// Docs preview gate and PR comment. .github/workflows/docs-preview.yml wires
2+
// these up: `authorize` decides whether a run may build and deploy a preview
3+
// (and for which commit), `comment` reports the outcome on the pull request.
4+
// The security model is described in the workflow's header.
5+
'use strict';
6+
7+
const MARKER = '<!-- docs-preview -->';
8+
const BOT_LOGIN = 'github-actions[bot]';
9+
10+
// Sets the job outputs `authorized`, `pr_number`, `head_sha` and
11+
// `slash_attempt` for a pull_request_target or /preview-docs issue_comment run.
12+
async function authorize({ github, context, core }) {
13+
const { owner, repo } = context.repo;
14+
15+
async function permissionFor(username) {
16+
const { data } = await github.rest.repos.getCollaboratorPermissionLevel({ owner, repo, username });
17+
return { level: data.permission, role: data.role_name };
18+
}
19+
20+
let authorized = false;
21+
let prNumber = '';
22+
let headSha = '';
23+
let slashAttempt = false;
24+
25+
if (context.eventName === 'pull_request_target') {
26+
const pr = context.payload.pull_request;
27+
prNumber = String(pr.number);
28+
headSha = pr.head.sha;
29+
// No automatic preview for fork PRs: actions/checkout refuses to fetch a
30+
// fork's head in a pull_request_target run. A maintainer can still request
31+
// one with /preview-docs. (head.repo is null once the fork is deleted.)
32+
const headRepo = pr.head.repo;
33+
if (!headRepo || headRepo.id !== context.payload.repository.id) {
34+
core.info(`PR #${prNumber} head is on ${headRepo ? headRepo.full_name : 'a deleted fork'}; fork PRs are previewed via /preview-docs only.`);
35+
} else {
36+
// Gate on the *sender* (whoever caused this run — on synchronize that
37+
// is the pusher), not the PR author, so a non-admin pushing to an
38+
// admin-opened branch does not get an automatic build.
39+
const actor = context.payload.sender.login;
40+
const perm = await permissionFor(actor);
41+
authorized = perm.level === 'admin';
42+
core.info(`pull_request_target by ${actor} (level=${perm.level}, role=${perm.role}) → authorized=${authorized}`);
43+
}
44+
} else {
45+
// issue_comment: the job-level `if:` already guarantees this is a PR
46+
// comment starting with /preview-docs.
47+
slashAttempt = true;
48+
const actor = context.payload.comment.user.login;
49+
prNumber = String(context.payload.issue.number);
50+
const perm = await permissionFor(actor);
51+
authorized = perm.level === 'admin' || perm.role === 'maintain';
52+
if (authorized) {
53+
const { data: pr } = await github.rest.pulls.get({ owner, repo, pull_number: Number(prNumber) });
54+
if (pr.state !== 'open') {
55+
authorized = false;
56+
core.info(`PR #${prNumber} is ${pr.state}; refusing to preview.`);
57+
} else {
58+
headSha = pr.head.sha;
59+
}
60+
}
61+
core.info(`/preview-docs by ${actor} (level=${perm.level}, role=${perm.role}) → authorized=${authorized}`);
62+
}
63+
64+
core.setOutput('authorized', String(authorized));
65+
core.setOutput('pr_number', prNumber);
66+
core.setOutput('head_sha', headSha);
67+
core.setOutput('slash_attempt', String(slashAttempt));
68+
}
69+
70+
// Posts or updates the preview comment on the PR. Reads the outcome of the
71+
// earlier jobs from the step's env: AUTHORIZED, PR_NUMBER, HEAD_SHA,
72+
// DEPLOY_RESULT, DEPLOYMENT_URL, ALIAS_URL, RUN_URL.
73+
async function comment({ github, context }) {
74+
const { owner, repo } = context.repo;
75+
const env = process.env;
76+
const issue_number = Number(env.PR_NUMBER);
77+
78+
async function upsert(body) {
79+
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number, per_page: 100 });
80+
const existing = comments.find((c) => c.user?.login === BOT_LOGIN && c.body?.includes(MARKER));
81+
if (existing) {
82+
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body });
83+
} else {
84+
await github.rest.issues.createComment({ owner, repo, issue_number, body });
85+
}
86+
}
87+
88+
if (env.AUTHORIZED !== 'true') {
89+
await github.rest.issues.createComment({
90+
owner, repo, issue_number,
91+
body: `@${context.actor} — only repository admins or maintainers can run \`/preview-docs\` (and the PR must be open).`,
92+
});
93+
return;
94+
}
95+
96+
if (env.DEPLOY_RESULT !== 'success') {
97+
await upsert(
98+
`${MARKER}\n### 📚 Documentation preview\n\n` +
99+
`❌ Preview build **failed** for \`${env.HEAD_SHA.slice(0, 7)}\` — [workflow logs](${env.RUN_URL}).`
100+
);
101+
return;
102+
}
103+
104+
const previewUrl = env.ALIAS_URL || env.DEPLOYMENT_URL;
105+
const ts = new Date().toISOString().replace('T', ' ').replace(/\.\d+Z$/, ' UTC');
106+
await upsert(
107+
`${MARKER}\n### 📚 Documentation preview\n\n` +
108+
`| | |\n|---|---|\n` +
109+
`| **Preview** | ${previewUrl} |\n` +
110+
`| **Deployment** | ${env.DEPLOYMENT_URL} |\n` +
111+
`| **Commit** | \`${env.HEAD_SHA.slice(0, 7)}\` |\n` +
112+
`| **Triggered by** | @${context.actor} |\n` +
113+
`| **Updated** | ${ts} |\n`
114+
);
115+
}
116+
117+
module.exports = { authorize, comment };

0 commit comments

Comments
 (0)