Skip to main content
Glama

Most coding agents lose critical decisions between sessions: architecture invariants, API contracts, rejected patterns, and setup quirks. OpenContext solves context loss through a lightweight Model Context Protocol (MCP) server that lets agents read and mutate durable markdown files inside .opencontext/.

No vector databases, no cloud subscriptions, and no hidden state. Memory is plain markdown tracked directly in Git.


Quickstart

Run the MCP server directly without installation via npx:

npx -y opencontext-mcp

One-Command Setup

Scaffold OpenContext in the current project interactively:

npx -y opencontext-mcp init

init walks you through the setup (enabling OpenCode and Claude Code integration) and generates everything you need:

  • .opencontext/ — directory that holds your context topic files

  • .opencontext.json — configuration template

  • opencode.json — MCP server entry for OpenCode

  • .mcp.json — MCP server entry for Claude Code

  • AGENTS.md / CLAUDE.md — workflow reminders for your agents

The init command takes no arguments: it always runs in the current directory, prompts interactively, and never overwrites an existing config.

Client Setup

OpenCode

Add OpenContext to your project MCP configuration (opencode.json) — or let opencontext-mcp init do it for you:

{
  "mcp": {
    "opencontext": {
      "type": "local",
      "command": ["npx", "-y", "opencontext-mcp"],
      "enabled": true
    }
  }
}

Cursor / Claude Desktop / Windsurf

Add OpenContext to your MCP settings file (claude_desktop_config.json or Cursor MCP settings):

{
  "mcpServers": {
    "opencontext": {
      "command": "npx",
      "args": ["-y", "opencontext-mcp"]
    }
  }
}

Remote Access (HTTP)

Expose the MCP server over the network with the Streamable HTTP transport. The endpoint URL is printed to stderr on startup.

# Plain HTTP on 127.0.0.1:3032 (default)
opencontext-mcp --http

# Custom port / bind to all interfaces
opencontext-mcp server --http --port 8787 --host 0.0.0.0

The server listens at http://<host>:<port>/mcp (stateless Streamable HTTP — one request at a time, no sessions). GET / returns basic server info, handy for a browser health check.


Core Tools

Tool

Parameters

Description

read_context

topic? (optional string)

Reads a specific context topic, or returns the lightweight topic index (~100 tokens) if omitted.

save_context

topic (string), content (string)

Writes or mutates markdown memory inside .opencontext/<topic>.md with built-in write guards and symlink protections.

delete_context

topic (string)

Removes an obsolete topic file and automatically rebuilds the topic index.


ADR Lifecycle & Frontmatter

Topics support optional YAML frontmatter to track lifecycle status — useful when architectural decisions evolve and old context should be visible but clearly flagged as outdated.

---
description: OAuth2 + PKCE authentication flow
status: active
supersedes: auth_v1
---

# Authentication v2

Migrated from JWT to OAuth2 with PKCE.

Supported frontmatter keys:

Key

Values

Description

description

string

Short summary used in the auto-generated index.

status

active | deprecated | superseded

Lifecycle status. Defaults to active when omitted.

supersedes

string

Topic name this topic replaces (set on the newer topic).

superseded_by

string

Topic name that replaced this one (set on the older topic).

Non-active topics automatically receive [DEPRECATED] or [SUPERSEDED] badges in the auto-generated index.md, along with cross-references showing which topic replaced or was replaced.


Agent Workflows

Instruct your agents to automatically leverage project context. Add this snippet to your .cursorrules, CLAUDE.md, or system prompt:

Before making structural code changes, run `read_context` to inspect existing project topics and architectural decisions.

Whenever a new architectural convention, database schema, or API rule is established or refactored, call `save_context` with a concise, topic-scoped markdown summary. Use YAML frontmatter (status, supersedes) when updating conventions to track lifecycle changes.

When a topic becomes obsolete, call `delete_context` to remove it. For deprecated topics that should remain visible, set status: deprecated or status: superseded in the frontmatter instead of deleting.

Configuration

Customize storage paths and security boundaries with an optional .opencontext.json file in your repository root (plain JSON — comments are not supported):

{
  "path": ".opencontext",
  "readOnly": false,
  "autoIndex": true,
  "guard": {
    "enabled": true,
    "maxFileSizeKb": 50,
    "strictPatternCheck": true
  }
}

