MCPcopy Index your code
hub / github.com/modelcontextprotocol/python-sdk / save

Method save

examples/mcpserver/memory.py:97–130  ·  view source on GitHub ↗
(self, deps: Deps)

Source from the content-addressed store, hash-verified

95 return cls(content=content, embedding=embedding)
96
97 async def save(self, deps: Deps):
98 async with deps.pool.acquire() as conn:
99 if self.id is None:
100 result = await conn.fetchrow(
101 """
102 INSERT INTO memories (content, summary, importance, access_count,
103 timestamp, embedding)
104 VALUES ($1, $2, $3, $4, $5, $6)
105 RETURNING id
106 """,
107 self.content,
108 self.summary,
109 self.importance,
110 self.access_count,
111 self.timestamp,
112 self.embedding,
113 )
114 self.id = result["id"]
115 else:
116 await conn.execute(
117 """
118 UPDATE memories
119 SET content = $1, summary = $2, importance = $3,
120 access_count = $4, timestamp = $5, embedding = $6
121 WHERE id = $7
122 """,
123 self.content,
124 self.summary,
125 self.importance,
126 self.access_count,
127 self.timestamp,
128 self.embedding,
129 self.id,
130 )
131
132 async def merge_with(self, other: Self, deps: Deps):
133 self.content = await do_ai(

Callers 4

merge_withMethod · 0.95
mainFunction · 0.80
add_memoryFunction · 0.80
take_screenshotFunction · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected