@jangmanj/mcp-client 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -112,6 +112,24 @@ Scope: `events/list`, `events/poll`, `events/stream`, `subscriptions/listen`,
112
112
  Webhook delivery and skills are intentionally out of scope; deprecated MCP
113
113
  Logging is not used — notices travel as ordinary events.
114
114
 
115
+ For discovery metadata, `@jangmanj/mcp-client/ext-server-cards` also includes a
116
+ card builder for servers you operate:
117
+
118
+ ```ts
119
+ import { buildServerCard, buildAiCatalog } from "@jangmanj/mcp-client/ext-server-cards";
120
+
121
+ const card = buildServerCard({
122
+ name: "roger-wilco",
123
+ version: "0.1.0",
124
+ description: "Durable cross-machine mail with push/poll event streams.",
125
+ remotes: [{ type: "streamable-http", url: "https://roger.example.net/mcp", supportedVersions: ["2026-07-28"] }],
126
+ });
127
+ const catalog = buildAiCatalog([card]); // serve as /.well-known/ai-catalog.json
128
+ ```
129
+
130
+ Cards are advisory only: primitive capability fields are rejected, and live
131
+ `server/discover` remains authoritative.
132
+
115
133
  ## Errors, cancellation, progress
116
134
 
117
135
  - **Simple mode** (`/client`): failures throw `McpOutcomeError`; inspect `error.outcome.kind`
@@ -77,3 +77,31 @@ export interface ServerCardsExtension extends Extension {
77
77
  }
78
78
  /** Advertises no client capability (EXT-card-8). */
79
79
  export declare function createServerCardsExtension(defaults?: DiscoverCardOptions): ServerCardsExtension;
80
+ export declare const DEFAULT_SERVER_CARD_SCHEMA = "https://modelcontextprotocol.io/schemas/server-card.json";
81
+ export interface ServerCardInput {
82
+ readonly $schema?: string;
83
+ readonly name: string;
84
+ readonly version: string;
85
+ readonly description: string;
86
+ readonly title?: string;
87
+ readonly icons?: unknown;
88
+ readonly repository?: unknown;
89
+ readonly websiteUrl?: string;
90
+ readonly remotes?: readonly ServerCardRemote[];
91
+ readonly _meta?: Record<string, unknown>;
92
+ }
93
+ /**
94
+ * Build an advisory Server Card for a server you operate.
95
+ *
96
+ * Cards are discovery metadata only: tools/resources/prompts primitives are
97
+ * rejected so a card cannot become an inferred capability document. Live
98
+ * server/discover remains authoritative.
99
+ */
100
+ export declare function buildServerCard(input: ServerCardInput): ServerCard;
101
+ /** Wrap cards in the /.well-known/ai-catalog.json document shape. */
102
+ export declare function buildAiCatalog(cards: readonly ServerCard[]): {
103
+ entries: Array<{
104
+ type: "mcp-server-card";
105
+ data: ServerCard;
106
+ }>;
107
+ };
@@ -196,3 +196,54 @@ export function createServerCardsExtension(defaults = {}) {
196
196
  discoverFromDomain: (d, o) => discoverFromDomain(d, { ...defaults, ...o }),
197
197
  };
198
198
  }
199
+ export const DEFAULT_SERVER_CARD_SCHEMA = "https://modelcontextprotocol.io/schemas/server-card.json";
200
+ function required(value, field) {
201
+ if (typeof value !== "string" || value.trim() === "")
202
+ throw new ServerCardError(`card-field-${field}`);
203
+ return value;
204
+ }
205
+ /**
206
+ * Build an advisory Server Card for a server you operate.
207
+ *
208
+ * Cards are discovery metadata only: tools/resources/prompts primitives are
209
+ * rejected so a card cannot become an inferred capability document. Live
210
+ * server/discover remains authoritative.
211
+ */
212
+ export function buildServerCard(input) {
213
+ for (const primitive of ["tools", "resources", "prompts"]) {
214
+ if (primitive in input)
215
+ throw new ServerCardError("card-primitives-not-allowed");
216
+ }
217
+ const card = {
218
+ $schema: input.$schema ?? DEFAULT_SERVER_CARD_SCHEMA,
219
+ name: required(input.name, "name"),
220
+ version: required(input.version, "version"),
221
+ description: required(input.description, "description"),
222
+ };
223
+ if (input.title !== undefined)
224
+ card["title"] = input.title;
225
+ if (input.websiteUrl !== undefined)
226
+ card["websiteUrl"] = input.websiteUrl;
227
+ if (input.icons !== undefined)
228
+ card["icons"] = input.icons;
229
+ if (input.repository !== undefined)
230
+ card["repository"] = input.repository;
231
+ if (input.remotes !== undefined) {
232
+ card["remotes"] = input.remotes.map((remote) => {
233
+ const type = required(remote.type, "remote-type");
234
+ const url = required(remote.url, "remote-url");
235
+ const supportedVersions = remote.supportedVersions ?? [];
236
+ if (!Array.isArray(supportedVersions) || supportedVersions.some((v) => typeof v !== "string")) {
237
+ throw new ServerCardError("card-field-supportedVersions");
238
+ }
239
+ return { ...remote, type, url, supportedVersions: [...supportedVersions] };
240
+ });
241
+ }
242
+ if (input._meta !== undefined)
243
+ card["_meta"] = input._meta;
244
+ return card;
245
+ }
246
+ /** Wrap cards in the /.well-known/ai-catalog.json document shape. */
247
+ export function buildAiCatalog(cards) {
248
+ return { entries: cards.map((card) => ({ type: "mcp-server-card", data: card })) };
249
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jangmanj/mcp-client",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "MCP 2026-07-28 client library: push events/subscriptions, core, transports, auth, ops, MRTR/cache, OTEL telemetry, and extensions.",
5
5
  "license": "MIT",
6
6
  "author": "JangMan-J",