agent-sessions
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-sessionsStart a new build session for the auth refactor and attach task-1234."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
Agent Sessions MCP - Session Context & Memory Bridge
Session lifecycle tracking, persistent context notes, transcript logging, and an explicit, unverified memory-promotion pipeline for AI agents in your agent harness.
Permissions and tool access are handled by your host AI agent harness. This MCP server provides session state tracking and the bridge between session context and long-term memory.
Session Types
Type | Phases | Description |
ask | active | Read-only analysis and research |
plan | active | Read-only, outputs actionable plan |
build | active | Edit, run, verify. Use git for versioning |
architect | planning → building → completed | Plan then Build with phase tracking |
Related MCP server: MCP Memory Server
Lifecycle Model
Every session has a top-level status: active (default), completed, blocked,
or cancelled. The last three are terminal. phase remains the mode-workflow
field (e.g. architect planning/building/completed) and is separate from status.
Close (
close_session) sets a terminal status plusclosed_at/close_reason. It is idempotent for an identical close and rejects a conflicting close.Archive (
archive_session) is an independent, reversible flag (archived/archived_at/archive_reason). Archived sessions are hidden from default listings and reject writes.Terminal/archived sessions are read-only:
append_context_note,append_transcript,set_mode,architect_advance_to_build, andupdate_session_metadataare rejected. Reads (get_session,get_context,get_transcript),resume_session(read-only with a warning), and promotion/export remain allowed.Old state files are lazily normalized on read (missing
status⇒active, missingarchived⇒false). Legacy architect records withphase=completedand nostatusnormalize tostatus=completed, withclosed_atderived from the existingupdated_at/created_atand an explanatorynormalized: …close_reason. Nothing is eagerly rewritten on disk.Every externally supplied session ID is validated against
^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$before any path is constructed from it; directory scans skip invalid names instead of aborting.Every lifecycle/archive/metadata/stale mutation appends one auditable
systemevent totranscript.jsonl. History is never rewritten, and no hard delete is exposed anywhere.architect_completerequires an architect session inbuildingphase (idempotent for already-completed architects), rejects archived and terminalblocked/cancelledsessions, setsphase=completedandstatus=completed, appends onearchitect_completedevent, and never auto-promotes to memory.
Structured Linkage Metadata
create_session validates/normalizes these optional metadata fields exactly
(additional keys are preserved; update_session_metadata patches them later with
reserved-field validation):
Field | Type | Default |
| string[] |
|
| string | null |
|
| string | null |
|
| string | null |
|
|
|
|
| string[] |
|
| string[] |
|
Run
npm startRegistered in your MCP client config as the agent-sessions MCP server.
Tools (22)
Session Management
list_modes- Show all session typescreate_session- Start a new session (validated metadata, see above)get_session- Get session statelist_sessions- List/filter sessions (newest updated first)resume_session- Resume the newest active non-archived session, or a specific one (closed/archived resume read-only)set_mode- Change session type (rejected when closed/archived)
Lifecycle
close_session- Close with terminal statuscompleted|blocked|cancelled(idempotent/conflict-safe)archive_session- Archive/unarchive (reversible, idempotent)update_session_metadata- Patch metadata (reserved fields rejected; rejected when closed/archived)report_stale_sessions- Stale report: active, non-archived sessions, oldest-first byupdated_atcleanup_stale_sessions- Close stale sessions (blocked|cancelled) then archive them. Dry-run by default (writes nothing); applying requiresdry_run=false+confirm=true. Re-reads each candidate and skips it if status/archive/updated_atchanged or it is no longer past the cutoff. Never deletes anything.
Architect Phase Control
architect_advance_to_build- Move from planning to building phase (rejected when closed/archived)architect_complete- Complete an architect session (closes it; never promotes)
Context Persistence
append_transcript- Log a turn to the session transcript (rejected when closed/archived)get_transcript- Retrieve transcript entriesappend_context_note- Add note to rolling context summary (rejected when closed/archived)get_context- Read the full context document
Memory Promotion (explicit, unverified)
promote_session_memory- Create a versioned (schema_version: 1), unverified promotion candidate in the queue. Deterministic content hash/candidate id; idempotent for identical content; changed content gets a hash-suffixed file (never an overwrite). Does not run the consumer.
Promotion Consumer (safe wiki ingest; dry-run by default)
These tools always use the canonical current base root (<OPENCODE_BASE_DIR>/.opencode)
— no caller-supplied filesystem override is accepted. Explicit baseDir remains
available only inside the consumer module, its CLI, and tests. Quarantine entries
store safe metadata only (IDs, hashes, memory count, queue path, rule IDs/counts/
indexes) — never candidate memory contents.
promotion_status- Read-only pipeline status (queue/inbox/quarantine/pages/ledger)promotion_process- Process queue candidates to inbox (clean) or quarantine. Dry-run unlesswrite=true. Never modifies queue/session files.promotion_lint- Lint inbox entries (schema, hash, secret/PII scan). Read-only.promotion_review- Approve (writes a trusted wiki page only after lint+scan+provenance pass) or reject. Requiresconfirm=trueand areviewer; dry-run unlesswrite=true.
No code path auto-trusts a candidate: queue → unverified inbox/quarantine → explicit human review → trusted page (ledgered).
list_sessions Filters
All filters are additive. Defaults: lifecycle=all (active + closed),
include_archived=false, offset=0, limit=20, order by updated_at descending.
workspace_root- case-insensitive, normalized exact path matchmode/phase/status- single value or arraylifecycle-active|closed|allcreated_after/created_before/updated_after/updated_before- ISO dates (validated; inclusive>=/<=)metadata- subset match against session metadatatask_id- matchesmetadata.task_idsentries and legacymetadata.task_idparent_session_id- exact matchtags+tag_match-all(default) |anykeyword- case-insensitive substring overcontext.mdnotesoffset/limit/include_state- pagination and full-state embedding
Summaries include status, closed_at, archived, workspace_root, and the
linkage fields task_ids, parent_session_id, tags.
Data Layout (canonical root)
State lives under the canonical root <base>/.opencode/, where <base> is
OPENCODE_BASE_DIR (default: ~/.config/opencode):
.opencode/
sessions/<session-id>/
state.json # mode, phase, status, archive flags, plan steps, metadata
transcript.jsonl # Append-only turn + system-event log
context.md # Rolling distilled context
memory-promotions/<candidate-id>.json
# Unverified promotion candidates (schema_version 1)
wiki/
inbox/ # Processed, still-unverified candidates
quarantine/ # Failed validation/scan/provenance (safe metadata only, no contents)
pages/ # Trusted pages (explicit human approval only)
review-ledger.jsonl # Append-only review eventsRestart note: the sessions root is resolved from OPENCODE_BASE_DIR when the
server process starts. After migrating state or changing the env var, restart the
agent-sessions server (restart your agent harness) so it picks up the new root.
Typical Flows
Build Session
create_session(mode="build", workspace_root="C:/path/to/project")
-> edit files, run tests (use git for versioning via /undo or git MCP tools)
-> append_context_note for important decisions
-> close_session(status="completed") when done
-> promote_session_memory to queue an unverified candidate (optional)Architect Session (Plan + Build)
create_session(mode="architect", workspace_root="C:/path/to/project")
# Phase 1: Planning
-> analyze, produce plan
-> architect_advance_to_build(plan_steps=[...])
# Phase 2: Building
-> implement plan steps, commit via git
-> architect_complete() # sets phase=completed AND status=completed; no auto-promotionResume After Restart
resume_session() # resumes newest active non-archived session
resume_session(session_id="...") # closed/archived sessions resume read-onlyPromotion Pipeline (human-gated)
promote_session_memory(session_id) # queue an UNVERIFIED candidate
promotion_process() # dry-run triage (inbox vs quarantine)
promotion_process(write=true) # write entries
promotion_lint() # re-validate inbox
promotion_review(candidate_id, action="approve",
confirm=true, reviewer="Matt Maas", write=true)
# trusted wiki page + ledger entryStale Hygiene (safe by default)
report_stale_sessions(stale_after_days=14) # read-only report
cleanup_stale_sessions(stale_after_days=14) # dry-run: writes nothing
cleanup_stale_sessions(stale_after_days=14,
dry_run=false, confirm=true,
close_status="blocked") # close + archive, never deleteTests
node --test agent-sessions-lifecycle.test.mjs promotion-consumer.test.mjs
node test-migrate-state-root.mjs
node test-logging-gate.mjs
node test-integration.mjs # tools/list smokeAll tests use temp roots (OPENCODE_BASE_DIR overrides) only; live session/queue/wiki
state is never touched.
Versioning
File versioning is handled through git-based /undo /redo commands
and the git MCP server.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections. Dates show when Glama detected each change.
No tool schema history has been recorded yet.
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Connectors
Verified memory for AI agents. Signed assertions, billing attestation, session continuity.
- memnodeOAuthdev.memnode
Persistent, inspectable memory for AI agents with lineage, correction, and a hosted MCP endpoint.
Versioned agent memory in your own Postgres: portable context, permissioned, audit trail.
Shared, governed long-term memory for AI agents across tools and sessions via MCP and REST.
Related MCP Servers
- FlicenseNot gradedqualityDmaintenanceProvides AI agents with persistent, searchable memory that survives across conversations using semantic search, temporal versioning, and smart organization. Enables long-term context retention and cross-session continuity for AI assistants.14-
- FlicenseNot gradedqualityDmaintenanceProvides persistent long-term memory, knowledge base, and audit trail for AI agents, with intelligent recall, salience tracking, and CJK-aware context management.2-
- AlicenseNot gradedqualityCmaintenanceGives AI agents persistent memory, handoffs, and shared context across sessions, enabling seamless continuity and multi-agent collaboration.8269-
- FlicenseNot gradedqualityCmaintenanceProvides AI agents with persistent memory across sessions, enabling recall of decisions, clients, and deadlines with verifiable citations.-
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
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/mattmaas/agent-sessions-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server