MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / main

Function main

scripts/test_mcp_interactive.py:323–408  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

321
322
323def main() -> int:
324 parser = argparse.ArgumentParser()
325 parser.add_argument("binary")
326 parser.add_argument(
327 "--scenario",
328 choices=("initialize", "invalid-index", "roundtrip", "advanced"),
329 required=True,
330 )
331 parser.add_argument("--repo-path", required=True)
332 parser.add_argument("--response-timeout", type=float, default=45.0)
333 parser.add_argument("--exit-timeout", type=float, default=15.0)
334 args = parser.parse_args()
335
336 try:
337 command = mcp_command(args.binary)
338 process = subprocess.Popen(
339 command,
340 stdin=subprocess.PIPE,
341 stdout=subprocess.PIPE,
342 stderr=subprocess.PIPE,
343 bufsize=0,
344 )
345 except (OSError, SmokeFailure) as error:
346 print(f"FAIL: could not start MCP server: {error}", file=sys.stderr)
347 return 1
348 assert process.stdout is not None
349 assert process.stderr is not None
350 responses: "queue.Queue[dict[str, Any]]" = queue.Queue()
351 transcript: list[dict[str, Any]] = []
352 stderr_chunks: list[bytes] = []
353 stdout_thread = threading.Thread(
354 target=read_json_lines,
355 args=(process.stdout, responses, transcript),
356 daemon=True,
357 )
358 stderr_thread = threading.Thread(
359 target=drain, args=(process.stderr, stderr_chunks), daemon=True
360 )
361 stdout_thread.start()
362 stderr_thread.start()
363
364 try:
365 run_scenario(
366 process,
367 responses,
368 args.scenario,
369 args.repo_path,
370 args.response_timeout,
371 )
372 assert process.stdin is not None
373 process.stdin.close()
374 try:
375 return_code = process.wait(timeout=args.exit_timeout)
376 except subprocess.TimeoutExpired as error:
377 raise SmokeFailure("MCP server did not exit after interactive stdin EOF") from error
378 if return_code != 0:
379 raise SmokeFailure(f"MCP server exited nonzero after completed session: {return_code}")
380 stdout_thread.join(timeout=2)

Callers 1

Calls 8

mcp_commandFunction · 0.85
run_scenarioFunction · 0.85
stop_processFunction · 0.85
cache_log_tailFunction · 0.85
startMethod · 0.80
waitMethod · 0.80
SmokeFailureClass · 0.70
closeMethod · 0.45

Tested by

no test coverage detected