@optimizeoverseas/lacrm-enforcement-wrapper 1.0.1 → 1.0.2
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.
- package/build/index.js +14 -0
- package/package.json +1 -1
package/build/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextpro
|
|
|
7
7
|
// --- Configuration ---
|
|
8
8
|
const MAX_UNIQUE_CONTACTS = 10;
|
|
9
9
|
const MAX_TOTAL_OPERATIONS = 50;
|
|
10
|
+
const INACTIVITY_TIMEOUT_MS = 10 * 60 * 1000; // 10 minutes
|
|
10
11
|
const DOWNSTREAM_COMMAND = 'node';
|
|
11
12
|
const DOWNSTREAM_ARGS = ['/usr/local/lib/node_modules/@optimizeoverseas/lacrm-mcp/build/index.js'];
|
|
12
13
|
// Tools whose names start with these prefixes are filtered out entirely
|
|
@@ -21,6 +22,17 @@ const CONTACT_MUTATING_TOOLS = new Set([
|
|
|
21
22
|
// --- Session state ---
|
|
22
23
|
const modifiedContacts = new Set();
|
|
23
24
|
let totalOperations = 0;
|
|
25
|
+
let lastOperationTime = 0;
|
|
26
|
+
// --- Session management ---
|
|
27
|
+
function checkAndResetSessionIfInactive() {
|
|
28
|
+
const now = Date.now();
|
|
29
|
+
if (lastOperationTime > 0 && (now - lastOperationTime) >= INACTIVITY_TIMEOUT_MS) {
|
|
30
|
+
// Reset session
|
|
31
|
+
modifiedContacts.clear();
|
|
32
|
+
totalOperations = 0;
|
|
33
|
+
}
|
|
34
|
+
lastOperationTime = now;
|
|
35
|
+
}
|
|
24
36
|
// --- Helpers ---
|
|
25
37
|
function isBlocked(toolName) {
|
|
26
38
|
return BLOCKED_PREFIXES.some((p) => toolName.startsWith(p));
|
|
@@ -91,6 +103,8 @@ async function main() {
|
|
|
91
103
|
// 4. Handle tools/call — enforce policies, then forward
|
|
92
104
|
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
93
105
|
const { name, arguments: args } = request.params;
|
|
106
|
+
// Reset session if inactive for 10+ minutes
|
|
107
|
+
checkAndResetSessionIfInactive();
|
|
94
108
|
// Block delete tools that somehow slip through
|
|
95
109
|
if (isBlocked(name)) {
|
|
96
110
|
return {
|