Protocol Reference¶
This page is the curated map of the MGP protocol surface. It explains how the protocol documents, schemas, and HTTP binding relate to one another.
Canonical Protocol Assets¶
MGP keeps protocol source material in three coordinated forms:
spec/explains semantics and expected behavior.schemas/defines the canonical validation contracts.openapi/mgp-openapi.yamldescribes the HTTP binding.
An implementation is aligned only when those three layers and the observable runtime behavior point in the same direction.
Alignment Rule¶
spec/remains the semantic source of truth for what an operation means.- Operation-specific schemas under
schemas/are the canonical machine-readable source for exact request and response shapes. schemas/response-envelope.schema.jsonis the shared outer response shell; endpoint-specific response schemas narrowdatafor the exact operation contract.openapi/mgp-openapi.yamlshould mirror the HTTP mapping without inventing alternative wire shapes.
Contract enforcement in this repository:
scripts/validate_schemas.pychecks published schema validityscripts/validate_openapi.pychecks the OpenAPI document and its referencesscripts/check_contract_drift.pychecks thatspec//schemas//openapi// reference gateway versions and routes have not drifted- CI runs those checks before the compliance matrix
Core Object Model¶
The protocol is centered on a canonical memory object and the supporting request and response envelopes around it.
Key schema assets:
schemas/memory-object.schema.jsonschemas/memory-candidate.schema.jsonschemas/policy-context.schema.jsonschemas/request-envelope.schema.jsonschemas/response-envelope.schema.json
The protocol also includes structured content schemas for common memory types such as preferences, semantic facts, relationships, and procedural rules.
Modeling Quick Reference¶
Use these defaults unless your runtime has a stronger domain-specific reason to model things differently:
| Situation | subject.kind |
scope |
acting_for_subject |
task_id |
session_id |
|---|---|---|---|---|---|
| durable user preference or fact | user |
user |
current user | optional | optional |
| conversation-local memory | user or session |
session |
current user or current session subject | optional | current session |
| workflow-local memory | task or user |
task |
current user | current workflow/task | optional |
| agent-owned operational memory | agent |
agent |
current operator or owning subject | optional | optional |
Interpretation rule:
acting_for_subjectdescribes who the runtime is acting on behalf of for policy evaluationsubjectdescribes what the memory is abouttask_ididentifies runtime workflow or execution correlation, not the protocol async task object returned by/mgp/tasks/*session_idis tracing and conversation identity, not a replacement forscope: session
Core Operations¶
The core operation semantics live in spec/core-operations.md and are exposed through the reference HTTP binding.
Required governed-memory operations:
- write
- search
- get
- update
- expire
- revoke
- delete
- purge
- audit query
Required discovery support:
GET /mgp/capabilities
Each operation is backed by request and response schemas under schemas/ and by reference behavior in reference/gateway/app.py.
Search And Runtime Consumption¶
MGP does not stop at raw retrieval. The protocol also defines how search results should be consumed safely by runtimes.
Primary references:
spec/search-results.mdspec/protocol-behavior.mdspec/runtime-client.mdschemas/partial-failure.schema.jsonschemas/return-mode.schema.jsonschemas/retrieval-mode.schema.jsonschemas/score-kind.schema.json
These documents explain result normalization, consumable_text, return modes, redaction-aware behavior, partial-failure reporting, and runtime-side handling.
Governance Semantics¶
MGP treats governance as part of the protocol contract rather than a backend-specific extension.
Primary references:
spec/retention.mdspec/conflicts.mdspec/access-control.mdspec/errors.mdschemas/audit-event.schema.jsonschemas/lineage-link.schema.jsonschemas/memory-evidence.schema.json
These assets describe retention, conflict handling, access outcomes, audit records, and lineage evidence.
Lifecycle, Discovery, And Async¶
The protocol includes a required discovery surface plus optional lifecycle and interoperability profiles that sit above core memory operations.
Compatibility claims for those optional surfaces should use the profile names defined in Conformance Profiles.
Primary references:
spec/lifecycle.mdspec/async-operations.mdspec/http-binding.mdschemas/capabilities.response.schema.jsonschemas/initialize.request.schema.jsonschemas/initialize.response.schema.jsonschemas/async-task.schema.jsonschemas/get-task.request.schema.jsonschemas/get-task.response.schema.jsonschemas/cancel-task.request.schema.jsonschemas/cancel-task.response.schema.jsonschemas/write-batch.request.schema.jsonschemas/write-batch.response.schema.jsonschemas/export.request.schema.jsonschemas/export.response.schema.jsonschemas/import.request.schema.jsonschemas/import.response.schema.jsonschemas/sync.request.schema.jsonschemas/sync.response.schema.json
These assets cover:
- capability discovery
- initialize negotiation
- batch write as an interoperability extension
- async export, import, and sync task handles
- task polling and cancellation
Interaction rule of thumb:
GET /mgp/capabilitiesdescribes the implementation's general discovery surfacePOST /mgp/initializedescribes what was negotiated for one interaction
Runtime Contracts¶
MGP defines explicit runtime-facing guidance so that a client can behave consistently even across different backends.
Primary references:
spec/runtime-client.mdspec/runtime-write-candidate.mdschemas/runtime-capabilities.schema.jsonschemas/negotiated-capabilities.schema.json
These assets cover policy-context mapping, candidate extraction, return-mode handling, and initialize-time runtime capability declaration.
Extensions, Compatibility, And Versioning¶
Protocol evolution is documented separately from the core operation surface.
Primary references:
spec/extensions.mdspec/versioning.md
This layer defines how new features are added without breaking compatibility.
Use Conformance Profiles together with spec/versioning.md when describing implementation scope. Version numbers tell users what changed; profile names tell them which optional surfaces are actually supported.
Current guidance:
- the
mgpnamespace remains reserved for protocol-level extensions - vendor namespaces should be declared in adapter manifests and documented in the repository documentation
- compatibility claims should be backed by observable schema, gateway, and compliance behavior
Implementation Rule Of Thumb¶
Use the protocol assets in this order:
- Start with the relevant
spec/document to understand the intended behavior. - Confirm the exact request or response shape in
schemas/. - Verify the HTTP surface in
openapi/mgp-openapi.yaml. - Check the reference gateway and compliance suite to see the contract in executable form.