share
Share agent memories across sessions to enable collaborative knowledge access within user or organizational scopes.
Instructions
Share a memory with a broader scope so other agents can access it. Use when you learn something that would be valuable to other agents serving the same user or organization.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| memory_id | Yes | The ID of the memory to share | |
| target_scope | Yes | Who to share with: user (all agents for this user) or org (all agents in the organization) | |
| user_id | No | Required when sharing to user scope |
Implementation Reference
- The core database logic for sharing a memory, updating its scope in the database.
export async function share( apiKeyId: string, memoryId: string, targetScope: "user" | "org", userId?: string, orgId?: string, ): Promise<boolean> { const result = await sql` UPDATE memories SET scope = ${targetScope}, user_id = COALESCE(${userId || null}, user_id), org_id = COALESCE(${orgId || null}, org_id), updated_at = now() WHERE id = ${memoryId} AND api_key_id = ${apiKeyId} AND deleted_at IS NULL RETURNING id `; return result.length > 0; - packages/mcp-server/src/index.ts:286-315 (registration)The MCP tool registration for 'share', which calls the API backend.
server.tool( "share", "Share a memory with a broader scope so other agents can access it. Use when you learn something that would be valuable to other agents serving the same user or organization.", { memory_id: z.string().describe("The ID of the memory to share"), target_scope: z .enum(["user", "org"]) .describe( "Who to share with: user (all agents for this user) or org (all agents in the organization)", ), user_id: z .string() .optional() .describe("Required when sharing to user scope"), }, async ({ memory_id, target_scope, user_id }) => { await apiCall(`/memories/${memory_id}/share`, "POST", { target_scope, user_id, }); return { content: [ { type: "text" as const, text: `Memory ${memory_id} is now shared at ${target_scope} scope. Other agents with ${target_scope} access can now recall this memory.`, }, ], }; }, );