@@ -17,71 +17,71 @@ function LLMBenchServer(;
1717)
1818 # Create base MCP server
1919 server = ClaudeMCPTools. MCPServer (name= name, version= version)
20-
20+
2121 # Add basic tools if requested
2222 if include_basic_tools
2323 ClaudeMCPTools. register_tool! (server, " bash" , ClaudeMCPTools. BashTool (working_dir= working_dir))
24- ClaudeMCPTools. register_tool! (server, " str_replace_editor" ,
24+ ClaudeMCPTools. register_tool! (server, " str_replace_editor" ,
2525 ClaudeMCPTools. StrReplaceEditorTool (base_path= working_dir))
2626 end
27-
27+
2828 # Add setup_problem tool if function provided
2929 if setup_fn != = nothing
30- ClaudeMCPTools. register_tool! (server, " setup_problem" ,
30+ ClaudeMCPTools. register_tool! (server, " setup_problem" ,
3131 SetupProblemTool (setup_fn, working_dir= working_dir))
3232 end
33-
33+
3434 # Add grade_problem tool if function provided
3535 if grade_fn != = nothing
3636 ClaudeMCPTools. register_tool! (server, " grade_problem" ,
3737 GradeProblemTool (grade_fn, working_dir= working_dir))
3838 end
39-
39+
4040 return server
4141end
4242
4343# Main entry point for the LLMBenchMCPServer.
4444# Usage: julia --project -m LLMBenchMCPServer ModuleName [--workdir /path]
45- function main (args= ARGS )
45+ function @ main (args)
4646 # Handle both array and varargs inputs
4747 if isa (args, Tuple)
4848 args = collect (args)
4949 end
5050 if isempty (args) || (length (args) == 1 && args[1 ] in [" --help" , " -h" ])
5151 println ("""
5252 LLMBenchMCPServer - MCP server for LLM benchmarking
53-
53+
5454 Usage:
5555 julia --project -m LLMBenchMCPServer ModuleName [options]
56-
56+
5757 Arguments:
5858 ModuleName Name of the module containing setup_problem and grade functions
59-
59+
6060 Options:
6161 --workdir PATH Working directory (default: current directory)
6262 --no-basic-tools Disable basic tools (bash, str_replace_editor)
6363 --verbose Enable verbose output
6464 --help, -h Show this help message
65-
65+
6666 The specified module should export:
6767 - setup_problem(workdir::String) -> String/Dict
6868 Returns the problem description
69-
69+
7070 - grade(workdir::String, transcript::String) -> Dict/Number
7171 Returns grading result with subscores, weights, and total score
72-
72+
7373 Example:
7474 julia --project -m LLMBenchMCPServer MyBenchmark
7575 """ )
7676 return 0
7777 end
78-
78+
7979 # Parse arguments
8080 module_name = args[1 ]
8181 working_dir = pwd ()
8282 include_basic_tools = true
8383 verbose = false
84-
84+
8585 i = 2
8686 while i <= length (args)
8787 if args[i] == " --workdir" && i + 1 <= length (args)
@@ -98,45 +98,48 @@ function main(args=ARGS)
9898 i += 1
9999 end
100100 end
101-
101+
102102 # Ensure working directory exists
103103 if ! isdir (working_dir)
104104 mkpath (working_dir)
105105 end
106-
106+
107107 # Load the module
108108 try
109109 # Try to load the module
110110 mod_symbol = Symbol (module_name)
111111
112- # First check if it's already loaded
113- if ! isdefined (Main, mod_symbol)
114- # Try to import it
115- try
116- Base. eval (Main, :(using $ mod_symbol))
117- catch
118- # Maybe it's a local module that needs to be included
119- # Try common locations
112+ # Try to load the module using Base.require
113+ mod = try
114+ # First try to load it as a package in the current environment
115+ Base. require (Main, mod_symbol)
116+ catch
117+ # If that fails, check if it's already loaded
118+ if isdefined (Main, mod_symbol)
119+ getfield (Main, mod_symbol)
120+ else
121+ # Try to include it as a local file
122+ loaded = false
120123 for path in [" $module_name .jl" , " src/$module_name .jl" , " ../$module_name .jl" ]
121124 if isfile (path)
122125 include (abspath (path))
126+ loaded = true
123127 break
124128 end
125129 end
130+
131+ if loaded && isdefined (Main, mod_symbol)
132+ getfield (Main, mod_symbol)
133+ else
134+ error (" Could not load module: $module_name " )
135+ end
126136 end
127137 end
128-
129- # Get the module
130- if ! isdefined (Main, mod_symbol)
131- error (" Could not load module: $module_name " )
132- end
133-
134- mod = getfield (Main, mod_symbol)
135-
138+
136139 # Extract functions
137140 setup_fn = nothing
138141 grade_fn = nothing
139-
142+
140143 if isdefined (mod, :setup_problem )
141144 setup_fn = getfield (mod, :setup_problem )
142145 if verbose
@@ -145,7 +148,7 @@ function main(args=ARGS)
145148 else
146149 println (" Warning: No setup_problem function found in $module_name " )
147150 end
148-
151+
149152 if isdefined (mod, :grade )
150153 grade_fn = getfield (mod, :grade )
151154 if verbose
@@ -154,7 +157,7 @@ function main(args=ARGS)
154157 else
155158 println (" Warning: No grade function found in $module_name " )
156159 end
157-
160+
158161 # Create and run the server
159162 server = LLMBenchServer (
160163 name= " $module_name -MCP" ,
@@ -164,20 +167,20 @@ function main(args=ARGS)
164167 working_dir= working_dir,
165168 include_basic_tools= include_basic_tools
166169 )
167-
170+
168171 if verbose
169172 println (" Starting MCP server for $module_name " )
170173 println (" Working directory: $working_dir " )
171174 println (" Tools registered: $(keys (server. tools)) " )
172175 end
173-
176+
174177 # Run the server in stdio mode
175178 ClaudeMCPTools. run_stdio_server (server, verbose= verbose)
176-
179+
177180 catch e
178181 println (stderr , " Error: $e " )
179182 return 1
180183 end
181-
184+
182185 return 0
183- end
186+ end
0 commit comments