Skip to main content
Glama
mcp-context-window

mcp-context-window

mcp-context-window

로컬 모델에 외부 컨텍스트 버퍼를 제공하는 MCP 서버입니다. 모델이 메모를 기록할 수 있는 지속적인 세션 메모리와, 전체를 로드하지 않고 페이지 단위로 읽을 수 있는 대용량 문서를 제공합니다.

MCP TypeScript SDK v2를 기반으로 2026-07-28 프로토콜 개정판에 맞춰 제작되었습니다. stdio(LM Studio, Claude Desktop, 로컬 프로세스를 실행하는 모든 호스트) 또는 Streamable HTTP를 통해 실행됩니다.


먼저 읽어보세요: MCP 서버가 할 수 있는 것과 할 수 없는 것

어떤 MCP 서버도 컨텍스트 창을 보거나 수정할 수 없습니다. MCP는 엄격한 요청/응답 방식입니다. 호스트가 도구를 호출하면 도구가 응답합니다. 서버는 대화를 볼 수 없고, 모델에 도달하기 전에 메시지를 가로챌 수 없으며, 어떤 것도 잘라낼 수 없습니다. LM Studio는 자체적으로 내부 트렁케이션을 수행하며 이에 대해 어떤 서버와도 상의하지 않습니다.

따라서 이것은 자동 슬라이딩 윈도우가 아니며, 그렇게 광고하는 것은 오해를 불러일으키는 것입니다. 이것이 실제로 하는 일은: 모델이 의도적으로 페이지를 넘겨가며 사용하는 저장소로, 자료의 대부분을 창 밖에 두고 필요한 것만 다시 가져오는 것입니다. 이는 8k 토큰 로컬 모델에서 진정으로 강력합니다. 하지만 모델이 호출하기 때문에 작동하는 것이지, 무엇인가를 가로채기 때문이 아닙니다.

실질적인 결과: 모델이 협조해야 합니다. 여기의 도구 설명은 규범적으로 작성되었으며, context_guide는 의도된 워크플로우를 반환합니다. 모델이 이를 무시한다면 시스템 프롬프트에 명시하세요.

관련 참고 사항: MCP 샘플링 — 서버가 클라이언트의 LLM에 텍스트 생성을 요청하는 메커니즘 — 은 2026-07-28 사양에서 더 이상 사용되지 않으며, 공식 권장 사항은 "LLM 제공자 API와 직접 통합하라"입니다. 따라서 이 서버는 자체적으로 OpenAI 호환 엔드포인트를 호출합니다. 이것이 또한 하네스에 구애받지 않게 하는 이유입니다. 동일한 코드가 LM Studio, Ollama, llama.cpp 또는 vLLM에서 작동합니다.


Related MCP server: membot

두 가지 구성 요소

세션 — 긴 작업 중 작업 메모리

도구

용도

context_open

명명된 세션을 시작하거나 재개합니다. 이미 저장된 내용을 보여줍니다.

context_append

사실, 결정 또는 막다른 길을 기록합니다. 절대 잃어서는 안 되는 것을 고정합니다.

context_recall

가장 관련성 높은 항목을 토큰 예산에 맞춰 다시 가져옵니다.

context_compact

오래된 항목을 요약으로 접어 예산을 확보합니다.

context_status

세션이 얼마나 찼는지, 압축해야 하는지 여부를 보여줍니다.

context_update

항목을 고정, 고정 해제 또는 삭제합니다.

context_list_sessions

이전 작업에서 세션 ID를 찾습니다.

문서 — 한 번에 읽기에는 너무 큰 자료

도구

용도

doc_ingest

텍스트 또는 파일을 로드합니다. 청크로 나누어 저장하며, 거의 컨텍스트에 들어가지 않습니다.

doc_outline

구조 맵: 청크 인덱스, 제목, 크기, 선택적 요약

doc_search

키워드로 관련 청크를 찾아 그대로 반환합니다.

doc_window

청크 범위를 순서대로 읽습니다. 커서가 자동으로 진행됩니다.

doc_summarize

범위 또는 전체를 요약합니다.

doc_list / doc_forget

저장된 내용을 관리합니다.

추가로 context_guide는 모델에게 워크플로우를 설명합니다.


빠른 시작

npm install
npm run build
npm test
node dist/index.js --ingest-root ./sources

또는 대화형으로 탐색하세요:

npx @modelcontextprotocol/inspector node dist/index.js

LM Studio

