
Context First Mcp
io.github.XJTLUmediaPublished by GitHub account XJTLUmediav1.2.2Updated Oct 25, 2026
37-tool MCP server: context health, memory, reasoning, truthfulness & research pipeline.
Overview
A local MCP server that adds context-health, memory, reasoning and truthfulness checks so an assistant stays grounded and consistent across long conversations.
- What you can do
- Run a single context loop that recaps intent, flags conflicts, ambiguity and drift, and returns one action directive with a health score and clarifying questions. Lock and read confirmed facts and task state, and review compressed conversation history. Store, recall, compact, curate and graph persistent memories, and isolate sub-task context in quarantines that can be merged back. Route to relevant tools by natural-language query and run structured reasoning and self-critique routines. Run a phased research pipeline and write report chunks and raw evidence batches to disk.
- When to use it
- Useful for long, multi-step sessions where the assistant tends to forget earlier decisions, contradict locked facts, or claim success without checking. Also suited to structured research runs that should end in files on disk.
- Requirements
- Runs locally over stdio, typically launched with npx, so Node.js is needed. The README also describes a hosted remote endpoint as an alternative. No API keys or environment variables are declared.
Installation
In SourceWeft
- Open Context First Mcp in the dashboard and add it to a workspace.
- Enable the server for the chats that should use its tools.
Desktop only via STDIO. STDIO servers start a local process, so they need the SourceWeft desktop host.
Other MCP clients
Follow the launch instructions in the repository.
README
Context-First MCP
The MCP server that keeps your AI grounded, coherent, and honest — across every turn.
[npm version] [npm downloads] [License: MIT] [MCP Compatible] [Smithery] [Glama] [Node ≥18] [TypeScript]
Works instantly with Claude Desktop · Cursor · VS Code · any MCP client · Vercel remote — zero API keys needed.
37 research-backed tools across 7 layers — context health, state, sandboxing, persistent memory, advanced reasoning, truthfulness verification, orchestration, structured research, and autonomous file export. One
context_loopcall replaces 6–7 individual tools and returns a unified action directive.
Why Your AI Conversations Break Down
Long AI conversations fail in predictable ways. Context-First fixes all four:
What You Get
37 production-ready tools grouped into 7 layers — plus 1 orchestrator that runs them all:
One call. One directive. One score.
Quick Start
npx — zero install
Claude Desktop
Cursor / VS Code
Remote (Streamable HTTP)
Deploy your own Vercel instance
Tool Reference
Layer 1: Core Context Health (9 tools)
Layer 1b: State Management (4 tools)
Layer 2: Sandbox & Discovery (3 tools)
Layer 3: Persistent Memory (6 tools)
Layer 4: Advanced Reasoning (5 tools)
Layer 5: Truthfulness & Verification (7 tools)
Research Pipeline & Export (2 tools)
Built on Peer-Reviewed Research
Every core algorithm traces back to a published paper:
Implementation highlights:
- Proxy Entropy (ERGO): 4 response-level proxy signals (lexical diversity, contradiction density, hedge-word frequency, n-gram repetition) replace inaccessible token-level logprobs. Composite score above threshold triggers adaptive context reset.
- TF-IDF Discovery (MCP-Zero): Pure TypeScript, zero external dependencies. Indexes all tool descriptions at startup; cosine similarity routes queries to the top-k relevant tools only.
- Inference-Time Abstention (RLAAR): 5-dimension confidence scoring replaces the RL training loop. Abstains with targeted questions when confidence < threshold — no hallucination fallback.
Export Helper (1 tool)
context_loop Pipeline
Synthesis Priority: abstain > reset > clarify > proceed
Each stage runs with independent error isolation — a failure in one stage doesn't block the others. The result includes per-stage timing, status, and detailed results for observability.
LLM Directive (NEW)
The context_loop response includes a top-level directive object designed for LLM consumption — a compact, actionable instruction that replaces the need to parse nested stage results:
How context_loop Works
Synthesis priority: abstain > reset > clarify > proceed
Each stage runs with independent error isolation. The directive response field carries everything an LLM needs:
Smart defaults: currentInput is auto-inferred from the last user message. Facts like "use React" are extracted and stored automatically.
Usage Protocol: Getting the Most from Context-First
The #1 mistake: LLMs treat
context_loopas optional. It's not — it's the backbone.
Built-in Enforcement (v1.2.1+)
The server ships with four compliance mechanisms that require zero configuration:
- Server Instructions — Full usage protocol injected at MCP handshake via
ServerOptions.instructions - Bootstrap Gate — First non-
context_loopcall appends a strong redirect reminder - Cross-Tool Reminders — After 3 consecutive calls without
context_loop, reminders appear in tool responses - MCP Prompts —
context-first-protocolandresearch-protocolprompt templates available on demand
Reinforce in Your System Prompt (Optional)
Research Task Workflow
research_pipeline orchestrates memory, phase control, reasoning, and autonomous file writing. It is not a web crawler — bring your own sources from web search, GitHub, fetch tools, PDFs, or any other MCP.
Autonomous file writing is always on. Files are written to ./context-first-research-output/ by default — no LLM cooperation required. Pass outputDir to override.
Architecture
- Core library (
@xjtlumedia/context-first-mcp-server): All tool implementations. Zero external API keys — heuristic-based by default. - stdio-server (
context-first-mcp):npxentry point, stdio transport, 37 tools. - remote-server: Vercel serverless, Streamable HTTP transport, 37 tools.
Frontend Demo
Try all 37 tools live in your browser at context-first-mcp.vercel.app.
Development
Contributing
See CONTRIBUTING.md.
License
Context-First MCP · @xjtlumedia/context-first-mcp-server · context-first-mcp
Built for every developer tired of watching their AI lose the plot.
Source: README.md at commit 2732b90
Tools
0Version history
1- v1.2.2LatestSep 16, 2026
Score
50% of the applicable checks met
How complete this listing is, computed from the registry entry, the endpoint and public sources. Not a rating of the server and not a statement that it is safe or working today: reachability is a dated check, and no installs or reviews go into the score.
- Reached in the last 30 days25 pts
Keep the endpoint answering the MCP handshake; SourceWeft probes it every 30 days.
- Auth declared10 pts
Declare the credential headers in the registry entry, or keep the endpoint answering the probe so its auth can be classified.
- Tools listed15 pts
Answer tools/list without a credential, or ship a package that starts in a sandbox without one.
- DescriptionRequired15 pts
- Logo10 pts
- Documentation15 pts
- License10 pts