Mnemonica Strategy
This server is an MCP bridge that lets an AI agent inspect and modify a running Mnemonica runtime over CDP and a fast injected WebSocket construction channel.
Connect to a Node.js debugger (
--inspect) and manage the connection.Execute commands in three contexts: MCP (local), RPC (remote via CDP), and RUN (local side effects).
List available commands per context and get detailed help for any command.
Analyze the runtime type hierarchy of the target process.
Create new mnemonica types in the running runtime via CDP.
Load Tactica-generated type definitions and compare them against runtime types.
Inject a WebSocket construction server into the target (
ws_bootstrap).Define new types so they are born shimmed and swappable (
ws_define).Instantiate types in the live process (
ws_instantiate), including nested subtype paths.Swap constructor implementations in flight without changing constructor identity (
ws_swap).List session state to see which types are shimmed/swappable (
ws_session).
Provides specialized support for NestJS applications, including tools to retrieve complete type hierarchies and create new types at runtime via Chrome Debug Protocol scripts.
Enables connection to and analysis of running Node.js applications via the Chrome Debug Protocol, allowing for runtime type hierarchy extraction, command execution within the target process, and memory management.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Mnemonica Strategycompare runtime types with Tactica output for this project"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
@mnemonica/strategy
MCP (Model Context Protocol) server that lets an AI agent work on a running Mnemonica runtime — inspect its type tree, define new types, construct instances, and swap constructor handlers in flight — without stopping the server you are developing.
Overview
Strategy is the live bridge between a running Mnemonica runtime and the
tools around it. It attaches to a target Node.js process via the Chrome
Debug Protocol (CDP) — zero instrumentation of the target — and then moves
the real work onto a fast WebSocket construction channel injected into the
process. It is the central point of the topology: agents drive it over MCP;
Mnemographica connects as
the monitoring client — through Strategy's own trace channel, or DIRECTLY to
an app's self-hosted channel (startStrategyClient + traceSubscribe, the
App Channel tab — no CDP in between).
The development loop this enables — the main server never stops:
Your app runs as usual (a debug-enabled child copy via infer-debug works too).
Strategy attaches over CDP — once. CDP is the delivery truck, not the road.
A dependency-free WebSocket server is injected into the runtime; all construction traffic (
define/instantiate/swap) moves there.New types are born shimmed: their constructor is a stable shell whose handler lives in the session's closure, so
ws_swapcan replace the implementation in flight — existing constructors and instances are untouched.When a shape is proven, Tactica crystallizes it into
.tacticatype definitions.
Strategy can also compare the runtime type tree against Tactica-generated types to validate static analysis — its original purpose, still available.
Related MCP server: MCP Browser Logger
Installation
npm install @mnemonica/strategyFrom source instead:
git clone https://github.com/mythographica/strategy.git
cd strategy
npm install
npm run buildUsage
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.jsDon't want --inspect on the main process? infer-debug
can spawn a debug-enabled child copy of the app on demand and tunnel CDP
through the app's own HTTP port — strategy attaches to that child the same
way.
As MCP Server
# installed from npm
npx @mnemonica/strategy
# from a source checkout
node /path/to/strategy/lib/cli.jsMCP Configuration
Add to your agent framework's MCP config:
{
"mcpServers": {
"mnemonica-strategy": {
"command": "npx",
"args": ["-y", "@mnemonica/strategy"]
}
}
}or, from a source checkout:
{
"mcpServers": {
"mnemonica-strategy": {
"command": "node",
"args": ["/path/to/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 Node.js debugger
execute {
context: "RPC",
command: "rpc_connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}
// Check connection status
execute {
context: "RPC",
command: "rpc_connection",
message: "{ \"action\": \"status\" }"
}
// Analyze the runtime type hierarchy
execute {
context: "RPC",
command: "rpc_analyze_type_hierarchy",
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: "rpc_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: "rpc_connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}Incorrect format (will not work):
// DON'T DO THIS
execute {
context: "RPC",
command: "rpc_connection",
args: { action: "connect" } // This won't work!
}Common Commands
Connection Management
// Connect to Node.js debugger
execute {
context: "RPC",
command: "rpc_connection",
message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}
// Check connection status
execute {
context: "RPC",
command: "rpc_connection",
message: "{ \"action\": \"status\" }"
}
// Disconnect from runtime
execute {
context: "RPC",
command: "rpc_connection",
message: "{ \"action\": \"disconnect\" }"
}Type Analysis
// Analyze the complete type hierarchy (recursive subtype tree from the target)
execute {
context: "RPC",
command: "rpc_analyze_type_hierarchy",
message: "{}"
}
// Create type in the target runtime via CDP
execute {
context: "RPC",
command: "rpc_create_type",
message: "{ \"typeName\": \"MyType\" }"
}
// Load Tactica-generated types
execute {
context: "MCP",
command: "mcp_load_remote_tactica_types",
message: "{ \"projectPath\": \"/path/to/project\" }"
}
// Compare runtime vs Tactica types
execute {
context: "MCP",
command: "mcp_compare_with_tactica",
message: "{ \"projectPath\": \"/path/to/project\" }"
}Example Workflow
Start your Mnemonica application with debug mode:
# any Mnemonica app, e.g. a NestJS service nest start --debug --watch # or plain Node.js node --inspect=9229 your-app.jsConnect to the debugger:
execute { context: "RPC", command: "rpc_connection", message: "{ \"action\": \"connect\" }" }Analyze runtime types:
execute { context: "RPC", command: "rpc_analyze_type_hierarchy", message: "{}" }Compare with Tactica-generated types:
execute { context: "MCP", command: "mcp_compare_with_tactica", message: "{ \"projectPath\": \"/path/to/project\" }" }
The construction channel (ws_ commands)
After rpc_connection is up, one call injects the WS channel into the
target; everything after that is fast WS traffic, not CDP:
// 1. Bootstrap: inject the WS server into the target (one CDP evaluate)
execute { context: "RPC", command: "ws_bootstrap", message: "{}" }
// 2. Define a type — born shimmed (swappable later)
execute {
context: "MCP",
command: "ws_define",
message: "{ \"name\": \"TempProbe\", \"body\": \"function (data) { this.value = data.value; }\" }"
}
// 3. Construct an instance of it, right now, in the running process
execute {
context: "MCP",
command: "ws_instantiate",
message: "{ \"path\": \"TempProbe\", \"args\": [{ \"value\": 42 }] }"
}
// → { chain: ["Mnemonica", "TempProbe"], props: { value: 42 } }
// 4. Swap the handler in flight — the constructor identity never changes
execute {
context: "MCP",
command: "ws_swap",
message: "{ \"path\": \"TempProbe\", \"body\": \"function (data) { this.value = data.value * 2; }\" }"
}
// 5. Next instance uses the NEW implementation
execute {
context: "MCP",
command: "ws_instantiate",
message: "{ \"path\": \"TempProbe\", \"args\": [{ \"value\": 42 }] }"
}
// → { props: { value: 84 } }
// Session state: which types are shimmed/swappable
execute { context: "MCP", command: "ws_session", message: "{ \"action\": \"list\" }" }Rules the channel enforces (they are mnemonica semantics, not policy):
ws_swaprefuses any type not born viaws_definein this session — pre-existing types are never re-defined.Subtypes construct from parent instances: for nested paths,
ws_instantiatewalks the chain, taking intermediate constructor args fromchainArgs(e.g.{ "TempProbe": [{ "value": 7 }] }).Async constructor handlers must
return this(mnemonica enforces this).
The in-target server is development-only instrumentation: it binds
127.0.0.1, requires a per-session token at the WebSocket handshake, and
disappears with the process. Do not expose it on production runtimes.
Command Contexts
Context | Folder | Execution Environment |
MCP |
| Local MCP server process |
RPC |
| Local orchestration; effects in the target via CDP |
RUN |
| Local side effects (files, utilities) |
Command names carry their site as a prefix (mcp_, rpc_, run_), so
the place of execution is visible in the name itself. The ws_ prefix
marks the construction channel: ws_bootstrap lives in commands-rpc/
(it needs CDP to get in), every other ws_* command lives in
commands-mcp/ and talks to the stored WS session.
Development
# Install dependencies
npm install
# Build
npm run build
# Watch mode
npm run watch
# Test
npm run testCDP Scripts Architecture
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 the target
├── analyze-hierarchy.js # Retrieves complete type hierarchy
└── ws-server.js # Phase 3: the injected WS construction serverHow it works:
MCP command reads the script file
(create-type only) injects
var args = {...}at the top with command argumentsSends it to the target via
client.Runtime.evaluate({ expression: script, awaitPromise: true })Script executes inside the target process
Return value is sent back to the MCP process
Key pattern — the canonical prelude. Scripts must never use a bare
require (there is none in evaluated code) and never rely on
process.mainModule.require alone (it is undefined in ESM-entry
processes, and import() in evaluated code throws
ERR_VM_DYNAMIC_IMPORT_CALLBACK_MISSING). Every cdp-script loads the
target's own mnemonica through this exact three-tier prelude:
var mnemonica;
if (process.mainModule && process.mainModule.require) {
mnemonica = process.mainModule.require('mnemonica');
} else if (typeof process.getBuiltinModule === 'function') {
var nodeModule = process.getBuiltinModule('node:module');
var cwdRequire = nodeModule.createRequire(process.cwd() + '/__strategy_cwd__.js');
mnemonica = cwdRequire('mnemonica');
} else {
var mnemonicaNs = await import('mnemonica');
mnemonica = mnemonicaNs.default || mnemonicaNs;
}Scripts using it must be async IIFEs. ws-server.js generalizes the same
three tiers into a targetRequire factory because it also needs
node:http/node:crypto — see AGENTS.md for the variant rule.
// Access types via the defaultCollection Map (avoids proxy enumeration issues)
mnemonica.defaultCollection.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;
}Creating Commands
Commands are JavaScript files in the commands-*/ folders with MCP Tool Metadata.
Two shapes are supported; module.exports.run is the pattern current
commands use:
/**
* MCP Tool Metadata:
* {
* "name": "mcp_my_command",
* "description": "What this command does",
* "inputSchema": {
* "type": "object",
* "properties": {
* "argName": { "type": "string" }
* }
* }
* }
*/
async function run (ctx) {
const { require, args, store } = ctx;
// Parse message if present (args arrive as a JSON string in `message`)
let 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 };
}
}
return { success: true, data: { got: commandArgs.argName } };
}
module.exports = { run };Files without a run export are instead wrapped in an async IIFE with
ctx in scope. Two gotchas, both learned the hard way:
Never
ctx.require('mnemonica')— that resolves in the MCP process, not the target. Target-side mnemonica work belongs incdp-scripts/with the canonical prelude.ctx.requireresolves relative paths fromlib/server.js, not from your command file — require lib modules by absolute path (path.join(__dirname, '../../lib/...')), the same idiom used forcdp-scripts/.
License
MIT
Available Tools
3 toolsexecuteC
Execute a command in the specified context (MCP, RPC, or RUN)
| Name | Required | Description | Default |
|---|---|---|---|
| context | Yes | Execution context: MCP (local), RPC (remote/CDP), or RUN (VS Code HTTP) | |
| command | Yes | Command name to execute | |
| message | Yes | Command Message or string of arguments, or empty string |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
With no annotations provided, the description carries full burden for behavioral disclosure. It mentions execution contexts but doesn't reveal critical behavioral traits: whether this is a read-only or destructive operation, what permissions are required, whether commands are synchronous or asynchronous, what happens on failure, or any rate limits. The description is operationally opaque beyond the basic action.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that states the core purpose. There's no wasted verbiage or unnecessary elaboration. However, it could be more front-loaded with critical behavioral information given the lack of annotations.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
For a command execution tool with 3 required parameters, no annotations, and no output schema, the description is inadequate. It doesn't explain what types of commands can be executed, what the expected output format might be, error conditions, or security implications. The agent would struggle to use this tool correctly without significant trial and error.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, so all parameters are documented in the schema. The description adds minimal value beyond the schema - it mentions the three contexts but doesn't elaborate on their differences or provide additional semantic context about how parameters interact. The baseline of 3 is appropriate when the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description states the tool 'Execute[s] a command in the specified context' which provides a basic verb+resource combination. However, it's vague about what types of commands are executed and what 'execute' means operationally. It doesn't distinguish this tool from its siblings (help, list) beyond the general action of execution.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives. It mentions three contexts (MCP, RPC, RUN) but doesn't explain when each context is appropriate or what distinguishes this execution tool from other potential command-execution tools. No prerequisites, exclusions, or sibling tool comparisons are provided.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
helpB
Get detailed help for a specific command including examples
| Name | Required | Description | Default |
|---|---|---|---|
| context | Yes | Command context | |
| command | Yes | Command name to get help for |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries the full burden of behavioral disclosure. It states the tool 'gets detailed help' but doesn't clarify if this is a read-only operation, what the output format might be, or any potential side effects like rate limits or authentication needs. This leaves significant gaps for a tool with two required parameters.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that front-loads the core purpose ('Get detailed help for a specific command') and adds a useful detail ('including examples') without any wasted words. It's appropriately sized for a simple tool.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's moderate complexity (two required parameters, no output schema, and no annotations), the description is minimally adequate. It explains what the tool does but lacks details on output, behavioral traits, or usage context. Without annotations or an output schema, more completeness would be beneficial, but it's not entirely inadequate.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The schema description coverage is 100%, so the schema already documents both parameters ('context' with enum values and 'command'). The description adds minimal value beyond implying that 'command' is the target for help, but it doesn't provide additional syntax or format details. This meets the baseline for high schema coverage.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the tool's purpose with a specific verb ('Get') and resource ('detailed help for a specific command'), and it includes additional context ('including examples'). However, it doesn't explicitly differentiate from sibling tools like 'execute' or 'list', which might also provide help or information, so it doesn't reach the highest score.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
The description provides no guidance on when to use this tool versus alternatives like 'execute' or 'list'. It lacks any mention of prerequisites, exclusions, or contextual cues, leaving the agent to infer usage based on the tool name and parameters alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
listB
List all available commands grouped by context and folder
| Name | Required | Description | Default |
|---|---|---|---|
| context | No | Filter by context (default: ALL) |
TDQS
Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?
No annotations are provided, so the description carries full burden. It states the tool lists commands grouped by context and folder, but doesn't disclose behavioral traits such as whether it's read-only (implied but not stated), what format the output takes, if there are rate limits, or any authentication needs. For a tool with no annotations, this is a significant gap in transparency.
Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.
Is the description appropriately sized, front-loaded, and free of redundancy?
The description is a single, efficient sentence that front-loads the key action ('List all available commands') and adds necessary detail ('grouped by context and folder'). There is zero waste, making it highly concise and well-structured for quick understanding.
Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.
Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?
Given the tool's low complexity (one optional parameter, no output schema, no annotations), the description is minimally adequate. It covers the basic purpose but lacks details on output format, error handling, or integration with siblings. Without annotations or output schema, more context on behavior would improve completeness, but it's not entirely inadequate for this simple tool.
Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.
Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?
The input schema has 100% description coverage, with one parameter ('context') fully documented including its enum values and default. The description adds no additional parameter semantics beyond what the schema provides, such as explaining the grouping behavior or folder implications. Baseline 3 is appropriate since the schema does the heavy lifting.
Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.
Does the description clearly state what the tool does and how it differs from similar tools?
The description clearly states the verb ('List') and resource ('all available commands'), specifying they are 'grouped by context and folder'. It distinguishes from 'execute' (which presumably runs commands) but doesn't explicitly differentiate from 'help' (which might provide documentation). The purpose is specific but could be more precise about sibling differentiation.
Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.
Does the description explain when to use this tool, when not to, or what alternatives exist?
No guidance is provided on when to use this tool versus alternatives like 'execute' or 'help'. The description implies it's for listing commands, but there's no explicit context for usage, prerequisites, or exclusions. This leaves the agent to infer usage from the tool name alone.
Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
3 tool updates
v0.1.0- First observed
execute - First observed
help - First observed
list
TDQS
Scored across 3 tools
Each tool has a clearly distinct purpose: execute performs actions, help provides documentation, and list enumerates available commands. There is no overlap in functionality, making it easy for an agent to select the correct tool without confusion.
All tool names follow a consistent, simple verb-only pattern (execute, help, list). This uniformity makes the set predictable and easy to understand, with no deviations in naming style.
With only 3 tools, the set feels thin for a strategy server, potentially lacking depth in operational coverage. While the tools are well-defined, the low count may limit the server's utility in complex scenarios, though it's not extreme.
The tool surface is significantly incomplete for a strategy domain; it only covers command execution, help, and listing, with no tools for planning, analysis, or decision-making. This creates obvious gaps that could lead to agent failures in strategic tasks.
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
MCP server for understanding Javascript internals from ECMAScript specification.
Repository knowledge graph MCP server for codebase understanding and debugging.
- AgentCatOAuthcom.agentcat
Analytics and debugging for your MCP server — explore usage and sessions, then root-cause errors.
MCP server to assist with JxBrowser development.
Related MCP Servers
- AlicenseBqualityCmaintenanceAn MCP server based on Puppeteer and Chrome DevTools Protocol for advanced browser debugging, performance analysis, and memory detection. It enables users to inspect DOM elements, monitor console errors, capture screenshots, and perform heap snapshot analysis through persistent browser connections.10311MIT
- FlicenseNot gradedqualityDmaintenanceAn MCP server that captures browser console logs and network requests via the Chrome DevTools Protocol. It allows users to monitor real-time logs, inspect network traffic, and execute JavaScript code directly in the browser context.-
- AlicenseNot gradedqualityAmaintenanceMCP server that lets AI coding tools control and observe a running Node.js process through the chrome devtools protocol (CDP), via a lightweight Debug Adapter Protocol (DAP) bridge.272MIT
- AlicenseBqualityDmaintenanceMCP server for debugging Node.js programs through the V8 Inspector Protocol, allowing AI agents to set breakpoints, inspect variables, and step through code.11105MIT