@casys/mcp-server 0.25.0 → 0.26.1

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
@@ -9,7 +9,10 @@ Protocol servers in TypeScript.
9
9
 
10
10
  Composable middleware, OAuth2 auth, dual transport, observability, and
11
11
  everything you need to ship reliable MCP servers. Built on the official
12
- [@modelcontextprotocol/sdk](https://github.com/modelcontextprotocol/sdk).
12
+ [`@modelcontextprotocol/server`](https://www.npmjs.com/package/@modelcontextprotocol/server)
13
+ and
14
+ [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk)
15
+ packages.
13
16
 
14
17
  ```
15
18
  rate-limit → auth → custom middleware → scope-check → validation → backpressure → handler
@@ -440,6 +443,54 @@ server.registerResource(
440
443
  );
441
444
  ```
442
445
 
446
+ Handlers return one payload form: `text` (including HTML) **or** `blob` for
447
+ binary content encoded as standard padded base64. Existing text handlers remain
448
+ valid. The framework also checks at runtime that the response URI exactly
449
+ matches the requested URI and that the MIME type is non-empty, which protects
450
+ JavaScript and unchecked TypeScript handlers as well as typed callers.
451
+
452
+ ```typescript
453
+ server.registerResource(
454
+ { uri: "file://reports/latest.pdf", name: "Latest report", size: 184_320 },
455
+ async (uri) => ({
456
+ uri: uri.toString(),
457
+ mimeType: "application/pdf",
458
+ blob: await loadReportAsCanonicalBase64(),
459
+ }),
460
+ );
461
+ ```
462
+
463
+ `size` is optional resource metadata shown in `resources/list`; when present it
464
+ must be a non-negative safe integer and is verified on every read against the
465
+ exact UTF-8 byte length of `text` or decoded byte length of `blob`. Supplying
466
+ `mimeType` in the resource metadata likewise binds every response to that exact
467
+ MIME type. If it is absent, it is absent from `resources/list`; the handler
468
+ still declares the MIME type when it serves the bytes. Resource content may
469
+ include `_meta`. Put `annotations`, `icons`, `title`, and resource `_meta` on
470
+ the `MCPResource` registration, where MCP defines those fields.
471
+
472
+ With `resourceCsp`, CSP injection applies only to the `text` branch of an HTML
473
+ resource. Blobs are never decoded, transformed, or re-encoded.
474
+
475
+ Register resources before `start()` / `startHttp()` to install the resource
476
+ handlers and advertise `resources: { listChanged: true }`. They can then be
477
+ added or removed at any time through `unregisterResource(uri)`, which returns
478
+ `true` only once. For a registry that starts empty and discovers resources
479
+ asynchronously, construct with `expectResources: true`; that mode installs the
480
+ same handlers at construction time:
481
+
482
+ ```typescript
483
+ const app = new McpApp({
484
+ name: "relay",
485
+ version: "1.0.0",
486
+ expectResources: true,
487
+ });
488
+
489
+ // After start(): list/read/templates handlers are already installed.
490
+ app.registerResource(resource, handler);
491
+ app.unregisterResource(resource.uri); // true, then false if called again
492
+ ```
493
+
443
494
  #### Capability negotiation (clients that don't support MCP Apps)
444
495
 
445
496
  Not every MCP client renders UI resources. Clients that do advertise the
@@ -506,11 +557,12 @@ to introspect the protocol target directly.
506
557
  ```typescript
507
558
  const server = new McpApp(options: McpAppOptions);
508
559
 
509
- // Registration (before start)
560
+ // Registration (before start, unless expectResources: true)
510
561
  server.registerTool(tool, handler);
511
562
  server.registerTools(tools, handlers);
512
563
  server.registerResource(resource, handler);
513
564
  server.registerResources(resources, handlers);
565
+ server.unregisterResource(resourceUri); // safe before or after start
514
566
  server.use(middleware);
515
567
 
516
568
  // Transport
package/mod.ts CHANGED
@@ -66,6 +66,7 @@ export type {
66
66
 
67
67
  // Type exports
68
68
  export type {
69
+ BlobResourceContent,
69
70
  HttpRateLimitContext,
70
71
  HttpRateLimitOptions,
71
72
  HttpServerInstance,
@@ -86,6 +87,7 @@ export type {
86
87
  SamplingParams,
87
88
  SamplingResult,
88
89
  StructuredToolResult,
90
+ TextResourceContent,
89
91
  ToolAnnotations,
90
92
  ToolErrorMapper,
91
93
  ToolHandler,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@casys/mcp-server",
3
- "version": "0.25.0",
3
+ "version": "0.26.1",
4
4
  "description": "Production-ready MCP server framework with concurrency control, auth, and observability",
5
5
  "type": "module",
6
6
  "main": "mod.ts",
@@ -10,6 +10,7 @@
10
10
  "test": "tsx --test src/**/*_test.ts"
11
11
  },
12
12
  "dependencies": {
13
+ "@modelcontextprotocol/server": "^2.0.0",
13
14
  "@modelcontextprotocol/sdk": "^1.29.0",
14
15
  "@modelcontextprotocol/ext-apps": "^1.7.4",
15
16
  "hono": "^4.0.0",