@dollhousemcp/mcp-server 2.0.14 → 2.0.16

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 (35) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/generated/version.d.ts +2 -2
  3. package/dist/generated/version.js +3 -3
  4. package/dist/handlers/ElementCRUDHandler.d.ts.map +1 -1
  5. package/dist/handlers/ElementCRUDHandler.js +7 -3
  6. package/dist/handlers/mcp-aql/MCPAQLHandler.d.ts.map +1 -1
  7. package/dist/handlers/mcp-aql/MCPAQLHandler.js +35 -19
  8. package/dist/handlers/mcp-aql/OperationSchema.d.ts.map +1 -1
  9. package/dist/handlers/mcp-aql/OperationSchema.js +4 -3
  10. package/dist/handlers/mcp-aql/evaluatePermission.d.ts +2 -1
  11. package/dist/handlers/mcp-aql/evaluatePermission.d.ts.map +1 -1
  12. package/dist/handlers/mcp-aql/evaluatePermission.js +22 -11
  13. package/dist/handlers/strategies/BaseActivationStrategy.d.ts.map +1 -1
  14. package/dist/handlers/strategies/BaseActivationStrategy.js +12 -3
  15. package/dist/handlers/strategies/PersonaActivationStrategy.js +2 -2
  16. package/dist/utils/permissionHooks.d.ts +38 -0
  17. package/dist/utils/permissionHooks.d.ts.map +1 -0
  18. package/dist/utils/permissionHooks.js +194 -0
  19. package/dist/web/public/index.html +12 -6
  20. package/dist/web/public/permissions.css +11 -0
  21. package/dist/web/public/permissions.js +43 -12
  22. package/dist/web/public/setup.css +172 -1
  23. package/dist/web/public/setup.js +353 -20
  24. package/dist/web/routes/permissionRoutes.d.ts.map +1 -1
  25. package/dist/web/routes/permissionRoutes.js +64 -15
  26. package/dist/web/routes/setupRoutes.d.ts +3 -0
  27. package/dist/web/routes/setupRoutes.d.ts.map +1 -1
  28. package/dist/web/routes/setupRoutes.js +14 -3
  29. package/package.json +6 -1
  30. package/scripts/pretooluse-codex.sh +6 -0
  31. package/scripts/pretooluse-cursor.sh +6 -0
  32. package/scripts/pretooluse-dollhouse.sh +110 -0
  33. package/scripts/pretooluse-gemini.sh +6 -0
  34. package/scripts/pretooluse-windsurf.sh +6 -0
  35. package/server.json +2 -2
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # pretooluse-codex.sh — Manual Codex hook wrapper for DollhouseMCP
3
+
4
+ export DOLLHOUSE_HOOK_PLATFORM="codex"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ exec bash "$SCRIPT_DIR/pretooluse-dollhouse.sh"
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # pretooluse-cursor.sh — Manual Cursor hook wrapper for DollhouseMCP
3
+
4
+ export DOLLHOUSE_HOOK_PLATFORM="cursor"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ exec bash "$SCRIPT_DIR/pretooluse-dollhouse.sh"
@@ -0,0 +1,110 @@
1
+ #!/bin/bash
2
+ # pretooluse-dollhouse.sh — PreToolUse hook for DollhouseMCP permission evaluation
3
+ #
4
+ # Routes permission checks through DollhouseMCP's evaluate_permission endpoint.
5
+ # The DollhouseMCP web server runs alongside the MCP stdio server on a dynamic port.
6
+ # Port discovery via ~/.dollhouse/run/permission-server.port
7
+ #
8
+ # Input: JSON on stdin. Claude Code uses { tool_name, tool_input }.
9
+ # Other clients may expose { toolName, toolInput } or { tool, input }.
10
+ # Output: JSON on stdout (platform-specific hook response; Claude Code expects
11
+ # hookSpecificOutput.permissionDecision for PreToolUse)
12
+ #
13
+ # Fail-open: if the server is unreachable or returns an error, the hook allows
14
+ # the action rather than blocking the user.
15
+ #
16
+ # Set DOLLHOUSE_HOOK_DEBUG=1 for debug logging to stderr.
17
+ # Set DOLLHOUSE_HOOK_PLATFORM to override the platform sent to the server.
18
+
19
+ PORT_FILE="$HOME/.dollhouse/run/permission-server.port"
20
+ MAX_RETRIES=2
21
+ INITIAL_TIMEOUT=5
22
+ HOOK_PLATFORM="${DOLLHOUSE_HOOK_PLATFORM:-claude_code}"
23
+
24
+ # Debug logging helper — writes to stderr so it doesn't pollute stdout
25
+ debug() {
26
+ if [[ "${DOLLHOUSE_HOOK_DEBUG:-0}" == "1" ]]; then
27
+ echo "[pretooluse] $*" >&2
28
+ fi
29
+ return 0
30
+ }
31
+
32
+ # Discover the port from the port file
33
+ if [[ -f "$PORT_FILE" ]]; then
34
+ PORT=$(cat "$PORT_FILE" 2>/dev/null)
35
+ debug "Port file found: $PORT"
36
+ else
37
+ debug "No port file at $PORT_FILE — fail open"
38
+ exit 0
39
+ fi
40
+
41
+ # Validate port is a number
42
+ if ! [[ "$PORT" =~ ^[0-9]+$ ]]; then
43
+ debug "Invalid port value: $PORT — fail open"
44
+ exit 0
45
+ fi
46
+
47
+ ENDPOINT="http://127.0.0.1:${PORT}/api/evaluate_permission"
48
+ debug "Endpoint: $ENDPOINT"
49
+
50
+ # Read the hook input from stdin
51
+ INPUT=$(cat)
52
+
53
+ # Extract tool_name and tool_input from the hook payload
54
+ TOOL_NAME=$(echo "$INPUT" | jq -r '.tool_name // .toolName // .tool // .name // empty' 2>/dev/null)
55
+ TOOL_INPUT=$(echo "$INPUT" | jq -c '.tool_input // .toolInput // .input // {}' 2>/dev/null)
56
+
57
+ # If we can't parse the input, fail open
58
+ if [[ -z "$TOOL_NAME" ]]; then
59
+ debug "Could not parse tool_name from input — fail open"
60
+ exit 0
61
+ fi
62
+
63
+ debug "Evaluating: $TOOL_NAME"
64
+ debug "Platform: $HOOK_PLATFORM"
65
+
66
+ if [[ -n "${DOLLHOUSE_SESSION_ID:-}" ]]; then
67
+ debug "Using DOLLHOUSE_SESSION_ID=${DOLLHOUSE_SESSION_ID}"
68
+ fi
69
+
70
+ PAYLOAD=$(jq -cn \
71
+ --arg tool_name "$TOOL_NAME" \
72
+ --arg platform "$HOOK_PLATFORM" \
73
+ --arg session_id "${DOLLHOUSE_SESSION_ID:-}" \
74
+ --argjson input "$TOOL_INPUT" \
75
+ '{
76
+ tool_name: $tool_name,
77
+ input: $input,
78
+ platform: $platform
79
+ } + (if ($session_id | length) > 0 then { session_id: $session_id } else {} end)')
80
+
81
+ # Call the DollhouseMCP permission evaluation endpoint with exponential backoff.
82
+ # Retry on transient failures (connection refused, timeout) but not on HTTP errors.
83
+ ATTEMPT=0
84
+ TIMEOUT=$INITIAL_TIMEOUT
85
+
86
+ while [[ $ATTEMPT -le $MAX_RETRIES ]]; do
87
+ RESPONSE=$(curl -s --max-time "$TIMEOUT" -X POST "$ENDPOINT" \
88
+ -H "Content-Type: application/json" \
89
+ -d "$PAYLOAD" \
90
+ 2>/dev/null)
91
+ CURL_EXIT=$?
92
+
93
+ if [[ $CURL_EXIT -eq 0 ]] && [[ -n "$RESPONSE" ]]; then
94
+ debug "Response (attempt $((ATTEMPT+1))): $RESPONSE"
95
+ echo "$RESPONSE"
96
+ exit 0
97
+ fi
98
+
99
+ ATTEMPT=$((ATTEMPT + 1))
100
+ if [[ $ATTEMPT -le $MAX_RETRIES ]]; then
101
+ BACKOFF=$((TIMEOUT * ATTEMPT))
102
+ debug "Attempt $ATTEMPT failed (curl exit $CURL_EXIT) — retrying in ${BACKOFF}s (timeout ${TIMEOUT}s → $((TIMEOUT * 2))s)"
103
+ sleep "$BACKOFF"
104
+ TIMEOUT=$((TIMEOUT * 2))
105
+ fi
106
+ done
107
+
108
+ # All retries exhausted — fail open
109
+ debug "All $((MAX_RETRIES + 1)) attempts failed — fail open"
110
+ exit 0
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # pretooluse-gemini.sh — Manual Gemini CLI hook wrapper for DollhouseMCP
3
+
4
+ export DOLLHOUSE_HOOK_PLATFORM="gemini"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ exec bash "$SCRIPT_DIR/pretooluse-dollhouse.sh"
@@ -0,0 +1,6 @@
1
+ #!/bin/bash
2
+ # pretooluse-windsurf.sh — Manual Windsurf hook wrapper for DollhouseMCP
3
+
4
+ export DOLLHOUSE_HOOK_PLATFORM="windsurf"
5
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
6
+ exec bash "$SCRIPT_DIR/pretooluse-dollhouse.sh"
package/server.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "name": "io.github.DollhouseMCP/mcp-server",
4
4
  "title": "DollhouseMCP",
5
5
  "description": "OSS to create Personas, Skills, Templates, Agents, and Memories to customize your AI experience.",
6
- "version": "2.0.14",
6
+ "version": "2.0.16",
7
7
  "homepage": "https://dollhousemcp.com",
8
8
  "repository": {
9
9
  "type": "git",
@@ -29,7 +29,7 @@
29
29
  {
30
30
  "registryType": "npm",
31
31
  "identifier": "@dollhousemcp/mcp-server",
32
- "version": "2.0.14",
32
+ "version": "2.0.16",
33
33
  "transport": {
34
34
  "type": "stdio"
35
35
  }