# One MCP implementation

The shipped contract remains `recall`, `analyze`, and `ingest`. Both stdio and Streamable HTTP now register it through `createMcpServer` in `src/server-factory.ts`. The CLI retains login, agent configuration, online/offline heartbeat and opt-in telemetry.

This fixes a transport discrepancy: the old stdio handler wrapped an already structured API error as a second JSON string, while the shared factory preserved fields such as `status` and `details.current_revision`. A revision conflict now reaches either transport in the same form. Telemetry failure cannot turn a committed write receipt into a tool failure.

## Retired internals

`src/tools.ts` now contains only the existing login/configuration/helper exports. Its unused `TOOLS` and `handleTool` exports and the older `src/agent-tools.ts` dispatcher are removed. Repository entry-point inspection found no shipped caller of those dispatchers: the CLI imported auth helpers from the same file, but tool execution already used `harness-v2.ts`.

Legacy names such as `save`, `wiki_write`, `list_projects`, `skills`, `setup_connector` and `run_analysis` were not advertised by either current transport. They remain unavailable. Use `ingest` for curated notes/evidence/versioned syntheses, `recall` for discovery/retrieval and `analyze` for research. No customer pages, source records, migration history or acquisition provider were removed.

Old stdio-only context priming called the unavailable `/agent/v1/knowledge/topics` endpoint, and onboarding injected instructions for the unavailable `set_preferences` tool. Those injections are removed. Explicit authorized knowledge retrieval remains available; persisted telemetry preferences still control local telemetry.

These internal module exports are not a supported replacement API for third-party integrations. Any consumer that deep-imported the retired files must migrate before publishing a release containing this change. No package has been published by the local consolidation.

## Verification

The obsolete dispatcher tests were adapted to the shipped contract: curated save/recall calls the API, failures cannot claim success from a no-op local fallback, scopes survive transport, current entity/workspace discovery works, and retired tool names are rejected. Existing auth, callback, configuration, streaming, execution-export and versioned-knowledge tests remain active.

`npm run build` clears only this package's generated `dist` before compilation, so removed sources cannot persist in a published package through stale compiler output. Both source and generated module inventories are checked. The optional knowledge round-trip suite tests independent in-memory clients and real child-process stdio clients against the disposable local API/Postgres fixture:

```sh
npm run build
npm test -- --run
CROWDLISTEN_AGENT_URL=http://127.0.0.1:8771 CROWDLISTEN_KNOWLEDGE_ROUNDTRIP=1 \
  npm test -- tests/unit/knowledgeRoundTrip.test.ts
```

The stdio fixture executes the built shared server through real stdin/stdout; it does not automate a hosted login or a Cursor/Claude application UI. A real-evidence pilot and hosted rollout remain separate gates.
