# @debugmcp/adapter-mock

Mock debug adapter for testing the MCP Debugger. This package provides a fully functional mock implementation of a Debug Adapter Protocol (DAP) server and adapter used heavily by tests and examples in the monorepo.

- MockDebugAdapter: In-memory adapter that simulates debugging life-cycle, state transitions, capabilities, and events.
- MockAdapterFactory: Factory that creates MockDebugAdapter instances.
- mock-adapter-process.ts: A small DAP server that can run over stdio or TCP for integration/e2e tests.

## Install (workspace)

This package is designed to be used via pnpm workspaces within this monorepo.

- Root package.json includes "@debugmcp/adapter-mock": "workspace:*" (the `workspace:*` protocol requires pnpm; npm cannot resolve it)
- Build order ensures @debugmcp/shared builds before this package

## Build

pnpm --filter @debugmcp/adapter-mock run build

## Test

- Run just this package’s tests:
  pnpm --filter @debugmcp/adapter-mock run test

- Or run from repo root (Vitest is already configured to include packages/**):
  pnpm test

## Exports

import { MockAdapterFactory, MockDebugAdapter, MockErrorScenario } from '@debugmcp/adapter-mock';
import type { MockAdapterConfig } from '@debugmcp/adapter-mock';

## Notes

- Primary path resolution for the mock-adapter-process uses import.meta.url when running from the compiled package.
- A second fallback resolves the CJS bundle variant (mock-adapter-process.cjs) in the same directory as the compiled file, for the npx bundle scenario.
- A third fallback (used only when import.meta.url resolution throws) resolves from the current working directory: packages/adapter-mock/dist/mock-adapter-process.js, for monorepo-root execution.
- The mock-adapter-process supports a `--host` flag to specify the listening address, passed as a separate argument (e.g., `--host 127.0.0.1`); the `--host=127.0.0.1` form is not parsed and is silently ignored. Defaults to `localhost`
