Skip to content

Commit b5c5b9a

Browse files
committed
Enhance MCPServer to support additional Java options for TLC execution.
- Added `extraJavaOpts` parameter to allow users to specify custom Java options for the JVM. This feature e.g. adds support for time-boxing the _check command. [Feature] Signed-off-by: Markus Alexander Kuppe <[email protected]>
1 parent f2eebe8 commit b5c5b9a

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/lm/MCPServer.ts

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -633,15 +633,18 @@ export class MCPServer implements vscode.Disposable {
633633
fileName: z.string().describe('The full path to the file containing the TLA+ module to parse.'),
634634
cfgFile: z.string().optional().describe('Optional path to a custom TLC configuration file.'),
635635
// eslint-disable-next-line max-len
636-
extraOpts: z.array(z.string()).optional().describe('Optional array of additional command-line options to pass to TLC beyond [-modelcheck].')
636+
extraOpts: z.array(z.string()).optional().describe('Optional array of additional command-line options to pass to TLC beyond [-modelcheck].'),
637+
// eslint-disable-next-line max-len
638+
extraJavaOpts: z.array(z.string()).optional().describe('Optional array of additional Java options to pass to the JVM (e.g., ["-Xmx4g", "-Dtlc2.TLC.stopAfter=60"]).')
637639
},
638-
async ({ fileName, cfgFile, extraOpts }) => {
640+
async ({ fileName, cfgFile, extraOpts, extraJavaOpts }) => {
639641
const absolutePath = this.resolveFilePath(fileName);
640642
const validatedPath = this.validateWorkspacePath(absolutePath);
641643
const cfgFilePath = cfgFile ? this.validateWorkspacePath(this.resolveFilePath(cfgFile)) : undefined;
642644
// Prepend the command line argument ['-modelcheck'] to extra opts.
643645
const options = extraOpts ? ['-cleanup', '-modelcheck', ...extraOpts] : ['-cleanup', '-modelcheck'];
644-
return this.runTLCInMCP(validatedPath, options, [], cfgFilePath);
646+
const javaOpts = extraJavaOpts || [];
647+
return this.runTLCInMCP(validatedPath, options, javaOpts, cfgFilePath);
645648
}
646649
);
647650

@@ -653,15 +656,18 @@ export class MCPServer implements vscode.Disposable {
653656
fileName: z.string().describe('The full path to the file containing the TLA+ module to parse.'),
654657
cfgFile: z.string().optional().describe('Optional path to a custom TLC configuration file.'),
655658
// eslint-disable-next-line max-len
656-
extraOpts: z.array(z.string()).optional().describe('Optional array of additional command-line options to pass to TLC beyond [-simulate].')
659+
extraOpts: z.array(z.string()).optional().describe('Optional array of additional command-line options to pass to TLC beyond [-simulate].'),
660+
// eslint-disable-next-line max-len
661+
extraJavaOpts: z.array(z.string()).optional().describe('Optional array of additional Java options to pass to the JVM (e.g., ["-Xmx4g"]). Note: -Dtlc2.TLC.stopAfter=3 is set by default.')
657662
},
658-
async ({ fileName, cfgFile, extraOpts }) => {
663+
async ({ fileName, cfgFile, extraOpts, extraJavaOpts }) => {
659664
const absolutePath = this.resolveFilePath(fileName);
660665
const validatedPath = this.validateWorkspacePath(absolutePath);
661666
const cfgFilePath = cfgFile ? this.validateWorkspacePath(this.resolveFilePath(cfgFile)) : undefined;
662667
// Prepend the command line argument ['-modelcheck'] to extra opts.
663668
const options = extraOpts ? ['-cleanup', '-simulate', ...extraOpts] : ['-cleanup', '-simulate'];
664-
return this.runTLCInMCP(validatedPath, options, ['-Dtlc2.TLC.stopAfter=3'], cfgFilePath);
669+
const javaOpts = ['-Dtlc2.TLC.stopAfter=3', ...(extraJavaOpts || [])];
670+
return this.runTLCInMCP(validatedPath, options, javaOpts, cfgFilePath);
665671
}
666672
);
667673

@@ -674,20 +680,23 @@ export class MCPServer implements vscode.Disposable {
674680
cfgFile: z.string().optional().describe('Optional path to a custom TLC configuration file.'),
675681
// eslint-disable-next-line max-len
676682
extraOpts: z.array(z.string()).optional().describe('Optional array of additional command-line options to pass to TLC beyond [-simulate, -invlevel].'),
683+
// eslint-disable-next-line max-len
684+
extraJavaOpts: z.array(z.string()).optional().describe('Optional array of additional Java options to pass to the JVM (e.g., ["-Xmx4g"]). Note: -Dtlc2.TLC.stopAfter=3 is set by default.'),
677685
behaviorLength: z.number().min(1).describe('The length of the behavior to generate.')
678686
},
679-
async ({ fileName, behaviorLength, cfgFile, extraOpts }) => {
687+
async ({ fileName, behaviorLength, cfgFile, extraOpts, extraJavaOpts }) => {
680688
const absolutePath = this.resolveFilePath(fileName);
681689
const validatedPath = this.validateWorkspacePath(absolutePath);
682690
const cfgFilePath = cfgFile ? this.validateWorkspacePath(this.resolveFilePath(cfgFile)) : undefined;
683691
// Prepend the command line argument ['-modelcheck'] to extra opts.
684692
const options = extraOpts ?
685693
['-cleanup', '-simulate', '-invlevel', behaviorLength.toString(), ...extraOpts] :
686694
['-cleanup', '-simulate', '-invlevel', behaviorLength.toString()];
695+
const javaOpts = ['-Dtlc2.TLC.stopAfter=3', ...(extraJavaOpts || [])];
687696
return this.runTLCInMCP(
688697
validatedPath,
689698
options,
690-
['-Dtlc2.TLC.stopAfter=3'],
699+
javaOpts,
691700
cfgFilePath
692701
);
693702
}

0 commit comments

Comments
 (0)