@dolusoft/claude-collab 0.1.1 → 0.1.3

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/cli.js CHANGED
@@ -4,6 +4,7 @@ import WebSocket2, { WebSocketServer, WebSocket } from 'ws';
4
4
  import { v4 } from 'uuid';
5
5
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
6
6
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
7
+ import { ListResourcesRequestSchema, ReadResourceRequestSchema } from '@modelcontextprotocol/sdk/types.js';
7
8
  import { z } from 'zod';
8
9
  import { spawn } from 'child_process';
9
10
  import { createConnection } from 'net';
@@ -1646,12 +1647,13 @@ var HubClient = class {
1646
1647
  format,
1647
1648
  requestId
1648
1649
  });
1649
- await this.waitForResponse(
1650
+ const questionSent = await this.waitForResponse(
1650
1651
  (msg) => msg.type === "QUESTION_SENT" && "requestId" in msg && msg.requestId === requestId,
1651
1652
  5e3
1652
1653
  );
1654
+ const questionId = questionSent.questionId;
1653
1655
  const answer = await this.waitForResponse(
1654
- (msg) => msg.type === "ANSWER",
1656
+ (msg) => msg.type === "ANSWER" && msg.questionId === questionId,
1655
1657
  timeoutMs
1656
1658
  );
1657
1659
  return answer;
@@ -2009,20 +2011,71 @@ function registerReplyTool(server, hubClient) {
2009
2011
 
2010
2012
  // src/presentation/mcp/server.ts
2011
2013
  function createMcpServer(options) {
2012
- const server = new McpServer({
2013
- name: "claude-collab",
2014
- version: "0.1.0"
2014
+ const { hubClient } = options;
2015
+ const server = new McpServer(
2016
+ {
2017
+ name: "claude-collab",
2018
+ version: "0.1.2"
2019
+ },
2020
+ {
2021
+ capabilities: {
2022
+ resources: {
2023
+ subscribe: true,
2024
+ listChanged: true
2025
+ }
2026
+ }
2027
+ }
2028
+ );
2029
+ registerJoinTool(server, hubClient);
2030
+ registerAskTool(server, hubClient);
2031
+ registerInboxTool(server, hubClient);
2032
+ registerReplyTool(server, hubClient);
2033
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
2034
+ return {
2035
+ resources: [
2036
+ {
2037
+ uri: "inbox://questions",
2038
+ name: "Pending Questions",
2039
+ description: "Your inbox of pending questions from other teams",
2040
+ mimeType: "application/json"
2041
+ }
2042
+ ]
2043
+ };
2044
+ });
2045
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
2046
+ if (request.params.uri === "inbox://questions") {
2047
+ try {
2048
+ const inbox = await hubClient.getInbox();
2049
+ return {
2050
+ contents: [
2051
+ {
2052
+ uri: "inbox://questions",
2053
+ mimeType: "application/json",
2054
+ text: JSON.stringify(inbox, null, 2)
2055
+ }
2056
+ ]
2057
+ };
2058
+ } catch (error) {
2059
+ const errorMessage = error instanceof Error ? error.message : "Unknown error";
2060
+ throw new Error(`Failed to read inbox: ${errorMessage}`);
2061
+ }
2062
+ }
2063
+ throw new Error(`Unknown resource URI: ${request.params.uri}`);
2015
2064
  });
2016
- registerJoinTool(server, options.hubClient);
2017
- registerAskTool(server, options.hubClient);
2018
- registerInboxTool(server, options.hubClient);
2019
- registerReplyTool(server, options.hubClient);
2020
2065
  return server;
2021
2066
  }
2022
2067
  async function startMcpServer(options) {
2068
+ const { hubClient } = options;
2023
2069
  const server = createMcpServer(options);
2024
2070
  const transport = new StdioServerTransport();
2025
2071
  await server.connect(transport);
2072
+ hubClient.events.onQuestion = async (question) => {
2073
+ await server.sendResourceUpdated({
2074
+ uri: "inbox://questions"
2075
+ });
2076
+ console.error(`[\u{1F4EC} New Question] From: ${question.from.displayName}`);
2077
+ console.error(`[\u{1F4A1} Tip] Check your inbox with: inbox()`);
2078
+ };
2026
2079
  }
2027
2080
  async function isHubRunning(host = config.hub.host, port = config.hub.port) {
2028
2081
  return new Promise((resolve) => {