Add generic memory gateway v1

This commit is contained in:
2026-05-05 16:18:31 +08:00
parent ba84b1ddb3
commit e65731a273
54 changed files with 4082 additions and 49 deletions

View File

@ -0,0 +1,135 @@
"""MCP tool definitions for the generic Memory Gateway contract.
The legacy MCP endpoint in server.py remains available. These definitions are
the target v1 tool contract for Nanobot, Hermes Agent, OpenClaw, and other
agent frameworks.
"""
MEMORY_GATEWAY_MCP_TOOLS = [
{
"name": "memory_search",
"description": "Search accessible memories with user/agent/workspace/session isolation.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"session_id": {"type": "string"},
"query": {"type": "string"},
"namespaces": {"type": "array", "items": {"type": "string"}},
"limit": {"type": "integer", "default": 10},
},
"required": ["user_id", "query"],
},
},
{
"name": "memory_upsert",
"description": "Create or update a memory record after ACL and namespace routing.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"session_id": {"type": "string"},
"namespace": {"type": "string"},
"memory_type": {"type": "string"},
"content": {"type": "string"},
"summary": {"type": "string"},
"tags": {"type": "array", "items": {"type": "string"}},
"importance": {"type": "number"},
"confidence": {"type": "number"},
"visibility": {"type": "string"},
},
"required": ["user_id", "content"],
},
},
{
"name": "memory_append_episode",
"description": "Append temporary episode/session memory without automatically promoting it.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"session_id": {"type": "string"},
"content": {"type": "string"},
"events": {"type": "array", "items": {"type": "object"}},
"tags": {"type": "array", "items": {"type": "string"}},
},
"required": ["user_id", "session_id", "content"],
},
},
{
"name": "memory_commit_session",
"description": "Promote selected session memories into long-term memory via consolidation.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"session_id": {"type": "string"},
"promote": {"type": "boolean", "default": True},
"min_importance": {"type": "number", "default": 0.6},
},
"required": ["user_id", "session_id"],
},
},
{
"name": "memory_get_profile",
"description": "Get the effective user profile memory.",
"inputSchema": {
"type": "object",
"properties": {"user_id": {"type": "string"}},
"required": ["user_id"],
},
},
{
"name": "memory_list_namespaces",
"description": "List namespaces visible to the current user/agent/workspace context.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"session_id": {"type": "string"},
},
"required": ["user_id"],
},
},
{
"name": "memory_delete",
"description": "Delete or archive a memory record if the caller has access.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"memory_id": {"type": "string"},
},
"required": ["user_id", "memory_id"],
},
},
{
"name": "memory_feedback",
"description": "Attach quality feedback to a memory record for pruning/merge decisions.",
"inputSchema": {
"type": "object",
"properties": {
"user_id": {"type": "string"},
"agent_id": {"type": "string"},
"workspace_id": {"type": "string"},
"memory_id": {"type": "string"},
"feedback": {"type": "string"},
"comment": {"type": "string"},
},
"required": ["user_id", "memory_id", "feedback"],
},
},
]