Local Development

# Clone and install dependencies
git clone [https://github.com/slxca/opencontext.git](https://github.com/slxca/opencontext.git)
cd opencontext
pnpm install

# Build & run tests
pnpm build
pnpm test

Documentation

For advanced setup guides, guard parameters, and agent prompt templates, visit opencntx.dev/docs.

Contributing

Contributions are welcome. Please ensure all unit tests and typechecks pass before submitting a pull request:

pnpm typecheck && pnpm test

Available Tools

2 tools
read_contextRead ContextA

Read a saved OpenContext topic, or list all available topics when no topic is provided.

ParametersJSON Schema
NameRequiredDescriptionDefault
topicNoOptional topic name in snake_case or kebab-case. Omit to list all saved topics.

TDQS

A4.2/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the behavioral disclosure burden. It transparently reveals the two modes of operation and the optional parameter behavior, and the verb 'read' implies a non-mutating operation. It does not discuss error handling or return format, but that is a minor gap for such a simple read tool.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence with no filler. The primary read behavior is front-loaded, and the list-all alternative is stated compactly.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

This is a low-complexity tool with one optional parameter, and the description adequately covers both invocation modes. There is no output schema, and the description does not detail the return shape or error behavior, but an agent still has enough information to invoke the tool correctly in either mode.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, and the schema already documents that 'topic' is an optional snake_case/kebab-case name and that omitting it lists all topics. The description adds little beyond what the schema already provides, so the baseline score of 3 is appropriate.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('read') and resource ('saved OpenContext topic'), and explicitly covers the alternative list-all behavior. It is clearly distinguishable from the sibling tool 'save_context'.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description clearly indicates when to call the tool: provide a topic to read it, or omit the topic to list available topics. It does not explicitly name 'save_context' as the alternative for writing, but the read-vs-save contrast makes the usage obvious.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

save_contextSave ContextA

Persist markdown project context, architectural rules, or decisions into .opencontext/.md in the current working directory.

ParametersJSON Schema
NameRequiredDescriptionDefault
topicYesContext topic name in snake_case or kebab-case, for example api_contracts or auth-rules.
contentYesMarkdown content to save for this project topic.

TDQS

A3.7/5.0
Behavior3/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description carries the full burden of behavioral disclosure. It does reveal that the tool writes to a specific file path in the current working directory, which is helpful. But it does not disclose whether existing files are overwritten, whether directories are created implicitly, or any other side effects, such as the absence of a return value.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, tight sentence that front-loads the primary action and includes concrete content examples. Every word contributes to clarity, and there is no redundancy or padding.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The description covers the essentials for a simple save operation, with fully documented parameters and a clear destination file. However, it omits overwrite semantics (what happens if the topic already exists) and gives no nod to the sibling read_context for retrieval. Given that there are no annotations or output schema, this leaves a notable but minor gap.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100% for both required parameters. The description adds no parameter-specific meaning beyond what the schema already provides, so the baseline of 3 is appropriate: the schema fully documents topic naming and markdown content.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states a specific verb ('persist'), a resource ('markdown project context, architectural rules, or decisions'), and a precise destination ('.opencontext/<topic>.md in the current working directory'). It clearly identifies a write operation and is readily distinguishable from the read_context sibling.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The verb 'persist' and the file-target phrasing imply the use case: save context content for later retrieval. However, the description does not explicitly state when to use this tool versus read_context, nor does it mention that read_context is the appropriate counterpart for reading the saved files.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.

  1. 2 tool updatesv0.1.0
    • First observedread_context
    • First observedsave_context

TDQS

A4.1/5.0
Disambiguation5/5

The two tools have clearly distinct purposes: one writes/persists context and the other reads/lists context. There is no overlap or ambiguity between them.

Naming Consistency5/5

Both tools follow a consistent verb_noun pattern: save_context and read_context. The naming is predictable and clear.

Tool Count4/5

With only two tools, the server is minimal but appropriately scoped for persisting and reading context files. It is slightly thin, but each tool serves a distinct and necessary function.

Completeness4/5

The core save/read workflow is covered, including listing topics via read_context when no topic is provided. An explicit delete/update tool is missing, but saving can overwrite existing context, so this is a minor gap.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/slxca/opencontext'

If you have feedback or need assistance with the MCP directory API, please join our Discord server