MCP server for Mnemonica runtime analysis via Chrome Debug Protocol.
@mnemonica/strategy
MCP (Model Context Protocol) server for Mnemonica runtime analysis via Chrome Debug Protocol.
Overview
Strategy connects to running Node.js applications via Chrome Debug Protocol to extract and analyze Mnemonica type hierarchies. It compares runtime types with Tactica-generated types to validate and improve static analysis.
Installation
npm install @mnemonica/strategy
Usage
Prerequisites
Your target application must be running with the debug flag:
# For NestJS
nest start --debug --watch
# For regular Node.js
node --inspect=9229 your-app.js
As MCP Server
npx @mnemonica/strategy
Configure with Roo Code
Add to .roo/mcp.json:
{
"mcpServers": {
"mnemonica-strategy": {
"command": "node",
"args": ["/code/mnemonica/strategy/lib/cli.js"]
}
}
}
MCP Tools Provided
The Strategy MCP server exposes 3 bundled tools:
1. `execute`
Execute any command from the 3 context folders (MCP, RPC, RUN).
Input:
context(string, required): Execution context - "MCP", "RPC", or "RUN"command(string, required): Command name to executemessage(string, optional): JSON string containing command arguments
Example:
// Connect to NestJS debugger
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}
// Check connection status
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"status\" }"
}
// Get runtime types
execute {
context: "RPC",
command: "get_runtime_types",
message: "{}"
}
2. `list`
List available commands by context.
Input:
context(string, required): "MCP", "RPC", "RUN", or "ALL"
Example:
list { context: "ALL" }
3. `help`
Get detailed help for any command.
Input:
context(string, required): Command contextcommand(string, required): Command name
Example:
help { context: "RPC", command: "connection" }
Args Passing Mechanism (IMPORTANT)
Due to MCP protocol limitations, command arguments must be passed as a JSON string in the message field, not as direct object properties.
Correct format:
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}
Incorrect format (will not work):
// DON'T DO THIS
execute {
context: "RPC",
command: "connection",
args: { action: "connect" } // This won't work!
}
Common Commands
Connection Management
// Connect to Node.js debugger
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}
// Check connection status
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"status\" }"
}
// Disconnect from runtime
execute {
context: "RPC",
command: "connection",
message: "{ \"action\": \"disconnect\" }"
}
Type Analysis
// Get runtime types from connected application
execute {
context: "RPC",
command: "get_runtime_types",
message: "{}"
}
// Analyze type hierarchy via CDP (retrieves complete type tree from NestJS)
execute {
context: "MCP",
command: "cdp_analyze_type_hierarchy",
message: "{}"
}
// Create type in NestJS via CDP
execute {
context: "MCP",
command: "cdp_create_type",
message: "{ \"typeName\": \"MyType\" }"
}
// Load Tactica-generated types
execute {
context: "MCP",
command: "load_remote_tactica_types",
message: "{ \"projectPath\": \"/path/to/project\" }"
}
// Compare runtime vs Tactica types
execute {
context: "MCP",
command: "compare_with_tactica",
message: "{ \"projectPath\": \"/path/to/project\" }"
}
Memory Management
// Store memory in connected runtime
execute {
context: "RPC",
command: "store_memory",
message: "{ \"key\": \"myKey\", \"data\": { ... } }"
}
// Recall memories
execute {
context: "RPC",
command: "recall_memories",
message: "{ \"key\": \"myKey\" }"
}
Example Workflow
Start your application with debug mode:
cd tactica-examples/nestjs npm run start:debugConnect to the debugger:
execute { context: "RPC", command: "connection", message: "{ \"action\": \"connect\" }" }Analyze runtime types:
execute { context: "RPC", command: "get_runtime_types", message: "{}" }Compare with Tactica-generated types:
execute { context: "MCP", command: "compare_with_tactica", message: "{ \"projectPath\": \"/path/to/project\" }" }
Command Contexts
| Context | Folder | Execution Environment |
|---|---|---|
| MCP | commands-mcp/ |
Local MCP server process |
| R |
Tools (3)
executeExecute any command from the MCP, RPC, or RUN context folders.listList available commands by context.helpGet detailed help for any command.Configuration
{"mcpServers": {"mnemonica-strategy": {"command": "node", "args": ["/code/mnemonica/strategy/lib/cli.js"]}}}