Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
```
10 changes: 10 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 <slug> <url>`. */
export function mcpAddCommand(entry: { slug: string; url: string }, cli?: "claude" | "gemini" | "qwen" | "codex" | "opencode"): string;
export const POLICIES: Record<string, PluginPolicy>;
export function policyFor(url: string): PluginPolicy | null;
export function needsConfirmation(policy: PluginPolicy, tool: string): boolean;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
43 changes: 43 additions & 0 deletions src/docs.js
Original file line number Diff line number Diff line change
@@ -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}`);
}
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ export {
describeAction,
redactLog,
} from "./money.js";
export { DOCS_CATALOG, mcpAddCommand } from "./docs.js";
6 changes: 5 additions & 1 deletion src/money.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
{
Expand Down Expand Up @@ -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",
Expand Down
33 changes: 33 additions & 0 deletions test/docs.test.js
Original file line number Diff line number Diff line change
@@ -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");
});
});
2 changes: 1 addition & 1 deletion test/money.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Loading