@procedures/mcp-server 0.28.0 → 0.29.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/CHANGELOG.md CHANGED
@@ -1,5 +1,47 @@
1
1
  # @procedures/mcp-server
2
2
 
3
+ ## 0.29.0
4
+
5
+ ### Patch Changes
6
+
7
+ - @procedures/client@0.29.0
8
+ - @procedures/mcp@0.29.0
9
+
10
+ ## 0.28.1
11
+
12
+ ### Patch Changes
13
+
14
+ - 2572f41: The MCP face stays on its listener through the drain (roadmap CLI-74).
15
+
16
+ PATCH: a fix with no API change (D34).
17
+
18
+ - Before, the mount of the MCP face stopped at the stage `stop intake`. On the listener of a procedures host, the listener closed, and each request got its plain 503. Thus the answer of an elicitation and a cancel did not reach a call in progress.
19
+ - Now the handler of `mcpFace()` and `McpHost.handleHttp` have `until: "close transports"`, as a `RequestHandler` of `@mark1russell7/service/http`. The procedures host gives the `until` of the handler of each face to its mount.
20
+ - During the drain, the answer of an elicitation, a cancel and a ping reach the session. A new session and a new GET stream get the 503 of the face. A new tool call gets `UNAVAILABLE` from the server.
21
+ - The face ends the SSE stream of a cancelled call. The SDK sends no answer to a cancel, so that stream held the drain of the listener until its deadline.
22
+ - Mount `host.handleHttp` itself, for example `listener.mount(host.handleHttp)`. A function that wraps it loses `until`. The dev-tools server mounts it in this way.
23
+ - A change you can see: during a drain, a listener with the MCP face answers a new connection with 503 and `Retry-After` until the stage `close transports`. Before, the listener closed at the stage `stop intake`.
24
+ - Note on the stop time: the cap of the drain does not change, and a stream of the face does not hold the drain past its deadline. A listener with the MCP face now answers a new connection with 503 until the stage `close transports`, and does not refuse it. The test `mcp-stop.test.ts` of `@procedures/peer` measures each stop on the fake clock.
25
+ - 21dc858: Fixes for the security findings of the second code audit (roadmap O55).
26
+
27
+ PATCH: bug fixes and additive options. Each fix refuses only an input that the documentation does not give. A caller that uses the documented behavior sees no change. A request to a loopback, private or link-local host still works, with a deprecation notice. Version 0.29.0 refuses it (decision D35).
28
+
29
+ - `procedure.delete` and `procedure.define` of `@procedures/client` obey the expose rule of the host, as `procedure.get` does (R17). `procedure.delete` does not find a hidden procedure, and `procedure.define` refuses to replace one with `NOT_EXPOSED`. A new procedure at a free path stays possible, as before. Before, a caller could remove or replace a hidden procedure that the host defined.
30
+ - The task store of `@procedures/mcp-server` keeps a task without a session (stdio, an SDK transport) apart from the HTTP sessions, both ways. Before, each HTTP session could list, read and cancel such a task.
31
+ - `restic.run` of `@procedures/restic` refuses each input that lets the caller choose a program for restic to start: `--from-password-command`, `--password-command2`, an extended option that sets `sftp.command`, `sftp.args`, `rclone.program` or `rclone.args` (each spelling), an sftp or rclone repository whose host or remote starts with `-`, and a positional argument that starts with `-` after a last flag without a value. Before, only `--password-command` was refused.
32
+ - `@procedures/http` exports `createHostFetch(options)`: a `fetch` for GET requests through the host policy, with the options of `createHttpModule()`. It also exports `httpSettings(options)`. The deprecated option `warnOnRefusal` keeps a refused host working: the process gets one `DeprecationWarning`, and the request goes through the global `fetch`.
33
+ - `weather.forecast` of `@procedures/weather` sends its request through `createHostFetch()` with `warnOnRefusal`. A `baseUrl` on a loopback, private or link-local address still works, with the warning `PROCEDURES_WEATHER_PRIVATE_HOST`. `createWeatherModule({ fetch })` gives another `fetch`, for a server of the host on such an address.
34
+ - `@procedures/geo` and `@procedures/ics` add `createGeoModule({ fetch })` and `createIcsModule({ fetch })`. Their default stays the global `fetch`, because their roots run in a browser. A refusal of the host policy keeps its code and its reason. The refusal of `ics.fetch` does not name the feed address.
35
+ - `@procedures/bundle-assistant` exports `mcpHostModules`: the modules of `geo` and `ics` with `createHostFetch()` and `warnOnRefusal`. A refused host gets the warning `PROCEDURES_GEO_PRIVATE_HOST` or `PROCEDURES_ICS_PRIVATE_HOST`. The bundle keeps the default modules, so `mark` and the site load it next to `geo` and `ics` as before.
36
+ - The dev-tools server of `@procedures/mcp-dev-tools` gives the `mcpHostModules` of each bundle to `createRegistry()` before the bundles. In one call, the first module of a name counts. Thus `geo.geocode`, `geo.route`, `weather.forecast` and `ics.fetch` of the dev-tools server go through the default host policy.
37
+
38
+ A host that sends `weather.forecast`, or the bundle's `geo` tools, to a server on a private address can remove the warning now. It gives a `fetch` that allows the server: `createWeatherModule({ fetch: createHostFetch({ allow: ["10.0.0.5:8080"] }) })`. This `fetch` refuses each other private host now, as 0.29.0 does by default.
39
+ - Updated dependencies [345c740]
40
+ - Updated dependencies [984c13b]
41
+ - Updated dependencies [21dc858]
42
+ - @procedures/client@0.28.1
43
+ - @procedures/mcp@0.28.1
44
+
3
45
  ## 0.28.0
