Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
mb-grpc
✓ npx mb-grpc
✗ require('mountebank-grpc-mts')
This package provides a CLI tool, not a JavaScript module. Use the command directly or via package.json scripts.
createCommand
✓ "createCommand": "mb-grpc" in protocols.json
✗ "createCommand": "mountebank-grpc-mts"
The createCommand must be 'mb-grpc' (the CLI binary), not the npm package name.
services
✓ Use JSON object keyed by fully qualified service name (e.g., 'example.ExampleService') in imposter definition
✗ Using service name without package prefix or mismatched with proto file
The service key must match exactly the package.ServiceName as defined in the .proto file.
Shows minimal setup: installing packages, creating protocols.json, starting mountebank with gRPC protocol, and creating a simple gRPC imposter that mocks a unary RPC.
mkdir mountebank-grpc-example && cd mountebank-grpc-example
npm init -y
npm install mountebank mountebank-grpc-mts
# Create protocols.json
echo '{
"grpc": {
"createCommand": "mb-grpc"
}
}' > protocols.json
# Start mountebank with gRPC protocol
npx mb start --protofile protocols.json --loglevel debug &
# Create example.proto (minimal)
echo 'syntax = "proto3";
package example;
service ExampleService {
rpc UnaryUnary (ExampleRequest) returns (ExampleResponse);
}
message ExampleRequest {
string name = 1;
}
message ExampleResponse {
string greeting = 1;
}' > example.proto
# Create imposter (replace with your mountebank port, default 2525)
curl -X POST http://localhost:2525/imposters -H 'Content-Type: application/json' -d '{
"protocol": "grpc",
"port": 50051,
"services": {
"example.ExampleService": {
"file": "'$(pwd)'/example.proto"
}
},
"stubs": [{
"predicates": [{"matches": {"path": "UnaryUnary"}}],
"responses": [{"is": {"value": {"greeting": "Hello from mock"}} }]
}]
}'
echo "gRPC mock running on port 50051"
Errors
Common errors & fixes
Error: ENOENT: no such file or directory, open '.../example.proto'
The file path in the imposter JSON is relative to the working directory, but the path is incorrect or the proto file doesn't exist.
fixUse an absolute path for the 'file' field, or ensure the relative path is correct relative to where mountebank is started.
Error: Could not load service: example.ExampleService. Make sure the service name is correct and the proto file exists.
The service name in the imposter JSON does not match the package and service defined in the .proto file.
fixVerify that the 'services' key exactly matches 'package.ServiceName' as declared in your .proto, and that the 'file' path is correct.
Error: Cannot find module 'mountebank-grpc-mts'
The package is not installed globally or locally, or the command 'mb-grpc' is not in PATH.
fixInstall the package locally: npm install mountebank-grpc-mts, and run via npx mb-grpc or ensure node_modules/.bin is in PATH.
Audit
Dependencies
mountebankrequiredmountebank-grpc is a protocol extension for Mountebank; must be running to use.
@grpc/proto-loaderrequiredUsed for loading .proto files and generating gRPC service descriptors.
google-protobufrequiredRequired for serializing/deserializing protobuf messages used by gRPC stubs.