3030 TEST_DIR=" $( cd -P -- " $SCRIPT_DIR /$RAW_DIR_ARG " && pwd) "
3131fi
3232
33- TEST_DIR=" ${1%/ } " # strip trailing slash if present
3433TESTS=" $TEST_DIR /tool-tests.yaml"
3534MCP_CONFIG=" $TEST_DIR /config.yaml"
3635
@@ -62,13 +61,21 @@ cleanup() { rm -rf "$TMP_DIR"; }
6261trap cleanup EXIT INT TERM # cleanup before exiting
6362GEN_CONFIG=" $TMP_DIR /server-config.generated.json"
6463
65- # Safe replacement for <test-dir> with absolute path (handles /, &, and |)
64+ # Safe replacement for paths with absolute path (handles /, &, and |)
6665safe_dir=" ${TEST_DIR// \\ / \\\\ } "
6766safe_dir=" ${safe_dir// &/ \\ &} "
6867safe_dir=" ${safe_dir// |/ \\ |} "
6968
70- # Replace the literal token "<test-dir>" everywhere
71- sed " s|<test-dir>|$safe_dir |g" " $TEMPLATE_PATH " > " $GEN_CONFIG "
69+ safe_bin=" ${BIN_PATH// \\ / \\\\ } "
70+ safe_bin=" ${safe_bin// &/ \\ &} "
71+ safe_bin=" ${safe_bin// |/ \\ |} "
7272
73- # Run the command
74- npx -y mcp-server-tester@1.4.0 tools " $TESTS " --server-config " $GEN_CONFIG "
73+ # Generate MCP config.yaml with absolute paths
74+ GEN_MCP_CONFIG=" $TEST_DIR /config.generated.yaml"
75+ sed -e " s|<test-dir>|$safe_dir |g" " $MCP_CONFIG " > " $GEN_MCP_CONFIG "
76+
77+ # Replace the literal tokens "<test-dir>" and "<bin-path>" in server config
78+ sed -e " s|<test-dir>|$safe_dir |g" -e " s|<bin-path>|$safe_bin |g" " $TEMPLATE_PATH " > " $GEN_CONFIG "
79+
80+ # Run the command (ignore-scripts needed due to mcp-server-tester's postinstall requiring patch-package)
81+ npm_config_ignore_scripts=true npx -y mcp-server-tester@1.4.1 tools " $TESTS " --server-config " $GEN_CONFIG "
0 commit comments