=== NEW SERVERS ADDED (7) === - servers/closebot — 119 tools, 14 modules, 4,656 lines TS (Stage 7) - servers/google-console — Google Search Console MCP (Stage 7) - servers/meta-ads — Meta/Facebook Ads MCP (Stage 8) - servers/twilio — Twilio communications MCP (Stage 8) - servers/competitor-research — Competitive intel MCP (Stage 6) - servers/n8n-apps — n8n workflow MCP apps (Stage 6) - servers/reonomy — Commercial real estate MCP (Stage 1) === FACTORY INFRASTRUCTURE ADDED === - infra/factory-tools — mcp-jest, mcp-validator, mcp-add, MCP Inspector - 60 test configs, 702 auto-generated test cases - All 30 servers score 100/100 protocol compliance - infra/command-center — Pipeline state, operator playbook, dashboard config - infra/factory-reviews — Automated eval reports === DOCS ADDED === - docs/MCP-FACTORY.md — Factory overview - docs/reports/ — 5 pipeline evaluation reports - docs/research/ — Browser MCP research === RULES ESTABLISHED === - CONTRIBUTING.md — All MCP work MUST go in this repo - README.md — Full inventory of 37 servers + infra docs - .gitignore — Updated for Python venvs TOTAL: 37 MCP servers + full factory pipeline in one repo. This is now the single source of truth for all MCP work.
108 lines
3.0 KiB
Python
108 lines
3.0 KiB
Python
# Copyright (c) 2025 Scott Wilcox
|
|
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
"""
|
|
STDIO Testing Utilities
|
|
|
|
Helper functions for testing MCP over STDIO transport.
|
|
"""
|
|
|
|
import os
|
|
import shlex
|
|
import subprocess
|
|
import time
|
|
from typing import List, Tuple
|
|
|
|
def check_command_exists(command: str) -> bool:
|
|
"""
|
|
Check if a command exists in the system path.
|
|
|
|
Args:
|
|
command: The command to check
|
|
|
|
Returns:
|
|
True if the command exists, False otherwise
|
|
"""
|
|
# Get the first part of the command (the executable)
|
|
executable = shlex.split(command)[0]
|
|
|
|
# Check if the command exists
|
|
try:
|
|
result = subprocess.run(
|
|
["which", executable],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
text=True,
|
|
check=False
|
|
)
|
|
return result.returncode == 0
|
|
except Exception:
|
|
return False
|
|
|
|
def run_process_with_timeout(command: str, args: List[str] = None, timeout: int = 5) -> Tuple[bool, str, str]:
|
|
"""
|
|
Run a process with a timeout and return stdout/stderr.
|
|
|
|
Args:
|
|
command: The command to run
|
|
args: Additional arguments for the command
|
|
timeout: Timeout in seconds
|
|
|
|
Returns:
|
|
Tuple of (success, stdout, stderr)
|
|
"""
|
|
args = args or []
|
|
cmd = shlex.split(command) + args
|
|
|
|
try:
|
|
process = subprocess.run(
|
|
cmd,
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
text=True,
|
|
timeout=timeout
|
|
)
|
|
return process.returncode == 0, process.stdout, process.stderr
|
|
except subprocess.TimeoutExpired:
|
|
return False, "", f"Process timed out after {timeout} seconds"
|
|
except Exception as e:
|
|
return False, "", f"Error running process: {e}"
|
|
|
|
def verify_python_server(server_path: str, timeout: int = 2) -> bool:
|
|
"""
|
|
Verify that a Python server file exists and is executable.
|
|
|
|
Args:
|
|
server_path: Path to the server Python file
|
|
timeout: Timeout for verification in seconds
|
|
|
|
Returns:
|
|
True if the server exists and is a valid Python file, False otherwise
|
|
"""
|
|
# Check if the file exists
|
|
if not os.path.isfile(server_path):
|
|
print(f"Server file not found: {server_path}")
|
|
return False
|
|
|
|
# Check if it's a Python file
|
|
if not server_path.endswith('.py'):
|
|
print(f"Server file does not have .py extension: {server_path}")
|
|
return False
|
|
|
|
# Try to syntax check the Python file
|
|
try:
|
|
result = subprocess.run(
|
|
["python", "-m", "py_compile", server_path],
|
|
stdout=subprocess.PIPE,
|
|
stderr=subprocess.PIPE,
|
|
text=True,
|
|
timeout=timeout
|
|
)
|
|
|
|
if result.returncode != 0:
|
|
print(f"Python syntax check failed: {result.stderr}")
|
|
return False
|
|
|
|
return True
|
|
except Exception as e:
|
|
print(f"Error verifying Python server: {e}")
|
|
return False |