@codesys/mcp-toolkit 1.5.5 → 1.5.6

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/CHANGELOG.md CHANGED
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [1.5.6] - 2025-05-02
9
+ ### Fixed
10
+ - Fixed session manager null reference error in interop.ts
11
+ - Added additional null checks for session manager
12
+ - Improved error handling when session manager is undefined
13
+
8
14
  ## [1.5.5] - 2025-05-02
9
15
  ### Fixed
10
16
  - Added enhanced command.json file verification to debug session communication
package/dist/server.js CHANGED
@@ -120,35 +120,49 @@ function startMcpServer(config) {
120
120
  // Default to true if not specified
121
121
  const enableSessionManagement = config.enableSessionManagement !== false;
122
122
  console.error(`SERVER.TS: Session management is ${enableSessionManagement ? 'enabled' : 'disabled'}`);
123
- // Create session manager instance
124
- let sessionManager;
123
+ // Create session manager instance (will remain undefined if session management is disabled)
124
+ let sessionManager = undefined;
125
125
  if (enableSessionManagement) {
126
- sessionManager = new sessionManager_1.CodesysSessionManager(codesysExePath, codesysProfileName);
127
- console.error('SERVER.TS: Session manager initialized');
128
- // Only start a session if explicitly enabled
129
126
  try {
130
- // Check if session is already active
131
- console.error('SERVER.TS: Checking if session is already active...');
132
- const isActive = (0, direct_session_command_1.isSessionActive)();
133
- if (isActive) {
134
- console.error('SERVER.TS: Session is already active');
127
+ sessionManager = new sessionManager_1.CodesysSessionManager(codesysExePath, codesysProfileName);
128
+ console.error('SERVER.TS: Session manager initialized');
129
+ // Only start a session if explicitly enabled and manager was created successfully
130
+ if (sessionManager) {
131
+ try {
132
+ // Check if session is already active
133
+ console.error('SERVER.TS: Checking if session is already active...');
134
+ const isActive = (0, direct_session_command_1.isSessionActive)();
135
+ if (isActive) {
136
+ console.error('SERVER.TS: Session is already active');
137
+ }
138
+ else {
139
+ console.error('SERVER.TS: Session not active, starting new session...');
140
+ console.error('SERVER.TS: IMPORTANT: If CODESYS hangs during session startup, use --no-session flag');
141
+ yield sessionManager.startSession();
142
+ console.error('SERVER.TS: Session start initiated');
143
+ }
144
+ }
145
+ catch (error) {
146
+ console.error(`SERVER.TS: Error starting session: ${error.message}`);
147
+ console.error('SERVER.TS: Will fallback to one-time execution for operations');
148
+ // Continue without session, will fallback to one-time execution
149
+ }
135
150
  }
136
151
  else {
137
- console.error('SERVER.TS: Session not active, starting new session...');
138
- console.error('SERVER.TS: IMPORTANT: If CODESYS hangs during session startup, use --no-session flag');
139
- yield sessionManager.startSession();
140
- console.error('SERVER.TS: Session start initiated');
152
+ console.error('SERVER.TS: Session manager creation failed');
141
153
  }
142
154
  }
143
155
  catch (error) {
144
- console.error(`SERVER.TS: Error starting session: ${error.message}`);
156
+ console.error(`SERVER.TS: Failed to create session manager: ${error.message}`);
145
157
  console.error('SERVER.TS: Will fallback to one-time execution for operations');
146
- // Continue without session, will fallback to one-time execution
158
+ sessionManager = undefined;
147
159
  }
148
160
  }
149
161
  else {
150
162
  console.error('SERVER.TS: Session management is disabled, will use one-time script execution');
151
- sessionManager = undefined;
163
+ }
164
+ if (!sessionManager) {
165
+ console.error('SERVER.TS: Session manager is not available - one-time script execution will be used');
152
166
  }
153
167
  // --- End Session Manager Initialization ---
154
168
  // --- Preload script templates ---
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codesys/mcp-toolkit",
3
- "version": "1.5.5",
3
+ "version": "1.5.6",
4
4
  "description": "Model Context Protocol (MCP) server for CODESYS automation platform",
5
5
  "main": "dist/server.js",
6
6
  "bin": {