@ui-calling/mcp 0.1.0-preview.0 → 0.1.0-preview.2

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.js CHANGED
@@ -2,7 +2,7 @@
2
2
  import { Server } from "@modelcontextprotocol/sdk/server";
3
3
  import { CallToolRequestSchema, ListToolsRequestSchema } from "@modelcontextprotocol/sdk/types.js";
4
4
  function createUiCallingMcpServer(ui, opts) {
5
- const server = new Server({ name: opts.name ?? "ui-calling", version: opts.version ?? "0.1.0-preview.0" }, { capabilities: { tools: {} } });
5
+ const server = new Server({ name: opts.name ?? "ui-calling", version: opts.version ?? "0.1.0-preview.1" }, { capabilities: { tools: {} } });
6
6
  const visible = () => ui.tools({ woken: opts.staySilent, filter: opts.filter });
7
7
  server.setRequestHandler(ListToolsRequestSchema, async () => ({
8
8
  tools: visible().map((t) => ({
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { SurfaceLink, UiCalling, Who } from \"@ui-calling/core\";\n\ntype CallExtra = Parameters<Parameters<Server[\"setRequestHandler\"]>[1]>[1];\n\nexport type McpAdapterOptions = {\n name?: string;\n version?: string;\n /**\n * Who a tool call is for. MCP has no notion of your end user, so derive it from the request,\n * e.g. from `extra.authInfo` (the authenticated user) and `extra.sessionId`.\n */\n who: (extra: CallExtra) => Who | Promise<Who>;\n /** Called with every link a tool call creates. */\n onLink?: (link: SurfaceLink) => void;\n filter?: (toolName: string) => boolean;\n /**\n * Also list `stay_silent`, for a host that runs the model on screen events without a user message.\n * MCP tool lists don't change per turn, so its description tells the model it's only for those turns.\n */\n staySilent?: boolean;\n /** Called when the model calls `stay_silent`: the host should send nothing this turn. */\n onSilent?: (reason: string) => void;\n};\n\n/**\n * An MCP server whose tools are your surfaces. Connect it to any transport:\n *\n * const server = createUiCallingMcpServer(ui, {\n * // One conversation per client session, never a shared fallback: events would mix between users.\n * who: (extra) => {\n * if (!extra.sessionId) throw new Error(\"This server needs a session ID per client\");\n * return { conversationId: extra.sessionId, subject: userFrom(extra.authInfo) };\n * },\n * });\n * await server.connect(new StdioServerTransport());\n *\n * MCP clients usually show the model's text, so create the runtime with `deliverLinks: \"message\"`\n * to have the model include the URL in its reply.\n */\nexport function createUiCallingMcpServer(ui: UiCalling, opts: McpAdapterOptions) {\n const server = new Server({ name: opts.name ?? \"ui-calling\", version: opts.version ?? \"0.1.0-preview.0\" }, { capabilities: { tools: {} } });\n const visible = () => ui.tools({ woken: opts.staySilent, filter: opts.filter });\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: visible().map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: t.input_schema as { type: \"object\"; properties?: Record<string, object> },\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n const name = request.params.name;\n if (!visible().some((t) => t.name === name)) {\n return { content: [{ type: \"text\" as const, text: JSON.stringify({ status: \"error\", code: \"unknown_tool\", message: `No tool ${name}` }) }], isError: true };\n }\n const run = await ui.runTool(name, request.params.arguments ?? {}, await opts.who(extra));\n if (run.ok && run.silent) opts.onSilent?.(run.reason);\n else if (run.ok) opts.onLink?.(run.link);\n return { content: [{ type: \"text\" as const, text: run.content }], isError: !run.ok };\n });\n\n return server;\n}\n"],"mappings":";AAAA,SAAS,cAAc;AACvB,SAAS,uBAAuB,8BAA8B;AAwCvD,SAAS,yBAAyB,IAAe,MAAyB;AAC/E,QAAM,SAAS,IAAI,OAAO,EAAE,MAAM,KAAK,QAAQ,cAAc,SAAS,KAAK,WAAW,kBAAkB,GAAG,EAAE,cAAc,EAAE,OAAO,CAAC,EAAE,EAAE,CAAC;AAC1I,QAAM,UAAU,MAAM,GAAG,MAAM,EAAE,OAAO,KAAK,YAAY,QAAQ,KAAK,OAAO,CAAC;AAE9E,SAAO,kBAAkB,wBAAwB,aAAa;AAAA,IAC5D,OAAO,QAAQ,EAAE,IAAI,CAAC,OAAO;AAAA,MAC3B,MAAM,EAAE;AAAA,MACR,aAAa,EAAE;AAAA,MACf,aAAa,EAAE;AAAA,IACjB,EAAE;AAAA,EACJ,EAAE;AAEF,SAAO,kBAAkB,uBAAuB,OAAO,SAAS,UAAU;AACxE,UAAM,OAAO,QAAQ,OAAO;AAC5B,QAAI,CAAC,QAAQ,EAAE,KAAK,CAAC,MAAM,EAAE,SAAS,IAAI,GAAG;AAC3C,aAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,KAAK,UAAU,EAAE,QAAQ,SAAS,MAAM,gBAAgB,SAAS,WAAW,IAAI,GAAG,CAAC,EAAE,CAAC,GAAG,SAAS,KAAK;AAAA,IAC5J;AACA,UAAM,MAAM,MAAM,GAAG,QAAQ,MAAM,QAAQ,OAAO,aAAa,CAAC,GAAG,MAAM,KAAK,IAAI,KAAK,CAAC;AACxF,QAAI,IAAI,MAAM,IAAI,OAAQ,MAAK,WAAW,IAAI,MAAM;AAAA,aAC3C,IAAI,GAAI,MAAK,SAAS,IAAI,IAAI;AACvC,WAAO,EAAE,SAAS,CAAC,EAAE,MAAM,QAAiB,MAAM,IAAI,QAAQ,CAAC,GAAG,SAAS,CAAC,IAAI,GAAG;AAAA,EACrF,CAAC;AAED,SAAO;AACT;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["import { Server } from \"@modelcontextprotocol/sdk/server\";\nimport { CallToolRequestSchema, ListToolsRequestSchema } from \"@modelcontextprotocol/sdk/types.js\";\nimport type { SurfaceLink, UiCalling, Who } from \"@ui-calling/core\";\n\ntype CallExtra = Parameters<Parameters<Server[\"setRequestHandler\"]>[1]>[1];\n\nexport type McpAdapterOptions = {\n name?: string;\n version?: string;\n /**\n * Who a tool call is for. MCP has no notion of your end user, so derive it from the request,\n * e.g. from `extra.authInfo` (the authenticated user) and `extra.sessionId`.\n */\n who: (extra: CallExtra) => Who | Promise<Who>;\n /** Called with every link a tool call creates. */\n onLink?: (link: SurfaceLink) => void;\n filter?: (toolName: string) => boolean;\n /**\n * Also list `stay_silent`, for a host that runs the model on screen events without a user message.\n * MCP tool lists don't change per turn, so its description tells the model it's only for those turns.\n */\n staySilent?: boolean;\n /** Called when the model calls `stay_silent`: the host should send nothing this turn. */\n onSilent?: (reason: string) => void;\n};\n\n/**\n * An MCP server whose tools are your surfaces. Connect it to any transport:\n *\n * const server = createUiCallingMcpServer(ui, {\n * // One conversation per client session, never a shared fallback: events would mix between users.\n * who: (extra) => {\n * if (!extra.sessionId) throw new Error(\"This server needs a session ID per client\");\n * return { conversationId: extra.sessionId, subject: userFrom(extra.authInfo) };\n * },\n * });\n * await server.connect(new StdioServerTransport());\n *\n * MCP clients usually show the model's text, so create the runtime with `deliverLinks: \"message\"`\n * to have the model include the URL in its reply.\n */\nexport function createUiCallingMcpServer(ui: UiCalling, opts: McpAdapterOptions) {\n const server = new Server({ name: opts.name ?? \"ui-calling\", version: opts.version ?? \"0.1.0-preview.1\" }, { capabilities: { tools: {} } });\n const visible = () => ui.tools({ woken: opts.staySilent, filter: opts.filter });\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: visible().map((t) => ({\n name: t.name,\n description: t.description,\n inputSchema: t.input_schema as { type: \"object\"; properties?: Record<string, object> },\n })),\n }));\n\n server.setRequestHandler(CallToolRequestSchema, async (request, extra) => {\n const name = request.params.name;\n if (!visible().some((t) => t.name === name)) {\n return { content: [{ type: \"text\" as const, text: JSON.stringify({ status: \"error\", code: \"unknown_tool\", message: `No tool ${name}` }) }], isError: true };\n }\n const run = await ui.runTool(name, request.params.arguments ?? {}, await opts.who(extra));\n if (run.ok && run.silent) opts.onSilent?.(run.reason);\n else if (run.ok) opts.onLink?.(run.link);\n return { content: [{ type: \"text\" as const, text: run.content }], isError: !run.ok };\n });\n\n return server;\n}\n"],"mappings":";AAAA,SAAS,cAAc;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ui-calling/mcp",
3
- "version": "0.1.0-preview.0",
3
+ "version": "0.1.0-preview.2",
4
4
  "description": "Expose ui-calling surfaces as tools on an MCP server, so any MCP client can open screens.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -48,7 +48,7 @@
48
48
  "removeNodeProtocol": false
49
49
  },
50
50
  "dependencies": {
51
- "@ui-calling/core": "^0.1.0-preview.0"
51
+ "@ui-calling/core": "^0.1.0-preview.2"
52
52
  },
53
53
  "peerDependencies": {
54
54
  "@modelcontextprotocol/sdk": ">=1.20.0"