Token导航 LogoToken导航TokenDH.com
Mnemonica Strategy logo
运维云端stdio官方级别未说明来源级核验

Mnemonica Strategy

MCP Server

@mnemonica/strategy

通过Chrome调试协议连接Node.js应用,提取并分析Mnemonica类型层次结构,验证和改进静态分析。

工具数

3

提示词数

0

GitHub Stars

0

资源数

0
JavaScript云端部署Docker

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

mythographica

提供方

mythographica

最后核验

2026/5/17 20:19

运行时

Node.js

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

npx @mnemonica/strategy

详细介绍

@记忆法/策略

MCP(模型上下文协议)服务器,用于通过Chrome调试协议进行Mnemonica运行时分析。

概述

Strategy通过Chrome调试协议连接到正在运行的Node.js应用程序,以提取和分析Mnemonica类型层次结构。它将运行时类型与Tactica生成的类型进行比较,以验证和改进静态分析。

安装

npm install @mnemonica/strategy

用法

先决条件

您的目标应用程序必须使用调试标志运行:

# For NestJS
nest start --debug --watch

# For regular Node.js
node --inspect=9229 your-app.js

作为MCP服务器

npx @mnemonica/strategy

使用Roo代码进行配置

添加 .roo/mcp.json:

{
	"mcpServers": {
		"mnemonica-strategy": {
			"command": "node",
			"args": ["/code/mnemonica/strategy/lib/cli.js"]
		}
	}
}

提供的MCP工具

Strategy MCP服务器公开 3个捆绑工具:

1. execute

执行3个上下文文件夹(MCP、RPC、RUN)中的任何命令。

输入:

  • context (字符串,必填):执行上下文-“MCP”、“RPC”或“RUN”
  • command (string,必填):要执行的命令名称
  • message (string,可选):包含命令参数的JSON字符串

例子:

// 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

按上下文列出可用命令。

输入:

  • context (字符串,必填):“MCP”、“RPC”、“RUN”或“ALL”

例子:

list { context: "ALL" }

3. help

获取任何命令的详细帮助。

输入:

  • context (字符串,必填):命令上下文
  • command (字符串,必填):命令名称

例子:

help { context: "RPC", command: "connection" }

Args传递机制(重要)

由于MCP协议的限制,命令参数必须作为 JSON字符串message 字段,而不是直接对象属性。

正确格式:

execute {
  context: "RPC",
  command: "connection",
  message: "{ \"action\": \"connect\", \"host\": \"localhost\", \"port\": 9229 }"
}

格式不正确(不起作用):

// 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\" }"
}

工作流示例

  1. 使用调试模式启动应用程序:
   cd tactica-examples/nestjs
   npm run start:debug
  1. 连接到调试器:
   execute {
     context: "RPC",
     command: "connection",
     message: "{ \"action\": \"connect\" }"
   }
  1. 分析运行时类型:
   execute {
     context: "RPC",
     command: "get_runtime_types",
     message: "{}"
   }
  1. 与Tactica生成的类型进行比较:
   execute {
     context: "MCP",
     command: "compare_with_tactica",
     message: "{ \"projectPath\": \"/path/to/project\" }"
   }

命令上下文

上下文文件夹执行环境
MCPcommands-mcp/本地MCP服务器进程
RPCcommands-rpc/通过目标Node.js中的CDP进行远程
奔跑commands-run/VS代码中的HTTP端点

发展

# Install dependencies
npm install

# Build
npm run build

# Watch mode
npm run watch

# Test
npm run test

CDP脚本体系结构

cdp-scripts/ 文件夹包含通过Chrome调试协议在目标Node.js运行时内执行的脚本:

cdp-scripts/
├── create-type.js          # Creates mnemonica types in NestJS
└── analyze-hierarchy.js    # Retrieves complete type hierarchy

它是如何工作的:

  1. MCP命令读取脚本文件
  2. 注射 var args = {...} 顶部带有命令参数
  3. 通过发送至NestJS client.Runtime.evaluate({ expression: script })
  4. 脚本在NestJS中的隔离VM上下文中执行
  5. Console.log输出出现在NestJS终端中(不是MCP输出)
  6. 返回值被发送回MCP

CDP脚本的关键模式:

// 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;
}

创建命令

命令是JavaScript文件 commands-*/ 包含MCP工具元数据的文件夹:

/**
 * 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: { ... } };

许可证

麻省理工学院

目录标签

目录标签

JavaScript云端部署Docker运行时分析本地部署类型验证Node.js调试静态分析改进Chrome调试协议

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Node.js

部署方式(deploymentType,部署类型)

local-only

来源包(packageName,安装包名)

@mnemonica/strategy

工具数量(toolCount,工具数)

3

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdiononelocal-only

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP