data-references
Skill1 starsChanged 24 days agoMITView on GitHub
The server-side data reference lifecycle in msmcp that keeps large spectra out of MCP/JSON, and the invariants a new reference kind must uphold.
In this repository6 other files it gives its agents.
- AGENTS.mdAGENTS.md
- add-mcp-toolSkill
- instrument-class-defaultsSkill
- ms-data-ingestionSkill
- quality-gateSkill
- security-boundarySkill
The file
We split this skill into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 10
Use this when moving data between tools, or when adding a new reference kind.
- Very specific: line 67
Add the kind to DataKind in state/pointers.py.
- Very specific: line 71
Add tests in tests/test_pointers.py for registration, kind mismatch, expiry, release idempotency, and the store limits.
≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Server-side data references
Use this when moving data between tools, or when adding a new reference kind. A single LC-MS/MS run has far more peaks than fit in a context window; the reference is how MSMCP lets an agent reason about data without holding it.
The lifecycle
load_spectrum(file) -> "ptr:spectrum:<id>" # a few dozen tokens
summarise_reference(ref) # no re-read of the file
release_reference(ref) # deterministic cleanupload_spectrum registers the parsed spectrum and returns metadata plus
provenance, never the peaks. The payload stays in state/store.py behind an
opaque handle of the form ptr:<kind>:<hex>.
Invariants
- Opaque identifier. Generated from
secrets.token_hex. Never a Pythonid(), a memory address, or a path. Stable for the reference's lifetime and never reused after release. - Metadata, not payload. A reference carries kind, shape, byte size,
creation/expiry times, namespace, and provenance.
DataReference.to_dict()is what a tool returns, and it cannot contain the payload. - Immutable payload.
registervalidates the payload against its kind and takes one defensive copy with read-only buffers, so neither the caller nor a later reader can mutate stored data in place. This is a deliberate one-time copy; MSMCP does not claim zero-copy. - The guaranteed property is that the payload is never serialised through MCP/JSON. A 100,000-peak spectrum reaches the model as a small JSON object. This property is tested.
- Bounded and non-evicting. Limits are enforced by refusing new registrations, never by silently dropping live data.
- Expiring and releasable. References expire lazily on access; release is immediate and idempotent.
Limits
MSMCP_MAX_REFERENCESMSMCP_MAX_TOTAL_BYTESMSMCP_REFERENCE_TTL_SECONDS(default one hour)
Hitting a limit raises StoreLimitError.
Errors
state/pointers.py defines ReferenceError and its subtypes, all under the
MsmcpError base:
UnknownReferenceError— the handle was never issued or was already released.ExpiredReferenceError— the handle outlived its TTL.ReferenceKindError— the handle's kind does not match the expected kind.ReferencePayloadError— the registered payload failed validation.StoreLimitError— a store limit was reached.
Adding a reference kind
- Add the kind to
DataKindinstate/pointers.py. - Extend payload normalisation (
_normalise_payloadand its_as_*helpers) to validate and copy the new shape. - Return
DataReference.to_dict()from the tool, never the payload. - Add tests in
tests/test_pointers.pyfor registration, kind mismatch, expiry, release idempotency, and the store limits.
Provenance
A reference's payload is registered alongside a Provenance record
(provenance.provenance_for), and a derived reference records its parents as
plain identifier strings. The store depends on provenance; provenance does not
depend on the store. Keep that direction.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

