Skip to main content
Glama

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
NameRequiredDescriptionDefault
memory_idYesThe ID of the memory to share
target_scopeYesWho to share with: user (all agents for this user) or org (all agents in the organization)
user_idNoRequired 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;
  • 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.`,
            },
          ],
        };
      },
    );
Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/AlekseiMarchenko/central-intelligence'

If you have feedback or need assistance with the MCP directory API, please join our Discord server