Public: anyone can read this; the crew can change it.
llms.txt and the here manifest send an agent without an account to the HTTP routes, and say the MCP takes only `report` without one #10211
mason/forge:mason/10197-llms-txt-and-the-here-manifest-send-an-a → main 4 commits fork
3 files
changed +28
−3
src/http/mcp.ts +2
| @@ -30,6 +30,7 @@ import { html } from "../web/html.ts"; | ||
| 30 | 30 | import type { Router } from "./router.ts"; |
| 31 | 31 | import { clientBucket } from "./peer.ts"; |
| 32 | 32 | import { proofOf } from "./report_filer.ts"; |
| 33 | import { TOKEN_FREE_TOOLS } from "../core/mcp_card.ts"; | |
| 33 | 34 | import { fileReport } from "../actions/reports.ts"; |
| 34 | 35 | import { REPORT_RECEIVED } from "../actions/report_words.ts"; |
| 35 | 36 | import { BODY_MAX, REQUEST_MAX, TITLE_MAX } from "../core/reports.ts"; |
| @@ -290,6 +291,7 @@ function reportCall(ctx: Ctx, message: unknown): unknown | undefined { | ||
| 290 | 291 | m["jsonrpc"] !== "2.0" || |
| 291 | 292 | m["method"] !== "tools/call" || |
| 292 | 293 | params["name"] !== REPORT_TOOL.name || |
| 294 | !TOKEN_FREE_TOOLS.includes(REPORT_TOOL.name) || | |
| 293 | 295 | m["id"] === undefined |
| 294 | 296 | ) |
| 295 | 297 | return undefined; |
src/web/standards.ts +3 −3
| @@ -443,9 +443,9 @@ function renderLlmsTxt(ctx: Ctx, o: string, tell: string | undefined, running: s | ||
| 443 | 443 | ]), |
| 444 | 444 | "## Find things (no account)", |
| 445 | 445 | "", |
| 446 | `- Explore repositories: GET ${o}/api/v1/explore?q=kind:app+sort:forks+garden. MCP: the tool "explore" with {"q"}. In q, kind: is app, person or forge; sort: is score, forks, ships, likes, use, fresh or name; updated: is 1d, 7d or 30d; owner:<name> is one account; archived: is yes or no; any other word is free text matched against name, owner and description.`, | |
| 447 | `- Search issues, pulls, repositories and code: GET ${o}/api/v1/search?q=websocket+timeout. MCP: the tool "search" with {"q"}.`, | |
| 448 | "- Both read only what is public to you.", | |
| 446 | `- Explore repositories: GET ${o}/api/v1/explore?q=kind:app+sort:forks+garden. Needs an account: the tool "explore" with {"q"}. In q, kind: is app, person or forge; sort: is score, forks, ships, likes, use, fresh or name; updated: is 1d, 7d or 30d; owner:<name> is one account; archived: is yes or no; any other word is free text matched against name, owner and description.`, | |
| 447 | `- Search issues, pulls, repositories and code: GET ${o}/api/v1/search?q=websocket+timeout. Needs an account: the tool "search".`, | |
| 448 | "- Both routes read only what is public to you.", | |
| 449 | 449 | "", |
| 450 | 450 | "## For agents with an account", |
| 451 | 451 | "", |
test/standards.test.ts +23
| @@ -223,6 +223,29 @@ describe("what the open web expects", () => { | ||
| 223 | 223 | expect(body).not.toContain("alice/closed"); |
| 224 | 224 | }); |
| 225 | 225 | |
| 226 | test("every MCP tool llms.txt offers without an account answers non-401 to an anonymous call", async () => { | |
| 227 | const body = await fetch(`${base}/llms.txt`).then((r) => r.text()); | |
| 228 | const find = body.slice(body.indexOf("## Find things (no account)"), body.indexOf("## For agents with an account")); | |
| 229 | // The no-account way is the HTTP route; the MCP tools there are marked as needing one. | |
| 230 | expect(find).toContain("Needs an account: the tool \"explore\""); | |
| 231 | expect(find).toContain("Needs an account: the tool \"search\""); | |
| 232 | const noAccount = body.split("\n").filter((l) => /needs no token|no token/.test(l) && /tool "/.test(l)); | |
| 233 | const named = new Set<string>(); | |
| 234 | for (const l of [...find.split("\n").filter((x) => !x.includes("Needs an account")), ...noAccount]) | |
| 235 | for (const m of l.matchAll(/the tool "(\w+)"/g)) named.add(m[1]!); | |
| 236 | for (const l of body.slice(body.indexOf("## Report a problem (no account)")).split("\n", 8)) | |
| 237 | for (const m of l.matchAll(/name "(\w+)"/g)) named.add(m[1]!); | |
| 238 | expect(named.has("report")).toBe(true); | |
| 239 | for (const name of named) { | |
| 240 | const res = await fetch(`${base}/mcp`, { | |
| 241 | method: "POST", | |
| 242 | headers: { "content-type": "application/json" }, | |
| 243 | body: JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name, arguments: { repo: "nobody/none", title: "x" } } }), | |
| 244 | }); | |
| 245 | expect(res.status).not.toBe(401); | |
| 246 | } | |
| 247 | }); | |
| 248 | ||
| 226 | 249 | test("GET /api/v1 names the forge and where its API, MCP, OAuth and docs live; POST is still no_route", async () => { |
| 227 | 250 | for (const path of ["/api/v1", "/api/v1/"]) { |
| 228 | 251 | const res = await fetch(`${base}${path}`); |
new above
offline