#
# This script generates Python gRPC code from .proto files using PowerShell.
# It should be executed from the root directory of the project.
#
# Force the console output to use UTF-8 encoding to prevent garbled text
$OutputEncoding = [System.Text.Encoding]::UTF8
# Set the script to stop on the first error
$ErrorActionPreference = "Stop"
Write-Host "--- Step 1: Checking Python dependencies ---"
# Check if grpcio-tools is installed in the current environment
try {
python -m grpc_tools.protoc --version | Out-Null
Write-Host "Dependency 'grpcio-tools' found."
}
catch {
Write-Host "Error: package 'grpcio-tools' not found in your activated .venv environment."
Write-Host "Please install it using: pip install grpcio-tools"
# Exit the script because the dependency is missing
exit 1
}
Write-Host "--- Step 2: Defining paths ---"
# Directory for third-party .proto files
$thirdPartyDir = "third_party"
$googleApisDir = Join-Path $thirdPartyDir "googleapis"
# Directory with our main .proto file
$protoDir = "MCP-NG/proto"
# Output directory for the generated Python code
$outputDir = "MCP-NG/tools/python/code_interpreter"
# Ensure the third-party dependencies directory exists
if (-not (Test-Path $googleApisDir)) {
Write-Host "Google's proto files not found. Cloning repository..."
git clone --depth 1 https://github.com/googleapis/googleapis $googleApisDir
}
else {
Write-Host "Google's proto files already exist."
}
Write-Host "--- Step 3: Generating Python code from .proto ---"
# Execute the generation command
python -m grpc_tools.protoc `
-I="$protoDir" `
-I="$googleApisDir" `
--python_out="$outputDir" `
--grpc_python_out="$outputDir" `
"$protoDir/mcp.proto"
Write-Host "Python code generation completed successfully."
Write-Host "Files 'mcp_pb2.py' and 'mcp_pb2_grpc.py' in '$outputDir' have been updated."
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/Lotargo/MCP-NG'
If you have feedback or need assistance with the MCP directory API, please join our Discord server