loading…
Search for a command to run...
loading…
An MCP server that connects to running Node.js applications via the Chrome Debug Protocol to analyze Mnemonica type hierarchies at runtime. It enables users to
An MCP server that connects to running Node.js applications via the Chrome Debug Protocol to analyze Mnemonica type hierarchies at runtime. It enables users to validate and improve static analysis by comparing runtime types with Tactica-generated types.
MCP (Model Context Protocol) server for Mnemonica runtime analysis via Chrome Debug Protocol.
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.
npm install @mnemonica/strategy
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
npx @mnemonica/strategy
Add to .roo/mcp.json:
{
"mcpServers": {
"mnemonica-strategy": {
"command": "node",
"args": ["/code/mnemonica/strategy/lib/cli.js"]
}
}
}
The Strategy MCP server exposes 3 bundled tools:
executeExecute 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 argumentsExample:
// 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: "{}"
}
listList available commands by context.
Input:
context (string, required): "MCP", "RPC", "RUN", or "ALL"Example:
list { context: "ALL" }
helpGet detailed help for any command.
Input:
context (string, required): Command contextcommand (string, required): Command nameExample:
help { context: "RPC", command: "connection" }
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!
}
// 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\" }"
}
// 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\" }"
}
// 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\" }"
}
Start your application with debug mode:
cd tactica-examples/nestjs
npm run start:debug
Connect 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\" }"
}
| Context | Folder | Execution Environment |
|---|---|---|
| MCP | commands-mcp/ |
Local MCP server process |
| RPC | commands-rpc/ |
Remote via CDP in target Node.js |
| RUN | commands-run/ |
HTTP endpoint in VS Code |
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run watch
# Test
npm run test
The cdp-scripts/ folder contains scripts that execute inside the target Node.js runtime via Chrome Debug Protocol:
cdp-scripts/
├── create-type.js # Creates mnemonica types in NestJS
└── analyze-hierarchy.js # Retrieves complete type hierarchy
How it works:
var args = {...} at the top with command argumentsclient.Runtime.evaluate({ expression: script })Key patterns for CDP scripts:
// Use process.mainModule.require (not require) because CDP runs in isolated VM
var mnemonica = process.mainModule.require('mnemonica');
// Access types via subtypes Map (avoids proxy enumeration issues)
defaultCollection.subtypes.forEach(function (Type, name) {
// Process each type
});
// Recursive traversal for subtype hierarchy
function getSubtypes (Type) {
var subtypes = [];
Type.subtypes.forEach(function (SubType, name) {
subtypes.push({
name: name,
subtypes: getSubtypes(SubType) // Recursive
});
});
return subtypes;
}
Commands are JavaScript files in the commands-*/ folders with MCP Tool Metadata:
/**
* MCP Tool Metadata:
* {
* "name": "my_command",
* "description": "What this command does",
* "inputSchema": {
* "type": "object",
* "properties": {
* "argName": { "type": "string" }
* }
* }
* }
*/
var { require, args, store } = ctx;
// Parse message if present
var commandArgs = args;
if (args.message && typeof args.message === 'string') {
try {
commandArgs = JSON.parse(args.message);
} catch (e) {
return { success: false, error: 'Invalid JSON: ' + e.message };
}
}
// Access parsed arguments
var myArg = commandArgs.argName;
// Return result
return { success: true, data: { ... } };
MIT
Добавь это в claude_desktop_config.json и перезапусти Claude Desktop.
{
"mcpServers": {
"mnemonica-strategy": {
"command": "npx",
"args": []
}
}
}