npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xjtlumedia/context-first-mcp-server

v1.2.5

Published

Core MCP server library — tools, state engine, and analysis for context-first conversation management

Readme

@xjtlumedia/context-first-mcp-server

Core library powering the Context-First MCP ecosystem — 37 tools across 7 layers for context health, memory, reasoning, and truthfulness.

npm version License: MIT MCP Compatible Node ≥18 TypeScript


Looking for the ready-to-run MCP server? Use context-first-mcp via npx context-first-mcp — zero install needed.

This package is the shared core library consumed by the stdio and remote servers. Use it if you are building your own MCP transport layer or embedding Context-First tools in a larger application.


Installation

npm install @xjtlumedia/context-first-mcp-server
# or
pnpm add @xjtlumedia/context-first-mcp-server

Node ≥ 18 required.


What This Package Exports

createServer(options?)

Creates a fully configured McpServer instance with all 37 tools registered, MCP prompts attached, and server-level usage instructions injected (visible to LLMs during handshake).

import { createServer } from "@xjtlumedia/context-first-mcp-server";

const server = createServer({ name: "my-context-first-server", version: "1.0.0" });

// Connect to any MCP transport
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const transport = new StdioServerTransport();
await server.connect(transport);

State & Session

import { SessionStore, SiloManager } from "@xjtlumedia/context-first-mcp-server";

const store = new SessionStore();       // Per-session key-value + history
const silos = new SiloManager(store);   // Multi-agent quarantine silos

Tool Catalog (TF-IDF Discovery)

import { ToolCatalog, TfIdfIndexer } from "@xjtlumedia/context-first-mcp-server";

const catalog = new ToolCatalog();
// catalog.registerBatch([...]) — register tools for semantic routing
// catalog.query("search query", topK) — returns relevant tools only

Persistent Memory

import { UnifiedMemoryManager } from "@xjtlumedia/context-first-mcp-server";

Type Exports

All state, registry, and memory types are re-exported:

import type {
  // State types
  SessionState, HistoryEntry, GroundTruth,
  // Registry types
  ToolEntry,
  // Memory types
  MemoryEpisode, MemoryTier,
} from "@xjtlumedia/context-first-mcp-server";

Tool Layers

| Layer | Tools | Description | |-------|-------|-------------| | Orchestrator | context_loop | 8-stage pipeline: ingest → recap → conflict → ambiguity → entropy → abstention → discovery → synthesis | | Layer 1 · Context Health | 8 tools | recap_conversation, detect_conflicts, check_ambiguity, verify_execution, entropy_monitor, abstention_check, detect_drift, check_depth | | Layer 1b · State | 4 tools | get_state, set_state, clear_state, get_history_summary | | Layer 2 · Sandbox | 3 tools | discover_tools, quarantine_context, merge_quarantine | | Layer 3 · Memory | 6 tools | memory_store, memory_recall, memory_compact, memory_graph, memory_inspect, memory_curate | | Layer 4 · Reasoning | 5 tools | inftythink_reason, coconut_reason, extracot_compress, mindevolution_solve, kagthinker_solve | | Layer 5 · Truthfulness | 7 tools | probe_internal_state, detect_truth_direction, ncb_check, check_logical_consistency, verify_first, ioe_self_correct, self_critique | | Research & Export | 2 tools | research_pipeline, export_research_files |


Architecture

This package is the shared core consumed by both transport layers:

@xjtlumedia/context-first-mcp-server   ← this package
├── All 37 tool implementations
├── SessionStore · SiloManager
├── UnifiedMemoryManager
├── ToolCatalog · TfIdfIndexer
├── Engine: loop-freshness, NLP utils
└── Research pipeline (autonomous file writing)

        ↑ imported by
        │
        ├── context-first-mcp         (npx / stdio transport)
        └── @xjtlumedia/context-first-remote-server  (Vercel / HTTP transport)

Usage Protocol

When createServer() connects to an LLM-facing client, the CONTEXT_FIRST_INSTRUCTIONS are injected at handshake time via ServerOptions.instructions. The LLM receives:

  • Mandatory context_loop call cadence
  • Research workflow: interleave one search → one research_pipeline(gather) → repeat
  • Memory preservation guide (memory_store / memory_recall)
  • Autonomous file writing: pipeline writes *.batch-N.topic.md, *.analysis.md, *.synthesis.md to disk without LLM cooperation

Research Pipeline — Autonomous File Writing

research_pipeline({ action: "init",     topic, outputDir? }) → state initialized, outputDir confirmed
research_pipeline({ action: "gather",   content, topic })   → batch-N.topic.md written to disk
research_pipeline({ action: "analyze",  problem })          → analysis.md written to disk
research_pipeline({ action: "verify",   claims })           → health gate (non-blocking)
research_pipeline({ action: "finalize" })                   → synthesis.md + all batch files on disk

outputDir defaults to ./context-first-research-output/ when not provided. Set it explicitly to control the output location.


Development

git clone https://github.com/XJTLUmedia/Context-First-MCP.git
cd Context-First-MCP
pnpm install

# Build this package only
pnpm --filter @xjtlumedia/context-first-mcp-server build

# Run tests
pnpm --filter @xjtlumedia/context-first-mcp-server test

# Type-check only
pnpm --filter @xjtlumedia/context-first-mcp-server exec tsc --noEmit

Related Packages

| Package | Description | |---------|-------------| | context-first-mcp | npx-ready stdio server — the easiest way to run Context-First | | @xjtlumedia/context-first-remote-server | Vercel Streamable HTTP transport |

Full documentation, Claude Desktop / Cursor / VS Code setup, and the tool reference are in the main README.


License

MIT — © XJTLUmedia