@mnemocyte/mcp 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server-Bwa4mQjX.mjs","names":["isRecord"],"sources":["../src/tools.ts","../src/server.ts"],"sourcesContent":["import type {\n\tCallToolResult,\n\tStandardSchemaWithJSON,\n\tToolAnnotations,\n} from \"@modelcontextprotocol/server\";\nimport type {\n\tBoundMemoryClient,\n\tImportanceLevel,\n\tMemoryKind,\n\tMemoryWithScore,\n} from \"mnemocyte\";\nimport { isMnemocyteError } from \"mnemocyte\";\n\n// The tools mirror `memoryTools` from `mnemocyte/ai-sdk`: the same names,\n// inputs, outputs and checks, written again here because that entry needs\n// the `ai` package. Keep the two in step.\n\n/** Input of the `searchMemories` tool. */\nexport interface SearchMemoriesInput {\n\tquery: string;\n\tlimit?: number;\n\tkinds?: MemoryKind[];\n}\n\n/** A memory as the `searchMemories` tool returns it. */\nexport interface FoundMemory {\n\tid: string;\n\tcontent: string;\n\tkind: MemoryKind;\n\timportance: ImportanceLevel;\n\ttags: string[];\n\t/** ISO 8601 creation time. */\n\tcreatedAt: string;\n\t/** Relevance in `[0, 1]`, rounded to three decimals. */\n\tscore: number;\n}\n\n/** Input of the `saveMemory` tool. */\nexport interface SaveMemoryInput {\n\tcontent: string;\n\tkind?: MemoryKind;\n\timportance?: ImportanceLevel;\n}\n\n/** Input of the `forgetMemory` tool. */\nexport interface ForgetMemoryInput {\n\tid: string;\n}\n\n/** The names of the tools the server can list. */\nexport type MemoryToolName = \"searchMemories\" | \"saveMemory\" | \"forgetMemory\";\n\n/** One tool, ready for `McpServer.registerTool`. */\nexport interface MemoryToolDefinition<Input> {\n\treadonly name: MemoryToolName;\n\treadonly title: string;\n\treadonly description: string;\n\treadonly inputSchema: StandardSchemaWithJSON<Input, Input>;\n\treadonly outputSchema: StandardSchemaWithJSON;\n\treadonly annotations: ToolAnnotations;\n\treadonly run: (input: Input, signal: AbortSignal) => Promise<CallToolResult>;\n}\n\n/** The value that tells the app's memories from the ones a model saved. */\nexport const SAVE_SOURCE = \"saveMemory\";\n\nconst DEFAULT_SEARCH_LIMIT = 5;\nconst MAX_SEARCH_LIMIT = 20;\n\nconst MEMORY_KINDS: readonly MemoryKind[] = [\n\t\"fact\",\n\t\"preference\",\n\t\"instruction\",\n\t\"backstory\",\n\t\"episode\",\n\t\"session\",\n];\nconst IMPORTANCE_LEVELS: readonly ImportanceLevel[] = [\n\t\"low\",\n\t\"normal\",\n\t\"high\",\n\t\"critical\",\n];\nconst SCOPE_FIELDS: ReadonlySet<string> = new Set([\n\t\"scope\",\n\t\"namespace\",\n\t\"entityId\",\n\t\"agentId\",\n\t\"sessionId\",\n\t\"allNamespaces\",\n]);\n\nconst KIND_DESCRIPTION =\n\t\"fact: a stable statement about the user; preference: how they like things done; instruction: a standing request for how to respond; backstory: long-lived background; episode: something that happened; session: context for this conversation only.\";\n\ntype JsonObject = Record<string, unknown>;\ntype Validation<T> =\n\t| { readonly value: T; readonly issues?: undefined }\n\t| { readonly issues: readonly { readonly message: string }[] };\n\nfunction isRecord(value: unknown): value is JsonObject {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction invalid(message: string): Validation<never> {\n\treturn { issues: [{ message }] };\n}\n\nfunction checkFields(\n\tvalue: unknown,\n\tallowed: readonly string[],\n): JsonObject | string {\n\tif (!isRecord(value)) {\n\t\treturn \"Input must be an object.\";\n\t}\n\tfor (const field of Object.keys(value)) {\n\t\tif (allowed.includes(field)) {\n\t\t\tcontinue;\n\t\t}\n\t\treturn SCOPE_FIELDS.has(field)\n\t\t\t? `${field} is not accepted: the memory scope is fixed by the server.`\n\t\t\t: `Unknown field ${field}.`;\n\t}\n\treturn value;\n}\n\nfunction isNonEmptyString(value: unknown): value is string {\n\treturn typeof value === \"string\" && value.trim().length > 0;\n}\n\nfunction isOneOf<T extends string>(\n\tvalue: unknown,\n\toptions: readonly T[],\n): value is T {\n\treturn (\n\t\ttypeof value === \"string\" && (options as readonly string[]).includes(value)\n\t);\n}\n\n/** @internal Exported for tests. */\nexport function validateSearchInput(\n\tvalue: unknown,\n): Validation<SearchMemoriesInput> {\n\tconst input = checkFields(value, [\"query\", \"limit\", \"kinds\"]);\n\tif (typeof input === \"string\") {\n\t\treturn invalid(input);\n\t}\n\tconst { query, limit, kinds } = input;\n\tif (!isNonEmptyString(query)) {\n\t\treturn invalid(\"query must be a non-empty string.\");\n\t}\n\tif (\n\t\tlimit !== undefined &&\n\t\t(typeof limit !== \"number\" ||\n\t\t\t!Number.isInteger(limit) ||\n\t\t\tlimit < 1 ||\n\t\t\tlimit > MAX_SEARCH_LIMIT)\n\t) {\n\t\treturn invalid(`limit must be an integer from 1 to ${MAX_SEARCH_LIMIT}.`);\n\t}\n\tif (\n\t\tkinds !== undefined &&\n\t\t(!Array.isArray(kinds) ||\n\t\t\t!kinds.every((kind) => isOneOf(kind, MEMORY_KINDS)))\n\t) {\n\t\treturn invalid(`kinds must be an array of ${MEMORY_KINDS.join(\", \")}.`);\n\t}\n\treturn {\n\t\tvalue: {\n\t\t\tquery,\n\t\t\t...(limit === undefined ? {} : { limit }),\n\t\t\t...(kinds === undefined ? {} : { kinds: [...kinds] }),\n\t\t},\n\t};\n}\n\n/** @internal Exported for tests. */\nexport function validateSaveInput(value: unknown): Validation<SaveMemoryInput> {\n\tconst input = checkFields(value, [\"content\", \"kind\", \"importance\"]);\n\tif (typeof input === \"string\") {\n\t\treturn invalid(input);\n\t}\n\tconst { content, kind, importance } = input;\n\tif (!isNonEmptyString(content)) {\n\t\treturn invalid(\"content must be a non-empty string.\");\n\t}\n\tif (kind !== undefined && !isOneOf(kind, MEMORY_KINDS)) {\n\t\treturn invalid(`kind must be one of ${MEMORY_KINDS.join(\", \")}.`);\n\t}\n\tif (importance !== undefined && !isOneOf(importance, IMPORTANCE_LEVELS)) {\n\t\treturn invalid(\n\t\t\t`importance must be one of ${IMPORTANCE_LEVELS.join(\", \")}.`,\n\t\t);\n\t}\n\treturn {\n\t\tvalue: {\n\t\t\tcontent,\n\t\t\t...(kind === undefined ? {} : { kind }),\n\t\t\t...(importance === undefined ? {} : { importance }),\n\t\t},\n\t};\n}\n\n/** @internal Exported for tests. */\nexport function validateForgetInput(\n\tvalue: unknown,\n): Validation<ForgetMemoryInput> {\n\tconst input = checkFields(value, [\"id\"]);\n\tif (typeof input === \"string\") {\n\t\treturn invalid(input);\n\t}\n\tif (!isNonEmptyString(input.id)) {\n\t\treturn invalid(\"id must be a non-empty string.\");\n\t}\n\treturn { value: { id: input.id } };\n}\n\n/**\n * A Standard Schema over a fixed JSON Schema and a validator of our own, so\n * the error messages match `memoryTools` and no schema library is needed.\n */\nfunction schema<T>(\n\tjson: JsonObject,\n\tvalidate: (value: unknown) => Validation<T>,\n): StandardSchemaWithJSON<T, T> {\n\treturn {\n\t\t\"~standard\": {\n\t\t\tversion: 1,\n\t\t\tvendor: \"mnemocyte\",\n\t\t\tvalidate,\n\t\t\tjsonSchema: {\n\t\t\t\tinput: () => structuredClone(json),\n\t\t\t\toutput: () => structuredClone(json),\n\t\t\t},\n\t\t},\n\t};\n}\n\n/** An output schema: the server builds the value, so it is not checked again. */\nfunction outputSchema(json: JsonObject): StandardSchemaWithJSON {\n\treturn schema<unknown>(json, (value) => ({ value }));\n}\n\nconst SEARCH_INPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: {\n\t\tquery: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"What to look for, in natural language.\",\n\t\t},\n\t\tlimit: {\n\t\t\ttype: \"integer\",\n\t\t\tminimum: 1,\n\t\t\tmaximum: MAX_SEARCH_LIMIT,\n\t\t\tdescription: `Most memories to return. Defaults to ${DEFAULT_SEARCH_LIMIT}.`,\n\t\t},\n\t\tkinds: {\n\t\t\ttype: \"array\",\n\t\t\titems: { type: \"string\", enum: [...MEMORY_KINDS] },\n\t\t\tdescription: `Only memories of these kinds. ${KIND_DESCRIPTION}`,\n\t\t},\n\t},\n\trequired: [\"query\"],\n\tadditionalProperties: false,\n};\n\nconst SEARCH_OUTPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: {\n\t\tmemories: {\n\t\t\ttype: \"array\",\n\t\t\tdescription: \"Best match first.\",\n\t\t\titems: {\n\t\t\t\ttype: \"object\",\n\t\t\t\tproperties: {\n\t\t\t\t\tid: { type: \"string\" },\n\t\t\t\t\tcontent: { type: \"string\" },\n\t\t\t\t\tkind: { type: \"string\", enum: [...MEMORY_KINDS] },\n\t\t\t\t\timportance: { type: \"string\", enum: [...IMPORTANCE_LEVELS] },\n\t\t\t\t\ttags: { type: \"array\", items: { type: \"string\" } },\n\t\t\t\t\tcreatedAt: { type: \"string\", format: \"date-time\" },\n\t\t\t\t\tscore: { type: \"number\", minimum: 0, maximum: 1 },\n\t\t\t\t},\n\t\t\t\trequired: [\n\t\t\t\t\t\"id\",\n\t\t\t\t\t\"content\",\n\t\t\t\t\t\"kind\",\n\t\t\t\t\t\"importance\",\n\t\t\t\t\t\"tags\",\n\t\t\t\t\t\"createdAt\",\n\t\t\t\t\t\"score\",\n\t\t\t\t],\n\t\t\t\tadditionalProperties: false,\n\t\t\t},\n\t\t},\n\t},\n\trequired: [\"memories\"],\n\tadditionalProperties: false,\n};\n\nconst SAVE_INPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: {\n\t\tcontent: {\n\t\t\ttype: \"string\",\n\t\t\tdescription:\n\t\t\t\t\"The memory as a short standalone sentence, for example: Prefers metric units.\",\n\t\t},\n\t\tkind: {\n\t\t\ttype: \"string\",\n\t\t\tenum: [...MEMORY_KINDS],\n\t\t\tdescription: `Defaults to fact. ${KIND_DESCRIPTION}`,\n\t\t},\n\t\timportance: {\n\t\t\ttype: \"string\",\n\t\t\tenum: [...IMPORTANCE_LEVELS],\n\t\t\tdescription: \"Defaults to normal.\",\n\t\t},\n\t},\n\trequired: [\"content\"],\n\tadditionalProperties: false,\n};\n\nconst SAVE_OUTPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: { id: { type: \"string\", description: \"Id of the new memory.\" } },\n\trequired: [\"id\"],\n\tadditionalProperties: false,\n};\n\nconst FORGET_INPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: {\n\t\tid: {\n\t\t\ttype: \"string\",\n\t\t\tdescription: \"Id of the memory, from searchMemories.\",\n\t\t},\n\t},\n\trequired: [\"id\"],\n\tadditionalProperties: false,\n};\n\nconst FORGET_OUTPUT: JsonObject = {\n\ttype: \"object\",\n\tproperties: {\n\t\tforgotten: {\n\t\t\ttype: \"boolean\",\n\t\t\tdescription: \"false when no memory with that id is visible.\",\n\t\t},\n\t},\n\trequired: [\"forgotten\"],\n\tadditionalProperties: false,\n};\n\nfunction result(value: JsonObject): CallToolResult {\n\treturn {\n\t\tcontent: [{ type: \"text\", text: JSON.stringify(value) }],\n\t\tstructuredContent: value,\n\t};\n}\n\nfunction toFoundMemory(memory: MemoryWithScore): FoundMemory {\n\treturn {\n\t\tid: memory.id,\n\t\tcontent: memory.content,\n\t\tkind: memory.kind,\n\t\timportance: memory.importance,\n\t\ttags: [...memory.tags],\n\t\tcreatedAt: memory.createdAt.toISOString(),\n\t\tscore: Math.round(memory.score * 1000) / 1000,\n\t};\n}\n\n/** The search tool over a bound client. */\nexport function searchTool(\n\tmemory: BoundMemoryClient,\n): MemoryToolDefinition<SearchMemoriesInput> {\n\treturn {\n\t\tname: \"searchMemories\",\n\t\ttitle: \"Search memories\",\n\t\tdescription:\n\t\t\t\"Search long-term memory about the user for facts, preferences and past events relevant to the conversation. Use it before answering anything that depends on what you know about them. Returns the best matches first, each with an id.\",\n\t\tinputSchema: schema(SEARCH_INPUT, validateSearchInput),\n\t\toutputSchema: outputSchema(SEARCH_OUTPUT),\n\t\tannotations: { readOnlyHint: true, openWorldHint: false },\n\t\tasync run(input, signal) {\n\t\t\tconst found = await memory.search({\n\t\t\t\tquery: input.query,\n\t\t\t\tlimit: input.limit ?? DEFAULT_SEARCH_LIMIT,\n\t\t\t\t...(input.kinds === undefined || input.kinds.length === 0\n\t\t\t\t\t? {}\n\t\t\t\t\t: { kinds: input.kinds }),\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\treturn result({ memories: found.map(toFoundMemory) });\n\t\t},\n\t};\n}\n\n/** The save tool over a bound client. */\nexport function saveTool(\n\tmemory: BoundMemoryClient,\n): MemoryToolDefinition<SaveMemoryInput> {\n\treturn {\n\t\tname: \"saveMemory\",\n\t\ttitle: \"Save a memory\",\n\t\tdescription:\n\t\t\t\"Save one durable fact about the user, such as a preference, a goal or a personal detail they shared, so later conversations can recall it. Save each fact once, as a short standalone sentence. Never save passwords, keys, payment details or other secrets.\",\n\t\tinputSchema: schema(SAVE_INPUT, validateSaveInput),\n\t\toutputSchema: outputSchema(SAVE_OUTPUT),\n\t\tannotations: {\n\t\t\treadOnlyHint: false,\n\t\t\tdestructiveHint: false,\n\t\t\tidempotentHint: false,\n\t\t\topenWorldHint: false,\n\t\t},\n\t\tasync run(input, signal) {\n\t\t\tconst saved = await memory.add({\n\t\t\t\tcontent: input.content,\n\t\t\t\t...(input.kind === undefined ? {} : { kind: input.kind }),\n\t\t\t\t...(input.importance === undefined\n\t\t\t\t\t? {}\n\t\t\t\t\t: { importance: input.importance }),\n\t\t\t\tsource: SAVE_SOURCE,\n\t\t\t\tsignal,\n\t\t\t});\n\t\t\treturn result({ id: saved.id });\n\t\t},\n\t};\n}\n\n/** The forget tool over a bound client. */\nexport function forgetTool(\n\tmemory: BoundMemoryClient,\n): MemoryToolDefinition<ForgetMemoryInput> {\n\treturn {\n\t\tname: \"forgetMemory\",\n\t\ttitle: \"Forget a memory\",\n\t\tdescription:\n\t\t\t\"Delete one memory about the user by its id from searchMemories, for example when they ask you to forget something or a memory is wrong. Duplicates that were merged into it are deleted too. Returns forgotten: false when no memory has that id.\",\n\t\tinputSchema: schema(FORGET_INPUT, validateForgetInput),\n\t\toutputSchema: outputSchema(FORGET_OUTPUT),\n\t\tannotations: {\n\t\t\treadOnlyHint: false,\n\t\t\tdestructiveHint: true,\n\t\t\tidempotentHint: true,\n\t\t\topenWorldHint: false,\n\t\t},\n\t\tasync run(input, signal) {\n\t\t\ttry {\n\t\t\t\t// Search shows only consolidation survivors, so forgetting one\n\t\t\t\t// also deletes the duplicates merged into it.\n\t\t\t\tawait memory.delete({ id: input.id, dependents: \"delete\", signal });\n\t\t\t\treturn result({ forgotten: true });\n\t\t\t} catch (error) {\n\t\t\t\tif (isMnemocyteError(error) && error.code === \"NOT_FOUND\") {\n\t\t\t\t\treturn result({ forgotten: false });\n\t\t\t\t}\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t},\n\t};\n}\n","import { readFileSync } from \"node:fs\";\nimport { McpServer } from \"@modelcontextprotocol/server\";\nimport type { BoundMemoryClient } from \"mnemocyte\";\nimport {\n\tforgetTool,\n\ttype MemoryToolDefinition,\n\ttype MemoryToolName,\n\tsaveTool,\n\tsearchTool,\n} from \"./tools.js\";\n\n/** Options for {@link createMemoryMcpServer}. */\nexport interface MemoryMcpServerOptions {\n\t/**\n\t * A client bound to one scope, from `memory.for(scope)`. Every tool reads\n\t * and writes that scope only; no tool input can name another.\n\t */\n\treadonly memory: BoundMemoryClient;\n\t/**\n\t * List `forgetMemory`, which deletes a memory for good.\n\t * @defaultValue `false`\n\t */\n\treadonly allowForget?: boolean;\n\t/**\n\t * List `searchMemories` only. Cannot be combined with `allowForget`.\n\t * @defaultValue `false`\n\t */\n\treadonly readOnly?: boolean;\n}\n\nconst OPTION_KEYS: readonly string[] = [\"memory\", \"allowForget\", \"readOnly\"];\n\n/** The package name and version, read from `package.json` once. */\nexport const SERVER_INFO: { readonly name: string; readonly version: string } =\n\treadServerInfo();\n\nfunction readServerInfo(): { name: string; version: string } {\n\t// `../package.json` is the package root from both src/ and dist/. An app\n\t// that bundles this module moves it, so a missing file is not an error.\n\tlet manifest: unknown;\n\ttry {\n\t\tmanifest = JSON.parse(\n\t\t\treadFileSync(new URL(\"../package.json\", import.meta.url), \"utf8\"),\n\t\t);\n\t} catch {\n\t\tmanifest = undefined;\n\t}\n\tconst version =\n\t\ttypeof manifest === \"object\" &&\n\t\tmanifest !== null &&\n\t\t\"version\" in manifest &&\n\t\ttypeof manifest.version === \"string\"\n\t\t\t? manifest.version\n\t\t\t: \"unknown\";\n\treturn { name: \"mnemocyte-mcp\", version };\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n\treturn typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction isBoundClient(value: unknown): value is BoundMemoryClient {\n\treturn (\n\t\tisRecord(value) &&\n\t\tisRecord(value.scope) &&\n\t\ttypeof value.search === \"function\" &&\n\t\ttypeof value.add === \"function\" &&\n\t\ttypeof value.delete === \"function\"\n\t);\n}\n\nfunction isOptionalBoolean(value: unknown): value is boolean | undefined {\n\treturn value === undefined || typeof value === \"boolean\";\n}\n\n/** The tools a server with these options lists, in order. */\nexport function toolNames(options: {\n\treadonly allowForget?: boolean | undefined;\n\treadonly readOnly?: boolean | undefined;\n}): MemoryToolName[] {\n\tif (options.readOnly === true) {\n\t\treturn [\"searchMemories\"];\n\t}\n\treturn options.allowForget === true\n\t\t? [\"searchMemories\", \"saveMemory\", \"forgetMemory\"]\n\t\t: [\"searchMemories\", \"saveMemory\"];\n}\n\nfunction register<Input>(\n\tserver: McpServer,\n\ttool: MemoryToolDefinition<Input>,\n): void {\n\tserver.registerTool(\n\t\ttool.name,\n\t\t{\n\t\t\ttitle: tool.title,\n\t\t\tdescription: tool.description,\n\t\t\tinputSchema: tool.inputSchema,\n\t\t\toutputSchema: tool.outputSchema,\n\t\t\tannotations: tool.annotations,\n\t\t},\n\t\t(input, context) => tool.run(input, context.mcpReq.signal),\n\t);\n}\n\n/**\n * An MCP server with Mnemocyte's memory tools over one bound client:\n * `searchMemories` and `saveMemory`, plus `forgetMemory` with\n * `allowForget`. The scope comes from `memory.for(scope)` on your side; no\n * tool takes a scope field, so a client or a prompt injection cannot reach\n * another scope's memories.\n *\n * Connect it to a transport yourself, or use the `mnemocyte-mcp` bin for\n * stdio. Create one per connection: an `McpServer` serves one transport.\n *\n * @throws {TypeError} When `memory` is not a bound client, an option is\n * unknown or not a boolean, or `readOnly` and `allowForget` are both set.\n *\n * @example\n * ```ts\n * import { createMemoryMcpServer } from \"@mnemocyte/mcp\";\n * import { memory } from \"./memory.ts\";\n *\n * const server = createMemoryMcpServer({\n * memory: memory.for({ entityId: user.id }),\n * });\n * ```\n */\nexport function createMemoryMcpServer(\n\toptions: MemoryMcpServerOptions,\n): McpServer {\n\tif (!isRecord(options)) {\n\t\tthrow new TypeError(\"createMemoryMcpServer requires an options object.\");\n\t}\n\tfor (const key of Object.keys(options)) {\n\t\tif (!OPTION_KEYS.includes(key)) {\n\t\t\tthrow new TypeError(`createMemoryMcpServer: unknown option ${key}.`);\n\t\t}\n\t}\n\tconst { memory, allowForget, readOnly } = options;\n\tif (!isBoundClient(memory)) {\n\t\tthrow new TypeError(\n\t\t\t\"createMemoryMcpServer requires a bound client: pass memory.for(scope), not the client itself.\",\n\t\t);\n\t}\n\tif (!isOptionalBoolean(allowForget) || !isOptionalBoolean(readOnly)) {\n\t\tthrow new TypeError(\n\t\t\t\"createMemoryMcpServer: allowForget and readOnly must be booleans.\",\n\t\t);\n\t}\n\tif (allowForget === true && readOnly === true) {\n\t\tthrow new TypeError(\n\t\t\t\"createMemoryMcpServer: readOnly and allowForget cannot both be set.\",\n\t\t);\n\t}\n\n\tconst server = new McpServer(SERVER_INFO, {\n\t\tcapabilities: { tools: {} },\n\t});\n\tfor (const name of toolNames({ allowForget, readOnly })) {\n\t\tswitch (name) {\n\t\t\tcase \"searchMemories\":\n\t\t\t\tregister(server, searchTool(memory));\n\t\t\t\tbreak;\n\t\t\tcase \"saveMemory\":\n\t\t\t\tregister(server, saveTool(memory));\n\t\t\t\tbreak;\n\t\t\tcase \"forgetMemory\":\n\t\t\t\tregister(server, forgetTool(memory));\n\t\t\t\tbreak;\n\t\t}\n\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AM,IAAI,UAAU,yCAAyC,IAAI,EAAE;CAGrE,MAAM,EAAE,QAAQ,aAAa,aAAa;CAC1C,IAAI,CAAC,cAAc,MAAM,GACxB,MAAM,IAAI,UACT,+FACD;CAED,IAAI,CAAC,kBAAkB,WAAW,KAAK,CAAC,kBAAkB,QAAQ,GACjE,MAAM,IAAI,UACT,mEACD;CAED,IAAI,gBAAgB,QAAQ,aAAa,MACxC,MAAM,IAAI,UACT,qEACD;CAGD,MAAM,SAAS,IAAI,UAAU,aAAa,EACzC,cAAc,EAAE,OAAO,CAAC,EAAE,EAC3B,CAAC;CACD,KAAK,MAAM,QAAQ,UAAU;EAAE;EAAa;CAAS,CAAC,GACrD,QAAQ,MAAR;EACC,KAAK;GACJ,SAAS,QAAQ,WAAW,MAAM,CAAC;GACnC;EACD,KAAK;GACJ,SAAS,QAAQ,SAAS,MAAM,CAAC;GACjC;EACD,KAAK,gBACJ,SAAS,QAAQ,WAAW,MAAM,CAAC;CAErC;CAED,OAAO;AACR"}
@@ -0,0 +1,2 @@
1
+ // Empty on purpose: the bin loads this file in place of React's
2
+ // server-only package, which throws outside React Server Components.
package/package.json CHANGED
@@ -1,6 +1,70 @@
1
1
  {
2
2
  "name": "@mnemocyte/mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "description": "An MCP server for Mnemocyte memory: search, save and forget for one fixed scope.",
5
+ "type": "module",
6
+ "sideEffects": false,
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "exports": {
11
+ ".": "./dist/index.mjs",
12
+ "./package.json": "./package.json"
13
+ },
14
+ "types": "./dist/index.d.mts",
15
+ "bin": {
16
+ "mnemocyte-mcp": "./dist/cli.mjs"
17
+ },
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/Meenic/mnemocyte.git",
21
+ "directory": "packages/mcp"
22
+ },
23
+ "keywords": [
24
+ "mcp",
25
+ "model-context-protocol",
26
+ "mcp-server",
27
+ "ai-memory",
28
+ "agent-memory",
29
+ "mnemocyte"
30
+ ],
31
+ "author": "Meenic",
32
+ "license": "MIT",
33
+ "funding": "https://github.com/sponsors/Meenic",
34
+ "bugs": {
35
+ "url": "https://github.com/Meenic/mnemocyte/issues"
36
+ },
37
+ "homepage": "https://github.com/Meenic/mnemocyte/blob/main/docs/guide/mcp.md",
38
+ "publishConfig": {
39
+ "access": "public",
40
+ "provenance": true
41
+ },
42
+ "engines": {
43
+ "node": ">=22.18"
44
+ },
45
+ "peerDependencies": {
46
+ "mnemocyte": "^1.1.0"
47
+ },
48
+ "devDependencies": {
49
+ "@arethetypeswrong/cli": "0.18.5",
50
+ "@mnemocyte/loader": "0.0.0",
51
+ "@modelcontextprotocol/client": "^2.4.0",
52
+ "@types/node": "^22.20.5",
53
+ "mnemocyte": "1.4.0",
54
+ "publint": "0.3.25",
55
+ "tsdown": "0.23.1",
56
+ "typescript": "^6.0.3",
57
+ "vitest": "5.0.5"
58
+ },
59
+ "dependencies": {
60
+ "@modelcontextprotocol/server": "^2.4.0"
61
+ },
62
+ "scripts": {
63
+ "build": "tsdown",
64
+ "checktypes": "tsc --noEmit --project tsconfig.build.json && tsc --noEmit",
65
+ "test": "pnpm build && vitest run",
66
+ "test:unit": "vitest run",
67
+ "lint:package": "pnpm build && node scripts/check-package.ts",
68
+ "pack:check": "pnpm pack --dry-run"
69
+ }
6
70
  }