~/.lmstudio/mcp.json(Windows에서는 C:\Users\<you>\.lmstudio\mcp.json)을 Program → Install → Edit mcp.json을 통해 편집한 후 LM Studio를 다시 로드하세요.

{
  "mcpServers": {
    "context": {
      "command": "node",
      "args": [
        "/absolute/path/to/mcp-context-sliding/dist/index.js",
        "--ingest-root", "/absolute/path/to/your/project",
        "--budget", "4000"
      ]
    }
  }
}

이 두 경로는 절대 경로여야 합니다. 호스트는 서버를 예측할 수 없는 작업 디렉토리로 자식 프로세스로 실행하므로 상대 경로는 해석되지 않습니다. 명령줄에서 작업 디렉토리를 제어하는 경우 --ingest-root ./sources와 같은 상대 경로는 괜찮습니다.

Windows에서는 슬래시(C:/Users/you/projects)를 쓰거나 백슬래시를 두 번 쓰세요. JSON 문자열에서 단일 \는 이스케이프 문자이기 때문입니다.

--budget을 모델의 컨텍스트 길이의 약 절반으로 설정하세요. 이것은 이 서버가 회상을 압축하는 대상이며, LM Studio가 강제하는 제한이 아닙니다.

--ingest-root는 doc_ingest가 파일을 읽을 수 있게 하는 것입니다. 이를 생략하면 서버는 인라인 텍스트만 허용합니다. 이는 안전한 기본값입니다. 모델의 지시에 따라 임의의 경로를 여는 서버는 위험 요소이기 때문입니다.

Docker

docker build -t mcp-context-window:latest .
{
  "mcpServers": {
    "context": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm", "--init",
        "-v", "mcp-context-data:/data",
        "-v", "/absolute/path/to/your/project:/ingest:ro",
        "-e", "CTX_INGEST_ROOTS=/ingest",
        "--add-host", "host.docker.internal:host-gateway",
        "mcp-context-window:latest", "--stdio"
      ]
    }
  }
}

여기서 문제가 되는 두 가지: -i는 필수이며, 그렇지 않으면 JSON-RPC 핸드셰이크가 발생하지 않습니다. 그리고 명명된 볼륨은 필수이며, 그렇지 않으면 재시작할 때마다 저장된 모든 세션이 조용히 삭제됩니다. 컨테이너 내부에서 localhost는 컨테이너 자체이므로 LLM 기본 URL은 host.docker.internal로 기본 설정됩니다. Docker는 또한 -v 바인드 마운트의 호스트 측이 절대 경로여야 합니다.


세션이 실제로 진행되는 방식

context_open        session_id "refactor-auth"
context_append      "Goal: replace session cookies with JWT" (pinned)
context_append      "auth/middleware.ts:42 assumes a cookie is present"
context_append      "Decision: keep cookie support behind a flag for one release"
...
context_status      → 3200/4000 tokens — approaching budget
context_compact     → folds 14 old entries into one 380-token summary
context_recall      "cookie flag decision" → returns the pinned goal + the decision

그리고 문서:

doc_ingest      file_path "logs/build-failure.log"  → doc_kx91, 240 chunks
doc_search      "OutOfMemory"                       → 3 chunks, 1400 tokens
doc_window      from 118 to 121                     → the surrounding context

로그는 모델의 컨텍스트에 들어가지 않았습니다. 세 번의 대상 읽기만 수행되었습니다.


구성

플래그

환경 변수

기본값

의미

--data-dir <dir>

CTX_DATA_DIR

플랫폼 데이터 디렉토리

상태가 저장되는 위치

--ingest-root <dir>

CTX_INGEST_ROOTS

(없음)

doc_ingest가 여기서 파일을 읽도록 허용합니다. 반복 가능.

--llm-base-url <url>

CTX_LLM_BASE_URL

http://localhost:1234/v1

OpenAI 호환 엔드포인트

--llm-model <id>

CTX_LLM_MODEL

(로드된 모델)

비워두면 로드된 모델을 사용합니다.

--llm-timeout <ms>

CTX_LLM_TIMEOUT_MS

120000

로컬 모델은 느릴 수 있습니다.

--no-llm

CTX_LLM_ENABLED=false

활성화

추출적 요약만 사용

--budget <n>

CTX_BUDGET

4000

기본 회상/창 예산

--chunk-tokens <n>

CTX_CHUNK_TOKENS

800

목표 청크 크기

--chunk-overlap <n>

CTX_CHUNK_OVERLAP

80

청크 간 겹침

--token-ratio <n>

