MemCP is a Model Context Protocol (MCP) server that gives AI agents direct access to read and write process memory on Windows. It provides a comprehensive toolset for memory inspection, modification, scanning, and analysis—enabling AI to perform advanced debugging, reverse engineering, process analysis, and memory forensics.
MemCP bridges the gap between AI agents and low-level process memory. Built with TypeScript and Node.js, it uses direct NT syscall layer access (via koffi FFI) for reliable memory operations. The server exposes 23+ MCP tools organized into 8 categories, allowing Claude and other MCP clients to programmatically inspect and manipulate live process memory with full type safety and safety controls.
Use cases:
- Interactive debugging and process analysis
- Memory-level reverse engineering and exploration
- Live memory forensics and inspection
- Dynamic process behavior analysis
- Pointer chain resolution and structure reading
- Memory pattern scanning and value searching
list_processes— Enumerate running processes with optional name filteringattach— Attach to a target process by PID or name (single attachment at a time)detach— Release the currently attached processprocess_info— Get detailed info about the attached process (PID, name, base address, architecture)
read_bytes— Read raw bytes with hex and ASCII previewread_int— Read signed/unsigned 8–64-bit integersread_float— Read 32-bit floats or 64-bit doublesread_string— Read null-terminated strings (ASCII, UTF-8, UTF-16LE)read_pointer— Read pointers and optionally follow chains
write_bytes— Write raw hex-encoded byteswrite_int— Write typed integer valueswrite_float— Write typed float/double valueswrite_string— Write strings with optional null termination
get_modules— List loaded DLLs and executables with base addresses and sizesget_base_address— Resolve module base address by name or partial matchget_regions— Query memory regions (committed, reserved, protection status, type)
scan_memory— Search for byte patterns (hex with??wildcards) across process memoryscan_value— Search for typed values (integers, floats) with region filtering
read_struct— Read typed structures by defining field offsets (C-like struct reading)diff_memory— Snapshot memory and detect changes between readswatch_address— Poll a memory address and return when its value changes
allocate_memory— Allocate new memory regions in the target processprotect_memory— Change memory protection flags (R, RW, RX, RWX, etc.)create_thread— Create a remote thread at a specified address (for code injection)
MCP Client (Claude, etc.) ← stdio MCP protocol → MemCP Server
↓
MCP Tool Handlers (index.ts)
↓
Safety Validator & Audit Logger
↓
MemoryEngine (core ops)
↓
ProcessManager + NT Syscall Layer
↓
Windows Kernel (ntdll.dll)
Key design choices:
-
Direct NT Syscalls — Uses
NtReadVirtualMemory,NtWriteVirtualMemory,NtQueryVirtualMemory, andNtProtectVirtualMemoryfromntdll.dllfor stealth and reliability, bypassing kernel32 hooks. -
FFI via koffi — Zero-compilation Foreign Function Interface to Windows APIs. No native module build required.
-
Single Process Attachment — Only one process can be attached at a time, eliminating confused-deputy vulnerabilities.
-
Type Safety — All types defined with Zod validation; addresses are hex strings (no BigInt precision issues).
-
Safety-First — Configurable read/write size limits, blocked system processes, audit logging, optional write protection, and address space validation (user-mode only).
-
Layered Architecture — MCP Protocol → Tool Handlers → Safety → Memory Engine → WinAPI Bindings, allowing for future kernel-mode driver support and platform expansion.
- OS: Windows 10/11 (x64)
- Node.js: 20+ (see
package.jsonengines field) - npm: 9+
- Privileges: Administrator rights (for protected/elevated targets)
- MCP Client: Copilot CLI, Claude Desktop with MCP config, or other MCP-compatible client
From the repository root:
cd MCP-Memory
.\build.batThis script will:
- Install dependencies (
npm install) - Build the TypeScript (
npm run build) - Install to Copilot MCP config (
npm run install:copilot)
Custom MCP config path:
.\build.bat "C:\path\to\your\mcp-config.json"cd MCP-Memory
npm install
npm run build
npm run install:copilot # or manually add to %USERPROFILE%\.copilot\mcp-config.jsonAfter setup, the MCP config will look like:
{
"mcpServers": {
"memcp": {
"type": "stdio",
"command": "node",
"args": ["C:\\Users\\<user>\\Desktop\\MemCP\\MCP-Memory\\dist\\index.js"],
"env": {
"MEMCP_WRITE_ENABLED": "true",
"MEMCP_AUDIT_LOG": "true",
"MEMCP_MAX_READ_SIZE": "65536",
"MEMCP_MAX_WRITE_SIZE": "4096"
}
}
}
}Restart/reconnect your MCP client to load MemCP.
User: "List all running processes"
MemCP: Uses list_processes tool → returns process names and PIDs
User: "Attach to notepad.exe"
MemCP: Uses attach tool → connects to the process
User: "Show me the first 64 bytes at the process base address"
MemCP: Uses process_info to get base address, then read_bytes → displays memory contents
User: "Scan for the byte pattern 48 89 5C 24 ?? in the .text section"
MemCP: Uses get_modules to find .text section, then scan_memory → returns all matching addresses
User: "Get the module base for kernel32.dll, then read a pointer chain from that address"
MemCP: Uses get_base_address, then resolve_pointer_chain with specified offsets →
follows the pointer chain and returns the final resolved address
User: "Watch the value at 0x12345678 and let me know when it changes"
MemCP: Uses watch_address with polling → returns old value, new value, and elapsed time
when the address changes
MemCP/
├── README.md (this file)
├── MCP-Memory/
│ ├── package.json (project metadata, Node.js 20+)
│ ├── tsconfig.json (TypeScript config)
│ ├── build.bat (one-command setup script)
│ ├── ARCHITECTURE.md (detailed design document)
│ ├── src/
│ │ ├── index.ts (CLI entry point)
│ │ ├── server.ts (MCP server setup)
│ │ ├── types.ts (shared type definitions)
│ │ ├── memory/
│ │ │ ├── index.ts (MemoryEngine: core read/write/scan)
│ │ │ ├── process-manager.ts (process attachment & handle mgmt)
│ │ │ ├── winapi.ts (NT syscall bindings via koffi)
│ │ │ ├── peb-walker.ts (module enumeration)
│ │ │ └── timing.ts (jitter and cache-line alignment)
│ │ ├── tools/
│ │ │ ├── index.ts (tool registration hub)
│ │ │ ├── process.ts (process tools)
│ │ │ ├── read.ts (memory read tools)
│ │ │ ├── write.ts (memory write tools)
│ │ │ ├── modules.ts (module/region tools)
│ │ │ ├── scan.ts (pattern/value scan tools)
│ │ │ ├── struct.ts (struct reading tool)
│ │ │ ├── analysis.ts (diff, watch, resolve chain)
│ │ │ ├── virtual.ts (allocate, protect, create_thread)
│ │ │ └── utils.ts (shared tool utilities)
│ │ └── safety/
│ │ ├── limits.ts (load config from env vars)
│ │ ├── validator.ts (input validation)
│ │ └── audit.ts (write operation logging)
│ ├── scripts/
│ │ └── install-copilot-mcp.mjs (MCP config installation)
│ └── dist/ (compiled JavaScript, created by `npm run build`)
└── .squad/ (team coordination files)
All configuration is via environment variables (with sensible defaults):
| Variable | Default | Purpose |
|---|---|---|
MEMCP_TRANSPORT |
stdio |
Server transport (stdio only) |
MEMCP_MAX_READ_SIZE |
65536 |
Maximum bytes per single read (64 KB) |
MEMCP_MAX_WRITE_SIZE |
4096 |
Maximum bytes per single write (4 KB) |
MEMCP_MAX_SCAN_RESULTS |
1000 |
Maximum scan hits returned per scan |
MEMCP_MAX_SCAN_REGION |
67108864 |
Maximum region size for scanning (64 MB) |
MEMCP_AUDIT_LOG |
true |
Enable/disable write operation audit logging to stderr |
MEMCP_WRITE_ENABLED |
false |
Enable/disable all memory write tools (default: disabled for safety) |
MEMCP_TIMING_JITTER_MS |
0 |
Optional random per-operation delay (milliseconds) for analysis evasion |
MEMCP_SCAN_TIMEOUT_MS |
30000 |
Maximum scan operation duration (milliseconds) |
- Address Validation: Blocks null, guard regions, and kernel-space addresses (user-mode only)
- Process Blocking: Prevents attachment to critical system processes (csrss.exe, lsass.exe, etc.)
- Single Attachment: Only one process can be attached at a time
- Size Limits: All reads, writes, and scans are size-bounded by configuration
- Write Protection: Write tools can be globally disabled via
MEMCP_WRITE_ENABLED=false - Audit Logging: All write operations are logged in JSON format to stderr for compliance
- Handle Escalation: Process handles start read-only and only escalate when first write is attempted
- Windows x64 only in v1 (Linux and ARM support possible in future with kernel-mode driver)
- User-mode access only (kernel-mode memory not accessible without a kernel driver)
- Protected/System Processes: Requires elevated privileges; some processes may still deny access
- Pointer reads: 8 bytes (x64); structure reading requires manual offset specification
- Timing side-channels: Optional jitter available via
MEMCP_TIMING_JITTER_MSfor evasion scenarios
cd MCP-Memory
# Install dependencies
npm install
# Build TypeScript
npm run build
# Run in dev mode (with tsx, no build step)
npm run dev
# Start the built server
npm run start
# Run linter
npm run lint
# Run tests
npm run test
# Watch mode for tests
npm run test:watch
# Clean build artifacts
npm run clean- TypeScript: Full type safety via Zod validation and static analysis
- MCP SDK:
@modelcontextprotocol/sdkv1.12.1+ - Testing: Vitest with minimal test coverage (expand as needed)
- Linting: ESLint v9 (ESLint config file not currently present)
MIT License — see LICENSE file for details.
Disclaimer: MemCP is designed for legitimate purposes including debugging, reverse engineering, process analysis, and memory forensics. Users are responsible for ensuring their use complies with applicable laws and policies. Do not use this tool for unauthorized access to systems or data.