From 8eef8efe904ba0fc3241f9e6239fbcf09daa7f70 Mon Sep 17 00:00:00 2001 From: Anthony Ettinger Date: Sun, 22 Nov 2026 19:56:25 +0000 Subject: [PATCH] 0.3.0: docs plugins, Microsoft Learn on by default, mcpAddCommand DOCS_CATALOG lists public read-only documentation servers that need no sign-in. Microsoft Learn (learn.microsoft.com/api/mcp) is on by default and joins DEFAULT_PLUGINS with auth: "none". mcpAddCommand() renders the one-line CLI registration for claude, gemini, qwen, codex and opencode. Co-Authored-By: Claude Fable 5.2 --- README.md | 19 +++++++++++++++++++ index.d.ts | 10 ++++++++++ package.json | 2 +- src/docs.js | 43 +++++++++++++++++++++++++++++++++++++++++++ src/index.js | 1 + src/money.js | 6 +++++- test/docs.test.js | 33 +++++++++++++++++++++++++++++++++ test/money.test.js | 2 +- 8 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 src/docs.js create mode 100644 test/docs.test.js diff --git a/README.md b/README.md index 37c14e0..aecf85b 100644 --- a/README.md +++ b/README.md @@ -125,3 +125,22 @@ const tools = applyPolicy(policy, await listTools(plugin), plugin.tradingMode ?? moomoo in paper mode offers reads plus `sim_trade_*` orders only; live order tools appear only in `"live"` mode, and still ask. `redactLog()` masks tokens, long digit runs and amounts before anything reaches a log. + +## Docs plugins (0.3.0) + +`DOCS_CATALOG` lists public, read-only documentation servers that need no +sign-in. It ships Microsoft Learn (`https://learn.microsoft.com/api/mcp`: +docs search, code sample search, page fetch), on by default. + +`DEFAULT_PLUGINS` now holds every default: the money plugins, then the docs +plugins. A docs entry carries `auth: "none"`; seed it as ready to use, not as +"needs sign-in": + +```js +import { DEFAULT_PLUGINS, DOCS_CATALOG, mcpAddCommand } from "@profullstack/chat-plugins"; + +for (const d of DEFAULT_PLUGINS) seed(userId, d, d.auth === "none" ? "none" : "sign-in-on-first-use"); + +mcpAddCommand(DOCS_CATALOG[0]); // claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp +mcpAddCommand(DOCS_CATALOG[0], "codex"); // codex mcp add microsoft-learn --url https://learn.microsoft.com/api/mcp +``` diff --git a/index.d.ts b/index.d.ts index 523b44b..21d946c 100644 --- a/index.d.ts +++ b/index.d.ts @@ -341,6 +341,12 @@ export interface FinanceCatalogEntry { icon: string; /** On for every account (listed and switched on, not signed in). */ default: boolean; + /** "none": the server needs no sign-in, so a seeded row is ready to use. Absent: sign-in on first use. */ + auth?: "none"; +} +/** A public, read-only documentation server that needs no sign-in. */ +export interface DocsCatalogEntry extends FinanceCatalogEntry { + auth: "none"; } export interface ActionSummary { title: string; @@ -350,7 +356,11 @@ export interface ActionSummary { } export const MODEL_CAN_BE_WRONG: string; export const FINANCE_CATALOG: readonly FinanceCatalogEntry[]; +/** Everything on for every account: money plugins (sign-in on first use), then docs plugins (auth "none"). */ export const DEFAULT_PLUGINS: readonly FinanceCatalogEntry[]; +export const DOCS_CATALOG: readonly DocsCatalogEntry[]; +/** The one-line CLI command that registers an entry, e.g. `claude mcp add --transport http `. */ +export function mcpAddCommand(entry: { slug: string; url: string }, cli?: "claude" | "gemini" | "qwen" | "codex" | "opencode"): string; export const POLICIES: Record; export function policyFor(url: string): PluginPolicy | null; export function needsConfirmation(policy: PluginPolicy, tool: string): boolean; diff --git a/package.json b/package.json index c20d0cc..5011811 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@profullstack/chat-plugins", - "version": "0.2.0", + "version": "0.3.0", "type": "module", "description": "Chat plugins = remote MCP servers, with less hoops than connectors: paste a URL or pick from a catalog, sign-in is automatic (OAuth 2.1 + DCR + PKCE), and an agent loop runs the tools even on models with no native tool calling. Zero dependencies.", "keywords": [ diff --git a/src/docs.js b/src/docs.js new file mode 100644 index 0000000..e05a6ba --- /dev/null +++ b/src/docs.js @@ -0,0 +1,43 @@ +// Docs plugins: public, read-only documentation servers that need no sign-in. +// Entries with `default: true` are on for every account in apps that seed +// DEFAULT_PLUGINS (c0mpute chat, Infernet chat). `auth: "none"` tells the app +// to seed the row as ready to use, not as "needs sign-in". +// +// No Node imports: this also runs in the browser. + +/** @type {readonly import("../index.js").DocsCatalogEntry[]} */ +export const DOCS_CATALOG = Object.freeze([ + Object.freeze({ + slug: "microsoft-learn", + name: "Microsoft Learn (docs)", + url: "https://learn.microsoft.com/api/mcp", + description: + "Official Microsoft and Azure documentation in chat: search the docs, find code samples and read full pages as markdown. Read-only, no sign-in.", + homepage: "https://learn.microsoft.com", + icon: "https://learn.microsoft.com/favicon.ico", + default: true, + auth: "none", + }), +]); + +/** + * The one-line command that registers a catalog entry in a coding agent's CLI, + * e.g. `claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp`. + * @param {{ slug: string, url: string }} entry + * @param {"claude" | "gemini" | "qwen" | "codex" | "opencode"} [cli] + */ +export function mcpAddCommand(entry, cli = "claude") { + const slug = String(entry?.slug || ""); + const url = String(entry?.url || ""); + if (!/^[a-z0-9][a-z0-9_-]*$/i.test(slug)) throw new Error("mcpAddCommand: bad slug"); + let parsed; + try { + parsed = new URL(url); + } catch { + throw new Error("mcpAddCommand: bad url"); + } + if (parsed.protocol !== "https:" || /[\s'"`$\;&|<>()]/.test(url)) throw new Error("mcpAddCommand: bad url"); + if (cli === "codex" || cli === "opencode") return `${cli} mcp add ${slug} --url ${url}`; + if (cli === "claude" || cli === "gemini" || cli === "qwen") return `${cli} mcp add --transport http ${slug} ${url}`; + throw new Error(`mcpAddCommand: unknown cli ${cli}`); +} diff --git a/src/index.js b/src/index.js index f04a0b2..12deb77 100644 --- a/src/index.js +++ b/src/index.js @@ -39,3 +39,4 @@ export { describeAction, redactLog, } from "./money.js"; +export { DOCS_CATALOG, mcpAddCommand } from "./docs.js"; diff --git a/src/money.js b/src/money.js index 024501c..4982761 100644 --- a/src/money.js +++ b/src/money.js @@ -12,6 +12,8 @@ // Shared by c0mpute chat and Infernet chat so the two cannot drift. No Node // imports: describeAction() also runs in the browser. +import { DOCS_CATALOG } from "./docs.js"; + export const MODEL_CAN_BE_WRONG = "The model can be wrong. You decide: nothing here runs until you approve it."; export const FINANCE_CATALOG = Object.freeze([ { @@ -42,7 +44,9 @@ export const FINANCE_CATALOG = Object.freeze([ default: false } ]); -export const DEFAULT_PLUGINS = FINANCE_CATALOG.filter((e) => e.default); +// Everything apps switch on for every account: the money plugins each person +// signs in to, then the docs plugins that need no sign-in (auth: "none"). +export const DEFAULT_PLUGINS = Object.freeze([...FINANCE_CATALOG.filter((e) => e.default), ...DOCS_CATALOG.filter((e) => e.default)]); const MERCURY_READ = new Set([ "getCurrentDate", "getAccount", diff --git a/test/docs.test.js b/test/docs.test.js new file mode 100644 index 0000000..831afd7 --- /dev/null +++ b/test/docs.test.js @@ -0,0 +1,33 @@ +import { describe, expect, test } from "bun:test"; +import { DEFAULT_PLUGINS, DOCS_CATALOG, mcpAddCommand, policyFor, resolvePluginInput } from "../src/index.js"; + +describe("docs plugins", () => { + test("Microsoft Learn is on by default and needs no sign-in", () => { + const ms = DOCS_CATALOG.find((e) => e.slug === "microsoft-learn"); + expect(ms.url).toBe("https://learn.microsoft.com/api/mcp"); + expect(ms.default).toBe(true); + expect(ms.auth).toBe("none"); + expect(DEFAULT_PLUGINS.map((d) => d.slug)).toEqual(["mercury", "coinpay", "microsoft-learn"]); + // Not a money plugin: no confirmation policy applies. + expect(policyFor(ms.url)).toBeNull(); + }); + + test("the add command is the documented one-liner, per CLI", () => { + const ms = DOCS_CATALOG[0]; + expect(mcpAddCommand(ms)).toBe("claude mcp add --transport http microsoft-learn https://learn.microsoft.com/api/mcp"); + expect(mcpAddCommand(ms, "codex")).toBe("codex mcp add microsoft-learn --url https://learn.microsoft.com/api/mcp"); + expect(mcpAddCommand(ms, "opencode")).toBe("opencode mcp add microsoft-learn --url https://learn.microsoft.com/api/mcp"); + }); + + test("the add command refuses anything a shell could misread", () => { + expect(() => mcpAddCommand({ slug: "x; rm -rf /", url: "https://a.example/mcp" })).toThrow(); + expect(() => mcpAddCommand({ slug: "x", url: "https://a.example/mcp;id" })).toThrow(); + expect(() => mcpAddCommand({ slug: "x", url: "http://a.example/mcp" })).toThrow(); + expect(() => mcpAddCommand({ slug: "x", url: "https://a.example/$(id)" })).toThrow(); + expect(() => mcpAddCommand({ slug: "x", url: "https://a.example/mcp" }, "nope")).toThrow(); + }); + + test("a catalog built from it resolves the slug", () => { + expect(resolvePluginInput("microsoft-learn", DOCS_CATALOG)?.url).toBe("https://learn.microsoft.com/api/mcp"); + }); +}); diff --git a/test/money.test.js b/test/money.test.js index 5f2650f..8cbe441 100644 --- a/test/money.test.js +++ b/test/money.test.js @@ -3,7 +3,7 @@ import { applyPolicy, DEFAULT_PLUGINS, describeAction, FINANCE_CATALOG, needsApp describe("money plugin catalog", () => { test("Mercury and CoinPay are on by default; moomoo is listed but off", () => { - expect(DEFAULT_PLUGINS.map((d) => d.slug).sort()).toEqual(["coinpay", "mercury"]); + expect(DEFAULT_PLUGINS.filter((d) => d.auth !== "none").map((d) => d.slug).sort()).toEqual(["coinpay", "mercury"]); const moomoo = FINANCE_CATALOG.find((e) => e.slug === "moomoo"); expect(moomoo.default).toBe(false); expect(moomoo.description).toContain("you decide");