cellium-mcp-client 1.1.0 → 1.1.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/cli.js CHANGED
@@ -11,7 +11,7 @@ const program = new commander_1.Command();
11
11
  program
12
12
  .name('cellium-mcp-client')
13
13
  .description('MCP client for connecting to remote Cellium processor server')
14
- .version('1.1.0')
14
+ .version('1.1.2')
15
15
  .option('-t, --token <token>', 'Authentication token (format: user:username:hash)')
16
16
  .option('-e, --endpoint <url>', 'Server endpoint URL', 'http://localhost:3000/mcp')
17
17
  .option('-v, --verbose', 'Enable verbose logging')
package/dist/client.js CHANGED
@@ -30,6 +30,17 @@ const PingSchema = zod_1.z.object({
30
30
  method: zod_1.z.literal('ping'),
31
31
  params: zod_1.z.object({}).optional()
32
32
  });
33
+ const InitializeSchema = zod_1.z.object({
34
+ method: zod_1.z.literal('initialize'),
35
+ params: zod_1.z.object({
36
+ protocolVersion: zod_1.z.string(),
37
+ capabilities: zod_1.z.object({}).passthrough()
38
+ })
39
+ });
40
+ const InitializedNotificationSchema = zod_1.z.object({
41
+ method: zod_1.z.literal('notifications/initialized'),
42
+ params: zod_1.z.object({}).optional()
43
+ });
33
44
  class CelliumMCPClient {
34
45
  config;
35
46
  localServer;
@@ -54,39 +65,100 @@ class CelliumMCPClient {
54
65
  this.setupServer();
55
66
  }
56
67
  setupServer() {
57
- // Register a dynamic tool handler that forwards all tool calls to remote server
58
- this.localServer.registerTool('cellium-proxy-tool', {
59
- description: 'Proxy tool for Cellium server - handles all tool calls dynamically'
60
- }, async (_args) => {
61
- // This won't actually be called since we override the request handlers directly
62
- return { content: [{ type: 'text', text: 'Proxy tool' }] };
68
+ // Handle MCP initialization
69
+ this.localServer.server.setRequestHandler(InitializeSchema, async (_request) => {
70
+ this.config.logger.debug('Received initialize request');
71
+ return {
72
+ protocolVersion: '2024-11-05',
73
+ capabilities: {
74
+ tools: {},
75
+ resources: {}
76
+ },
77
+ serverInfo: {
78
+ name: 'cellium-mcp-client',
79
+ version: '1.1.2'
80
+ }
81
+ };
63
82
  });
64
83
  // Override the underlying server's tool request handlers to proxy to remote
65
84
  this.localServer.server.setRequestHandler(ToolsListSchema, async () => {
66
- this.config.logger.debug('Proxying tools/list to remote server');
67
- const result = await this.makeHttpRequest('tools/list', {});
68
- return result;
85
+ try {
86
+ this.config.logger.debug('Proxying tools/list to remote server');
87
+ const result = await this.makeHttpRequest('tools/list', {});
88
+ this.config.logger.debug({ result }, 'tools/list result from remote server');
89
+ return result;
90
+ }
91
+ catch (error) {
92
+ this.config.logger.error({ error }, 'Error proxying tools/list');
93
+ // Return empty tools list instead of throwing to prevent transport closure
94
+ return { tools: [] };
95
+ }
69
96
  });
70
97
  this.localServer.server.setRequestHandler(ToolsCallSchema, async (request) => {
71
- this.config.logger.debug({ toolName: request.params?.name }, 'Proxying tool call to remote server');
72
- const result = await this.makeHttpRequest('tools/call', request.params);
73
- return result;
98
+ try {
99
+ this.config.logger.debug({ toolName: request.params?.name }, 'Proxying tool call to remote server');
100
+ const result = await this.makeHttpRequest('tools/call', request.params);
101
+ return result;
102
+ }
103
+ catch (error) {
104
+ this.config.logger.error({ error, toolName: request.params?.name }, 'Error proxying tool call');
105
+ // Return error result instead of throwing
106
+ return {
107
+ content: [{
108
+ type: 'text',
109
+ text: `Error calling tool: ${error instanceof Error ? error.message : 'Unknown error'}`
110
+ }],
111
+ isError: true
112
+ };
113
+ }
74
114
  });
75
115
  // Handle resources as well
76
116
  this.localServer.server.setRequestHandler(ResourcesListSchema, async () => {
77
- this.config.logger.debug('Proxying resources/list to remote server');
78
- const result = await this.makeHttpRequest('resources/list', {});
79
- return result;
117
+ try {
118
+ this.config.logger.debug('Proxying resources/list to remote server');
119
+ const result = await this.makeHttpRequest('resources/list', {});
120
+ return result;
121
+ }
122
+ catch (error) {
123
+ this.config.logger.error({ error }, 'Error proxying resources/list');
124
+ // Return empty resources list instead of throwing
125
+ return { resources: [] };
126
+ }
80
127
  });
81
128
  this.localServer.server.setRequestHandler(ResourcesReadSchema, async (request) => {
82
- this.config.logger.debug({ uri: request.params?.uri }, 'Proxying resources/read to remote server');
83
- const result = await this.makeHttpRequest('resources/read', request.params);
84
- return result;
129
+ try {
130
+ this.config.logger.debug({ uri: request.params?.uri }, 'Proxying resources/read to remote server');
131
+ const result = await this.makeHttpRequest('resources/read', request.params);
132
+ return result;
133
+ }
134
+ catch (error) {
135
+ this.config.logger.error({ error, uri: request.params?.uri }, 'Error proxying resources/read');
136
+ // Return error result instead of throwing
137
+ return {
138
+ contents: [{
139
+ uri: request.params?.uri || '',
140
+ mimeType: 'text/plain',
141
+ text: `Error reading resource: ${error instanceof Error ? error.message : 'Unknown error'}`
142
+ }]
143
+ };
144
+ }
85
145
  });
86
146
  // Handle ping
87
147
  this.localServer.server.setRequestHandler(PingSchema, async () => {
88
- const result = await this.makeHttpRequest('ping', {});
89
- return result;
148
+ try {
149
+ const result = await this.makeHttpRequest('ping', {});
150
+ return result;
151
+ }
152
+ catch (error) {
153
+ this.config.logger.error({ error }, 'Error proxying ping');
154
+ // Return empty result instead of throwing
155
+ return {};
156
+ }
157
+ });
158
+ // Handle other common MCP methods
159
+ this.localServer.server.setNotificationHandler(InitializedNotificationSchema, async () => {
160
+ this.config.logger.debug('Received initialized notification');
161
+ // No response needed for notifications
90
162
  });
91
163
  }
92
164
  async makeHttpRequest(method, params) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cellium-mcp-client",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "MCP client for connecting to remote Cellium processor server",
5
5
  "main": "dist/index.js",
6
6
  "bin": {