NAME

MCP::Server::KnowledgeStore::Tools::Revisioned - Generic tool set for a revisioned, taggable, project-scoped resource

VERSION

version 0.001

SYNOPSIS

package MCP::Server::KnowledgeStore::Tools::Memory;
use MCP::Server::KnowledgeStore::Tools::Revisioned;

sub register ($class, $server, $store) {
  MCP::Server::KnowledgeStore::Tools::Revisioned->register(
    $server, $store, kind => 'memory', type => 1, search => 1);
}

DESCRIPTION

Memory and skill are, at the tool level, the same shape: list, get, save, list revisions, mark useful, tag, untag - differing only in whether they carry type and support search. This module is that shape, factored out once instead of duplicated per resource.

THE BACKEND INTERFACE

register takes a backend - anything implementing this handful of methods, taking $kind as their first argument, matching MCP::Server::KnowledgeStore::Store's own shape:

$backend->list($kind, $project)                    # arrayref of entries
$backend->search($kind, $query, $project)           # only if search => 1
$backend->get($kind, $name, $revision)               # one entry, or undef
$backend->save($kind, $name, $content, %opts)        # returns the new entry
$backend->tag($kind, $name, $project)                # dies if $name unknown
$backend->untag($kind, $name, $project)
$backend->history($kind, $name)                      # arrayref, newest first
$backend->mark_useful($kind, $name)                  # returns the new count

Additional methods for lifecycle management (added alongside this module):

$backend->archive($kind, $name, %opts)              # soft delete, returns entry
$backend->restore($kind, $name, %opts)              # undo archive, returns entry
$backend->purge($kind, $name, %opts)                # permanent delete, returns status
$backend->list_archived($kind, $project)             # arrayref of archived entries
$backend->audit_log($kind, $name, $action, $limit)  # arrayref of audit entries

Options for archive/restore/purge: author (required), expected_revision (optional), reason (optional).

MCP::Server::KnowledgeStore::Store already implements all of it, since this is exactly the API it exposed before this module existed. Passing a different object is how a resource can bring its own storage instead of Store's entries/revisions tables, as long as it answers to the same shape.

METHODS

register

MCP::Server::KnowledgeStore::Tools::Revisioned->register(
  $server, $backend, kind => 'memory', plural => 'memories',
  type => 1, search => 1,
);

kind is required. plural defaults to "${kind}s". type (default false) adds the type property/requirement save_* memory needs and skill doesn't. search (default false) additionally registers search_$plural.

AUTHOR

Wesley Schwengle <waterkip@cpan.org>

COPYRIGHT AND LICENSE

This software is Copyright (c) 2026 by Wesley Schwengle.

This is free software, licensed under:

The (three-clause) BSD License