CTX_TOKEN_RATIO

0.27

콜드 스타트 토큰-문자 비율 추정

--stdio / --http

CTX_TRANSPORT

stdio

전송

--host / --port

CTX_HTTP_HOST / CTX_HTTP_PORT

127.0.0.1 / 3001

HTTP 바인드

--audit / --no-audit

CTX_AUDIT

켜짐

호출당 stderr에 JSON 로그


설계 노트

토큰 계산은 실제 모델에 맞게 보정됩니다. 보편적인 토크나이저는 없습니다. Llama, Qwen, GPT는 모두 다르게 분할하며, 하나를 번들로 포함하면 크고 로드한 모델에 대해 틀릴 것입니다. 대신 서버는 저렴하게 추정한 다음 실제를 측정합니다. 서로 다른 길이의 두 샘플을 max_tokens: 1로 엔드포인트에 보내고 보고된 usage.prompt_tokens 사이의 기울기를 취합니다. 기울기는 채팅 템플릿의 고정 오버헤드를 상쇄하고 문자당 실제 한계 비용을 제공합니다. 결과는 캐시되므로 첫 실행만 보정되지 않으며, 백그라운드에서 실행되므로 아직 로드되지 않은 모델로 인해 시작이 차단되지 않습니다.

추정치는 의도적으로 높게 잡습니다. 과소 계산은 창을 넘치게 하고 이 서버가 보호하기 위해 존재하는 컨텍스트를 잘라냅니다.

요약은 실패하는 대신 성능이 저하됩니다. 엔드포인트에 연결할 수 없거나 모델이 로드되지 않은 경우 TF-ISF 문장 점수 기반의 추출적 요약으로 대체됩니다. 이는 즉각적이고 결정적이며 구조적으로 환각을 일으킬 수 없습니다. 저장된 컨텍스트에 대한 접근을 잃는 것은 더 조잡한 요약보다 더 나쁜 결과입니다. 실패 후 클라이언트는 잠시 백오프하므로 200개 청크 문서가 200개의 개별 TCP 시간 초과를 기다리지 않습니다.

저장은 추가 전용 JSONL입니다. 충돌은 최대 마지막 줄만 손상시킬 수 있으며, 로드 시 치명적이지 않고 건너뜁니다. tail로 파일을 보면서 메모리가 축적되는 것을 관찰할 수 있습니다. 압축은 원본을 삭제하는 대신 대체된 것으로 표시하므로 중요한 것을 놓친 압축도 로그에서 복구할 수 있습니다.

청크는 고정 오프셋이 아닌 문서 구조를 따릅니다. 제목, 단락, 펜스 코드 블록이 그대로 유지되며 각 청크는 그 아래에 있는 제목 경로를 포함합니다. 청크 전체보다 실제로 큰 블록만 강제 분할됩니다.

검색은 BM25와 최신성 기반이며 임베딩 모델이 없습니다. 이는 아무것도 로드할 필요가 없고, 메인 모델과 함께 VRAM을 소모하지 않으며, 결정적입니다. 모델이 보는 것에 대한 예측 가능성이 핵심일 때 중요합니다. 식별자는 전체 및 분할로 인덱싱되므로 getUserName은 "user name"으로 찾을 수 있습니다.

제한 사항

  • 모델이 실제로 이러한 도구를 호출해야 합니다. 자동으로 되는 것은 없습니다.

  • 키워드 검색은 임베딩 모델이 잡을 의역을 놓칩니다.

  • 토큰 수는 첫 번째 보정이 성공할 때까지 추정치입니다.

  • 두 전송 모두 인증하지 않습니다. HTTP는 그 이유로 루프백에 바인딩됩니다.

  • doc_ingest는 UTF-8 텍스트를 읽습니다. PDF 또는 DOCX 추출기가 아닙니다.

라이선스

MIT

Available Tools

15 tools
context_appendA

Record something worth remembering into the session. Use this as you go — after discovering a fact, making a decision, or hitting a dead end — rather than trying to hold it all in your reply. Keep each entry self-contained: it may be read back much later without the surrounding conversation. Set pinned for facts that must never be dropped during compaction, such as the goal or a hard constraint.

Inputs: text (required), session_id (required), role, tags, +1 more.

context_compactA

Fold older entries into a single summary to free budget, keeping the most recent entries verbatim. Call this when context_status or context_append warns that the session is over budget. Pinned entries are never compacted. The originals are kept on disk and can be recovered, so this is safe to run. Use dry_run first to see what would happen.

