Skip to main content

The framework for building stateful agents. Your agent is a folder of state, served over MCP, used from any runtime.

Project description

gcontext

The framework for building stateful agents.

An agent built with gcontext is a folder: instructions, service connections, secrets, knowledge, and multi-step work, all as plain files you can version with git. gcontext serves that folder over MCP from a local HTTP server, and you use the agent from the tools you already work in: Claude Code, Claude Desktop, Codex, or Cursor.

Runtimes forget everything between sessions; the folder doesn't. Because the state is separate from the runtime, the same agent works from any client and survives every session. gcontext ships no chat loop and no LLM client: the runtime you attach does the reasoning, gcontext keeps the state.

Install

uv tool install gcontext-ai

Quickstart

gcontext init my-agent      # create the state folder
gcontext up my-agent        # serve it at http://127.0.0.1:4242/mcp

Then connect a client (once, from any directory):

claude mcp add --transport http my-agent http://127.0.0.1:4242/mcp

gcontext connect claude|desktop|codex|cursor prints the exact steps per client. The server logs each client as it connects. Stopping the server (Ctrl+C) disconnects everything; there is no other cleanup.

The folder

my-agent/
  gcontext.yaml          # name, description, optional port
  instructions.md        # standing instructions for whatever runtime attaches
  secrets.env            # secret values, gitignored

  connections/           # services the agent can use
    stripe/
      connection.yaml    # secret names + Python deps
      index.md           # API notes, usage patterns

  modules/               # accumulated knowledge
  flows/                 # multi-step work, tracked as files (see below)
  archive/               # excluded from scanning, still readable

Markdown holds the context, YAML holds the config. Edit any of it with a text editor; the server reads the files on demand, so changes apply immediately.

Connected clients get six tools: overview, read_context, write_context, run_script, list_connections, flows.

Your first connection

init creates no connections: a connection is worth having when it points at a service you actually use. Adding one is three files, no command needed:

mkdir -p my-agent/connections/stripe

connections/stripe/connection.yaml declares what the connection needs, by name only:

name: stripe
description: Payments, test mode.
secrets:
  - STRIPE_API_KEY
deps:
  - stripe

Put the value in secrets.env (gitignored, never leaves your machine):

echo 'STRIPE_API_KEY=sk_test_...' >> my-agent/secrets.env

And write connections/stripe/index.md: what the service is for, which endpoints matter, any usage patterns worth remembering. The agent reads this before writing scripts, and updates it as it learns.

That's it. The server picks the connection up on the next tool call (no restart), gcontext status shows whether every declared secret has a value, and the agent can now call the API through run_script without ever seeing the key.

Context ledger

gcontext context lists every channel through which context reaches the agent, marked as loaded (pushed at start), on demand (agent pulls it via a visible tool call), skipped (closed by a launch flag), or uncontrolled (owned by the runtime, outside gcontext's view). gcontext only inserts context through the channels on that list. If you want to know what the agent is seeing, this is the answer.

Secrets

connection.yaml declares secret names; secrets.env holds the values. When the agent calls run_script, the values are injected as environment variables and scrubbed from the script's output. The agent can know that STRIPE_API_KEY exists and use it in a script, but never reads the value. secrets.env is gitignored by init and the write_context tool refuses to touch it.

run_script executes Python in a per-project venv with each connection's declared deps preinstalled (via uv).

Flows

A flow is a YAML file describing multi-step work as file dependencies:

steps:
  - id: draft
    needs: [flows/brief/brief.md]
    produces: [flows/brief/draft.md]
    instructions: Read the brief, write the draft.

Step status is derived from the filesystem, like make targets:

  • blocked: a needed file doesn't exist
  • ready: needs exist, produces don't
  • stale: a needed file was modified after the produced files
  • done: everything exists and is up to date

There is no engine and no stored run state. A step is completed by writing the files it declares, whether that's done by an attached runtime, a script, or you in an editor. If an upstream file changes, downstream steps become stale on the next read. gcontext flows prints the board; attached clients get the same via the flows() tool, which includes step instructions only for steps that are currently actionable.

Archiving

When old modules or connections start cluttering the context, move them:

mv my-agent/modules/old-onboarding my-agent/archive/modules/

Anything under archive/ is skipped when scanning, but stays readable by path, and summaries mention what's archived so it doesn't silently vanish. That's the entire mechanism. gcontext never moves, archives, or deletes anything on its own.

Commands

Command Description
gcontext init <dir> Scaffold a new state folder
gcontext up [dir] Serve the folder over MCP
gcontext status [dir] Server state, connected clients, state overview
gcontext connect [client] Connection steps for claude, desktop, codex, cursor
gcontext context [dir] Print the context ledger
gcontext flows [dir] Print the flow boards
gcontext chat [dir] Launch a dedicated claude session against the folder

Going further

Scope

Local only. The server binds 127.0.0.1 without auth, so it is not reachable from outside your machine and should stay that way. A remote variant (same model, URL plus token) is planned but not part of this release.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gcontext_ai-0.3.1.tar.gz (106.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gcontext_ai-0.3.1-py3-none-any.whl (19.0 kB view details)

Uploaded Python 3

File details

Details for the file gcontext_ai-0.3.1.tar.gz.

File metadata

  • Download URL: gcontext_ai-0.3.1.tar.gz
  • Upload date:
  • Size: 106.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.16

File hashes

Hashes for gcontext_ai-0.3.1.tar.gz
Algorithm Hash digest
SHA256 f4cc3b954e3910fcd46c050f1eba004ba610e8954d8777727e6c59b3ca2d10c7
MD5 ff0ceca3b159b306d9ac0a70f294c1fe
BLAKE2b-256 480f1978d957dd2d97e20f7906b5037c4c2b82a5b00105a645ca2cf3504c6517

See more details on using hashes here.

File details

Details for the file gcontext_ai-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gcontext_ai-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 26310a097900b73134c6037b09236fe39fd7c162c801888cef5f75ec81a19536
MD5 90225ff3febed24aad7cb750e80381ba
BLAKE2b-256 4d6e6175f6df7edabc950900f8dbc3f7f2b5c33360a214e6081aa2baf01950c1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page