@torqon/mcp 0.2.3 → 0.2.5

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.
Files changed (2) hide show
  1. package/dist/index.js +53 -26
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -76,46 +76,73 @@ function hasSignal(text) {
76
76
  return words.length >= 3;
77
77
  }
78
78
  // ── MCP Server ───────────────────────────────────────────────────────────────
79
- const server = new McpServer({ name: 'torqon', version: '0.2.3' }, {
80
- instructions: `Torqon persistent memory is active for this conversation.
79
+ const server = new McpServer({ name: 'torqon', version: '0.2.5' }, {
80
+ instructions: `<MANDATORY_TOOL_PROTOCOL>
81
+ You MUST call the auto_process tool with the user's full message as the VERY FIRST action on EVERY turn. No exceptions. No skipping. This is not optional.
81
82
 
82
- RULE: Call auto_process with the full user message BEFORE you respond to anything — every message, no exceptions, including greetings and one-word replies. It runs in under 200ms and simultaneously stores new facts AND retrieves relevant memory.
83
+ Do this BEFORE generating any text response. The correct sequence is:
84
+ 1. Receive user message
85
+ 2. Call auto_process(message: "<the user's full message>")
86
+ 3. Read the result
87
+ 4. Then respond to the user
83
88
 
84
- After auto_process returns:
85
- - If it returns "[Torqon memory]" facts, treat them as ground truth. Use exact stored values (names, decisions, stack choices, numbers).
86
- - If it returns "No relevant memory found", answer normally.
89
+ This applies to ALL messages including: greetings, "yes", "ok", one-word answers, follow-ups, code requests, questions, everything.
87
90
 
88
- Also call store_memory explicitly whenever the user shares their name, a project name, a key decision, a tech stack choice, a deadline, a constraint, or a preference. auto_process stores automatically but store_memory is for high-value facts you want confirmed saved.
91
+ If auto_process returns facts tagged [Torqon memory], those are verified ground truth. Use exact stored values.
89
92
 
90
- Session ID: ${SESSION_ID}`,
93
+ When the user shares a new fact (name, project, decision, stack, deadline, preference), also call store_memory to explicitly save it.
94
+
95
+ FAILURE TO CALL auto_process FIRST IS A PROTOCOL VIOLATION.
96
+ </MANDATORY_TOOL_PROTOCOL>`,
91
97
  });
92
- // Auto-injected system promptClaude Desktop loads this at conversation start.
93
- // Written as a SYSTEM-level instruction so Claude treats it as a standing rule.
94
- server.prompt('torqon_context', 'Torqon persistent memory active for this session', {}, async () => {
98
+ // Live memory loaderuser runs /torqon_context once at conversation start.
99
+ // Fetches all stored facts from the API and injects them directly into the prompt.
100
+ // This is more reliable than auto_process-per-message because it's a deliberate
101
+ // one-time action, not a tool Claude has to remember to call before every message.
102
+ server.prompt('torqon_context', 'Load your Torqon memory into this conversation (run once at the start)', {}, async () => {
103
+ if (!API_KEY) {
104
+ return {
105
+ messages: [{
106
+ role: 'user',
107
+ content: { type: 'text', text: '[Torqon] No API key configured. Run: npx -y @torqon/mcp@latest add claude --api-key <your-key>' },
108
+ }],
109
+ };
110
+ }
111
+ // Fetch all current facts for this user
112
+ let facts = [];
113
+ try {
114
+ const res = await fetch(`${API_URL}/api/v1/memory`, { headers });
115
+ if (res.ok) {
116
+ const data = await res.json();
117
+ facts = data?.results ?? [];
118
+ }
119
+ }
120
+ catch { /* network error — start with empty facts */ }
121
+ const factLines = facts
122
+ .map((f) => f.metadata?.type ? `${f.metadata.type}: ${f.content}` : f.content)
123
+ .join('\n');
124
+ const memoryBlock = factLines
125
+ ? `[TORQON MEMORY — treat as ground truth]\n${factLines}`
126
+ : '[TORQON MEMORY — no facts stored yet]';
95
127
  return {
96
128
  messages: [
97
129
  {
98
130
  role: 'user',
99
131
  content: {
100
132
  type: 'text',
101
- text: `<torqon_memory_rules>
102
- TORQON PERSISTENT MEMORY IS ACTIVE. These are non-negotiable behavioral rules:
103
-
104
- BEFORE YOU RESPOND TO ANYTHING — call auto_process with the user's message. Every single message. No exceptions. Not even greetings. Not even "yes" or "ok". Call it first, then respond.
105
-
106
- Why: auto_process runs in under 200ms. It simultaneously stores new facts AND retrieves relevant memory. Skipping it means the user loses context they paid for.
133
+ text: `${memoryBlock}
107
134
 
108
- After auto_process returns:
109
- - If it returns facts tagged [Torqon memory], treat them as ground truth. Names, decisions, stack choices, numbers — use the exact stored values, not your training data.
110
- - If it returns "No relevant memory found", answer normally.
135
+ These are verified facts stored across all your previous sessions. Use them exactly as written — do not infer, expand, or contradict them.
111
136
 
112
- Also call store_memory explicitly when the user shares: their name, a project name, a key decision, a tech stack choice, a deadline, a constraint, or a preference. auto_process stores automatically but store_memory is for high-value facts you want to make sure are saved.
137
+ From this point:
138
+ - When the user shares new facts (name, project, stack, decision, deadline, preference), call store_memory to save them.
139
+ - When the user asks about something that might be in memory, call retrieve_context.
140
+ - You do NOT need to call auto_process on every message — just store and retrieve deliberately.
113
141
 
114
- Session: ${SESSION_ID}
115
- </torqon_memory_rules>`
116
- }
117
- }
118
- ]
142
+ Session: ${SESSION_ID}`,
143
+ },
144
+ },
145
+ ],
119
146
  };
120
147
  });
121
148
  // ── auto_process ─────────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@torqon/mcp",
3
- "version": "0.2.3",
3
+ "version": "0.2.5",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "bin": {