@dolusoft/claude-collab 0.1.2 → 0.1.5
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 +62 -7
- package/dist/cli.js.map +1 -1
- package/dist/mcp-main.js +62 -7
- package/dist/mcp-main.js.map +1 -1
- package/package.json +1 -1
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';
|
|
@@ -2010,20 +2011,74 @@ function registerReplyTool(server, hubClient) {
|
|
|
2010
2011
|
|
|
2011
2012
|
// src/presentation/mcp/server.ts
|
|
2012
2013
|
function createMcpServer(options) {
|
|
2013
|
-
const
|
|
2014
|
-
|
|
2015
|
-
|
|
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}`);
|
|
2016
2064
|
});
|
|
2017
|
-
registerJoinTool(server, options.hubClient);
|
|
2018
|
-
registerAskTool(server, options.hubClient);
|
|
2019
|
-
registerInboxTool(server, options.hubClient);
|
|
2020
|
-
registerReplyTool(server, options.hubClient);
|
|
2021
2065
|
return server;
|
|
2022
2066
|
}
|
|
2023
2067
|
async function startMcpServer(options) {
|
|
2068
|
+
const { hubClient } = options;
|
|
2024
2069
|
const server = createMcpServer(options);
|
|
2025
2070
|
const transport = new StdioServerTransport();
|
|
2026
2071
|
await server.connect(transport);
|
|
2072
|
+
hubClient.events.onQuestion = async (question) => {
|
|
2073
|
+
await server.notification({
|
|
2074
|
+
method: "notifications/resources/updated",
|
|
2075
|
+
params: {
|
|
2076
|
+
uri: "inbox://questions"
|
|
2077
|
+
}
|
|
2078
|
+
});
|
|
2079
|
+
console.error(`[\u{1F4EC} New Question] From: ${question.from.displayName}`);
|
|
2080
|
+
console.error(`[\u{1F4A1} Tip] Check your inbox with: inbox()`);
|
|
2081
|
+
};
|
|
2027
2082
|
}
|
|
2028
2083
|
async function isHubRunning(host = config.hub.host, port = config.hub.port) {
|
|
2029
2084
|
return new Promise((resolve) => {
|