@strowk/mcpmock
v0.0.2
Published
mcpmock - Windows ARM64 build
Downloads
8
Readme
mcpmock
Install: npm install -g @strowk/mcpmock
mcpmock is a CLI tool that generates a mock Model Context Protocol server from list of cases in a YAML file.
For example you define something like this in a YAML file:
case: List tools
# requesting list of tools
in: {"jsonrpc": "2.0", "method": "tools/list", "id": 1}
# expect one tool in the list
out: {"jsonrpc": "2.0", "result":{ "tools": [{"description": "Lists files in the current directory", "inputSchema": {"type": "object"}, "name": "list-current-dir-files"}] }, "id": 1}
---
case: Call current dir files tool
# requesting list of files in the current directory
in: {"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "list-current-dir-files", "arguments": {}}, "id": 1}
# expect list of files returned as text content without error
out: {
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [
{"type": "text", "text": ".gitignore"},
{"type": "text", "text": "README.md"},
{"type": "text", "text": "go.mod"},
{"type": "text", "text": "go.sum"},
{"type": "text", "text": "main.go"},
{"type": "text", "text": "main_test.go"},
{"type": "text", "text": "testdata"},
],
"isError": false
},
}Then if you put it in the folder testdata and run mcpmock like this:
mcpmock testdataIt would start a mock MCP server with stdio transport that would serve the cases defined in the YAML file.
If you now copy and paste this into your terminal:
{"jsonrpc": "2.0", "method": "tools/list", "id": 1}, you should see list of tools as is defined in first MCP case.
And sending this:
{"jsonrpc": "2.0", "method": "tools/call", "params": {"name": "list-current-dir-files", "arguments": {}}, "id": 1}, you should get the output as defined in second case.