4
46
 
5
47
  ### Patch Changes
package/README.md CHANGED
@@ -143,6 +143,7 @@ The server of the face checks the credentials of each request one time (CLI-2b,
143
143
  - A host with a stdio face declares the trigger `stdin-close`. The end of the input starts the stop in stages, and the face does not stop the host by itself.
144
144
  - The HTTP face has no listener. Mount `host.handleHttp` on an `httpTransport` of `@mark1russell7/service/http`, and declare that transport on the service.
145
145
  - At the stop of the intake, the HTTP face ends the idle GET streams, as `mcpFace()` does (CLI-72). Thus the drain of the listener waits only for the calls and the tasks. Refer to [The face of a procedures host](#the-face-of-a-procedures-host).
146
+ - The HTTP face stays on the listener through the drain, as `mcpFace()` does (CLI-74). `host.handleHttp` has `until: "close transports"`, so mount the function itself. A function that wraps it loses `until`. Then give `{ until: "close transports" }` to `mount()`.
146
147
 
147
148
  ```typescript
148
149
  import { createServer } from "node:http";
@@ -156,7 +157,8 @@ await stdioHost.declare(service("my-mcp").profile(ephemeral)).run();
156
157
  // Over Streamable HTTP: a listener of the service, and the face at /mcp on it
157
158
  const httpHost = createMcpHost({ registry, policy: { token }, faces: { http: {} } });
158
159
  const listener = httpTransport(createServer(), knobs, { listen: { port: 3003, host: "127.0.0.1" } });
159
- listener.mount((req, res) => httpHost.handleHttp(req, res));
160
+ // The function has the stage of its mount: the face stays on the listener through the drain
161
+ listener.mount(httpHost.handleHttp);
160
162
  const svc = httpHost.declare(service("my-mcp").profile(localDev));
161
163
  svc.server("my-mcp.listen", listener.knobs, listener);
162
164
  await svc.run();
@@ -263,6 +265,7 @@ host.tasks?.running(); // the tasks that did not end, for a status page
263
265
  - The tool list gives `execution.taskSupport` of each such tool. Without the option `tasks`, the list does not give it, and each call is a normal request.
264
266
  - A progress of the procedure becomes the status message of its task, for example `2 of 5 done`. The message holds only the counts, so no text of the work leaves its envelopes. A client that sent a progress token also gets the progress notifications.
265
267
  - A cancel of the task (`tasks/cancel`) aborts `ctx.signal` of the procedure. The close of a session cancels its tasks, and the stop of the host cancels each task.
268
+ - Each task belongs to its session. A request of another session does not find it. A task without a session (stdio, an SDK transport) is visible only to the requests without a session. Such a request does not find the tasks of the HTTP sessions.
266
269
  - The store runs at most `maxRunning` tasks at one time (8 by default). A task holds its place until its procedure returns, also after a cancel. A task above the limit starts, and then fails at once. Thus the client gets a task, and the result of the task gives the reason. A full store is different: refer to `maxStored` below.
267
270
  - The time to keep a task (`ttl`) starts when the task ends. The store does not remove a task whose procedure still runs.
268
271
  - The store keeps at most 100 tasks for one session, and at most 1000 tasks for all the sessions together (`maxStored`, CLI-51). A new task removes the oldest task of its own session that ended. The store can be full, and the session can have no task that ended. Then the request of the new task gets the error `-32600`, and the store keeps nothing of it. Thus a client cannot remove the results of another session. `maxStored: Infinity` turns the total limit off.
@@ -400,6 +403,14 @@ The face stops with the host (CLI-72). At the stop of the intake, the face does
400
403
 
401
404
  Thus the drain of the listener waits only for the calls and the tasks. Before, each GET stream stayed open until the close of the face. Thus each stop with a connected client waited for the full cap of the drain.
402
405
 
406
+ The face stays on the listener through the drain (CLI-74). Its handler has `until: "close transports"`, as a `RequestHandler` of `@mark1russell7/service/http`. Thus the listener stays open until the stage `close transports`. During the drain, the face does these steps:
407
+
408
+ - It gives the answer of an elicitation, a cancel and a ping to the session. Thus a call that asks the person can complete.
409
+ - It refuses a new session and a new GET stream with its 503. A new tool call gets `UNAVAILABLE` from the server, and its procedure does not start.
410
+ - It ends the SSE stream of a cancelled call. The SDK sends no answer to a cancel. Before, that stream held the drain of the listener until its deadline.
411
+
412
+ Each other path of the listener gets 503 with `Retry-After`, and a new connection gets an answer. The cap of the drain does not change. Before, the listener closed at the stop of the intake. Thus a call that waited for an answer of the person waited until the cooperative abort.
413
+
403
414
  ## The procedures of this package
404
415
 
405
416
  | Procedure | Function |