@@ -284,7 +284,7 @@ async def server_lifespan(_server: Server) -> AsyncIterator[SemgrepContext]:
284284 # Initialize resources on startup with tracing
285285 # MCP requires Pro Engine
286286 with start_tracing ("mcp-python-server" ) as span :
287- process = await run_semgrep_process (["mcp" , "--pro" , "--debug" ])
287+ process = await run_semgrep_process (top_level_span = span , args = ["mcp" , "--pro" , "--debug" ])
288288
289289 try :
290290 yield SemgrepContext (process = process , top_level_span = span )
@@ -350,7 +350,7 @@ async def get_supported_languages() -> list[str]:
350350 args = ["show" , "supported-languages" , "--experimental" ]
351351
352352 # Parse output and return list of languages
353- languages = await run_semgrep (args )
353+ languages = await run_semgrep (top_level_span = None , args = args )
354354 return [lang .strip () for lang in languages .strip ().split ("\n " ) if lang .strip ()]
355355
356356
@@ -586,7 +586,7 @@ async def semgrep_scan_with_custom_rule(
586586
587587 # Run semgrep scan with custom rule
588588 args = get_semgrep_scan_args (temp_dir , rule_file_path )
589- output = await run_semgrep (args )
589+ output = await run_semgrep (top_level_span = None , args = args )
590590 results : SemgrepScanResult = SemgrepScanResult .model_validate_json (output )
591591 remove_temp_dir_from_results (results , temp_dir )
592592 return results
@@ -631,7 +631,7 @@ async def semgrep_scan(
631631 # Create temporary files from code content
632632 temp_dir = create_temp_files_from_code_content (code_files )
633633 args = get_semgrep_scan_args (temp_dir , config )
634- output = await run_semgrep (args )
634+ output = await run_semgrep (top_level_span = None , args = args )
635635 results : SemgrepScanResult = SemgrepScanResult .model_validate_json (output )
636636 remove_temp_dir_from_results (results , temp_dir )
637637 return results
@@ -731,7 +731,7 @@ async def semgrep_scan_local(
731731 results = []
732732 for cf in code_files :
733733 args = get_semgrep_scan_args (cf .path , config )
734- output = await run_semgrep (args )
734+ output = await run_semgrep (top_level_span = None , args = args )
735735 result : SemgrepScanResult = SemgrepScanResult .model_validate_json (output )
736736 results .append (result )
737737 return results
@@ -787,7 +787,7 @@ async def security_check(
787787 # Create temporary files from code content
788788 temp_dir = create_temp_files_from_code_content (code_files )
789789 args = get_semgrep_scan_args (temp_dir )
790- output = await run_semgrep (args )
790+ output = await run_semgrep (top_level_span = None , args = args )
791791 results : SemgrepScanResult = SemgrepScanResult .model_validate_json (output )
792792 remove_temp_dir_from_results (results , temp_dir )
793793
@@ -850,7 +850,7 @@ async def get_abstract_syntax_tree(
850850 "--json" ,
851851 temp_file_path ,
852852 ]
853- return await run_semgrep (args )
853+ return await run_semgrep (top_level_span = None , args = args )
854854
855855 except McpError as e :
856856 raise e
0 commit comments