@brightbeamai/chap-coordinator-mcp 0.3.2 → 0.3.4

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/dist/index.d.cts CHANGED
@@ -101,7 +101,7 @@ declare function classifyEnvelope(params: unknown): ProtocolEra;
101
101
  * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
102
102
  *
103
103
  * const coord = new Coordinator({ ... });
104
- * const server = makeChapMcpServer(coord, { name: "chap", version: "0.3.2" });
104
+ * const server = makeChapMcpServer(coord, { name: "chap", version: "0.3.4" });
105
105
  * await server.connect(new StdioServerTransport());
106
106
  *
107
107
  * Usage (Streamable HTTP): see reference/mcp-server-ts/server.ts.
@@ -147,10 +147,20 @@ declare const ServerDiscoverRequestSchema: z.ZodObject<{
147
147
  interface ChapMcpOptions {
148
148
  /** Server name advertised to MCP clients. Default: "chap". */
149
149
  name?: string;
150
- /** Server version. Default: "0.3.2". */
150
+ /** Server version. Default: "0.3.4". */
151
151
  version?: string;
152
- /** Override the list of CHAP methods to expose. Default: all 39. */
152
+ /**
153
+ * Restrict the CHAP methods this server offers. Default: all 39. A tool the
154
+ * filter excludes is left out of the list and refused when called.
155
+ */
153
156
  toolFilter?: (toolName: string) => boolean;
157
+ /**
158
+ * Make every call as this participant. `from` is filled in on each call,
159
+ * and a call that names another `from` is refused. Use it where the server
160
+ * is one participant's connection, such as an agent's, so the connection
161
+ * cannot act in anyone else's name. Default: each call names its own `from`.
162
+ */
163
+ participant?: string;
154
164
  /** Optional id generator for the envelopes emitted by tool calls. */
155
165
  envelopeIdFactory?: () => string | number;
156
166
  }
package/dist/index.d.ts CHANGED
@@ -101,7 +101,7 @@ declare function classifyEnvelope(params: unknown): ProtocolEra;
101
101
  * import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
102
102
  *
103
103
  * const coord = new Coordinator({ ... });
104
- * const server = makeChapMcpServer(coord, { name: "chap", version: "0.3.2" });
104
+ * const server = makeChapMcpServer(coord, { name: "chap", version: "0.3.4" });
105
105
  * await server.connect(new StdioServerTransport());
106
106
  *
107
107
  * Usage (Streamable HTTP): see reference/mcp-server-ts/server.ts.
@@ -147,10 +147,20 @@ declare const ServerDiscoverRequestSchema: z.ZodObject<{
147
147
  interface ChapMcpOptions {
148
148
  /** Server name advertised to MCP clients. Default: "chap". */
149
149
  name?: string;
150
- /** Server version. Default: "0.3.2". */
150
+ /** Server version. Default: "0.3.4". */
151
151
  version?: string;
152
- /** Override the list of CHAP methods to expose. Default: all 39. */
152
+ /**
153
+ * Restrict the CHAP methods this server offers. Default: all 39. A tool the
154
+ * filter excludes is left out of the list and refused when called.
155
+ */
153
156
  toolFilter?: (toolName: string) => boolean;
157
+ /**
158
+ * Make every call as this participant. `from` is filled in on each call,
159
+ * and a call that names another `from` is refused. Use it where the server
160
+ * is one participant's connection, such as an agent's, so the connection
161
+ * cannot act in anyone else's name. Default: each call names its own `from`.
162
+ */
163
+ participant?: string;
154
164
  /** Optional id generator for the envelopes emitted by tool calls. */
155
165
  envelopeIdFactory?: () => string | number;
156
166
  }
package/dist/index.js CHANGED
@@ -920,12 +920,15 @@ var META_SERVER_INFO = "io.modelcontextprotocol/serverInfo";
920
920
  var LIST_TTL_MS = 36e5;
921
921
  var ServerDiscoverRequestSchema = z.object({
922
922
  method: z.literal("server/discover"),
923
- params: z.optional(z.object({ _meta: z.optional(z.record(z.string(), z.unknown())) }).loose())
923
+ // `.passthrough()` keeps unknown keys under zod 3 and zod 4 alike, and the
924
+ // package accepts both majors. The zod 4 name for the same thing does not
925
+ // exist in zod 3, where it stopped the package at import.
926
+ params: z.optional(z.object({ _meta: z.optional(z.record(z.string(), z.unknown())) }).passthrough())
924
927
  });
925
928
  function makeChapMcpServer(coord, options = {}) {
926
929
  const serverInfo = {
927
930
  name: options.name ?? "chap",
928
- version: options.version ?? "0.3.2"
931
+ version: options.version ?? "0.3.4"
929
932
  };
930
933
  const server = new Server(
931
934
  serverInfo,
@@ -989,7 +992,25 @@ function makeChapMcpServer(coord, options = {}) {
989
992
  content: [{ type: "text", text: `Unknown CHAP tool: ${toolName}` }]
990
993
  });
991
994
  }
992
- const args = coerceToolArgs(toolName, rawArgs);
995
+ if (!filter(toolName)) {
996
+ return terminal({
997
+ isError: true,
998
+ content: [{ type: "text", text: `CHAP tool not offered by this server: ${toolName}` }]
999
+ });
1000
+ }
1001
+ const args = { ...coerceToolArgs(toolName, rawArgs) };
1002
+ if (options.participant !== void 0) {
1003
+ if (args.from !== void 0 && args.from !== options.participant) {
1004
+ return terminal({
1005
+ isError: true,
1006
+ content: [{
1007
+ type: "text",
1008
+ text: `This server acts as ${options.participant}; a call cannot name another from (${JSON.stringify(args.from)}).`
1009
+ }]
1010
+ });
1011
+ }
1012
+ args.from = options.participant;
1013
+ }
993
1014
  const envelope = {
994
1015
  jsonrpc: "2.0",
995
1016
  id: nextId(),