Inputs: session_id (required), dry_run, keep_recent, target_tokens.

context_guideA

Explain how to use this server effectively — the intended workflow for sessions and documents. Call this once if you have not used these tools before.

Inputs: no named parameters.

context_list_sessionsA

List stored sessions, newest first. Use this to find a session id from earlier work when you do not remember it.

Inputs: no named parameters.

context_openA

Start or resume a named memory session. Call this ONCE at the beginning of any task that will run long enough to risk losing earlier details, then reuse the same session_id for every later call. Returns what is already stored, so resuming a session after a restart tells you what you previously knew.

Inputs: title, session_id.

context_recallA

Retrieve the most relevant stored entries for a query, packed to fit a token budget. This is the main way to get memory back into your working context: ask for what you need rather than reading the whole session. Pinned entries are always included. Omit the query to get the most recent entries instead.

Inputs: session_id (required), limit, query, budget_tokens.

context_statusA

Report how full a session is, what is pinned, and whether compaction is advisable. Cheap to call — use it to decide whether you need to compact before adding more.

Inputs: session_id (required).

context_updateA

Pin, unpin, or delete a single entry by its id. Pin what must survive compaction; delete what turned out to be wrong, so it stops polluting recall.

Inputs: entry_id (required), session_id (required), delete, pinned.

doc_forgetA

Permanently delete an ingested document and everything derived from it. Use when a document is stale or was ingested by mistake.

Inputs: doc_id (required).

doc_ingestA

Load a large text into the store and split it into addressable chunks. Use this INSTEAD OF reading a big file into your context: the content stays on disk and you page through it with doc_outline, doc_search and doc_window. Accepts inline text, or a file path if the server was started with an ingest root. Returns a document id.

Inputs: text, title, doc_id, file_path.

doc_listA

List ingested documents with their ids, sizes and read positions.

Inputs: no named parameters.

doc_outlineA

Show the structure of an ingested document: every chunk with its index, heading and size. Call this right after doc_ingest to decide what is worth reading. Set summarize to also generate a one-line summary per chunk — more useful, but it runs the summarizer once per chunk, so it is slow on large documents.

Inputs: doc_id (required), summarize, max_chunks.

doc_summarizeA

Summarize a whole document or a range of its chunks. Use this to get the gist of something too large to read, before deciding which parts to pull verbatim. The whole-document summary is cached, so asking again is free.

Inputs: doc_id (required), to, from, refresh, +1 more.

doc_windowA

Read a range of chunks verbatim. This is the sliding window: ask for chunks 0-2, then 3-5, and so on, keeping each read inside your budget. Omit from/to to continue from where the last window left off — the read cursor is stored server-side, so sequential paging works without you tracking position.

Inputs: doc_id (required), to, from, reset, +1 more.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.3/5.0

    Scored across 15 tools

    Disambiguation5/5

    The tools are cleanly divided into context/session memory tools and document ingestion tools, with each serving a distinct operation: append, recall, compact, status, update, ingest, outline, window, search, summarize, list, and forget. Even the two retrieval-style tools, context_recall and doc_search, are clearly scoped to different stores by their descriptions.

    Naming Consistency4/5

    All names are lowercase snake_case and consistently grouped with context_ and doc_ prefixes, mostly following a verb-action pattern. Minor deviations exist: context_status and doc_window use nouns as commands, but the overall convention is readable and predictable.

    Tool Count5/5

    At 15 tools, the server is at the upper edge of a well-scoped set, but every tool maps to a distinct and useful operation across two related subdomains. There are no redundant utilities, and the count feels justified for the stated context-window and document-management purpose.

    Completeness4/5

    The server covers the core session lifecycle (open/resume, append, recall, compact, status, update, list) and the document lifecycle (ingest, outline, read, search, summarize, list, forget). The main gap is the absence of an explicit session deletion or close tool, though agents can still work around this by leaving sessions unused.

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      D
      maintenance
      Provides persistent session memory for AI assistants, enabling them to store, search, and retrieve conversation summaries across sessions via the Model Context Protocol.
      10
      MIT
    • A
      license
      Not graded
      quality
      C
      maintenance
      Provides a persistent, versioned, and searchable context store for AI agents with local embedding and hybrid search.
      65 npm
      3
      MIT
    • A
      license
      Not graded
      quality
      D
      maintenance
      Provides a unified context layer for Cursor's agent with lossless token savings and verifiable memory, enabling efficient code exploration and cross-session continuity.
      15 npm
      1
      MIT