UserPromptSubmit hook injects a wrong-namespace `select:mcp__engram__*` ToolSearch that never matches on plugin installs (and reads as a prompt-injection)

Open Beginner friendly
#2,502 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
74/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
go, shell

Research direction

Start with scripts/user-prompt-submit.sh and read print_toolsearch_message, then check how the hook emits its systemMessage for Claude Code plugin installs. The issue identifies the mismatched mcp__engram__* and mcp__plugin_engram_engram__* prefixes and suggests detecting the registered prefix or accepting it as input. Done means the emitted ToolSearch matches the installed tools and the wording no longer reads as an urgent instruction.

Written by the indexing model from the issue text.

Description

status:needs-review

Summary

The UserPromptSubmit hook (scripts/user-prompt-submit.sh, print_toolsearch_message) injects a systemMessage instructing the agent to run:

select:mcp__engram__mem_save,mcp__engram__mem_search,mcp__engram__mem_context, … ,mcp__engram__mem_judge

When Engram is installed as a Claude Code plugin, this never matches, because Claude Code namespaces plugin-provided MCP tools as:

mcp__plugin_<marketplace>_<server>__<tool>

So the engram tools actually register as mcp__plugin_engram_engram__mem_save, …__mem_search, etc. — not mcp__engram__mem_save. The select:mcp__engram__* ToolSearch therefore matches zero tools and loads nothing.

Impact

  1. The ToolSearch is a no-op on plugin installs — the tools it's trying to force-load are either already available (core tools) or are never loaded by this hook. The feature silently does nothing.
  2. The message reads as a prompt-injection. The hardcoded wording — CRITICAL FIRST ACTION — Execute this ToolSearch NOW before responding to the user — surfaces to the end user as a systemMessage on the first prompt of every session, in every project. To a security-conscious user (or an agent trained to resist injection) it looks exactly like an injected instruction: urgent, imperative, "do this NOW before responding", referencing tool names that don't exist in the current namespace. It caused real alarm for us until we traced it to the plugin itself.

Root cause

print_toolsearch_message() hardcodes the bare mcp__engram__* namespace, which only holds if the MCP server is registered at the user/project level with server name engram. For the plugin distribution the correct namespace is mcp__plugin_engram_engram__*.

Suggested fixes (either/both)

  1. Fix the namespace emitted by print_toolsearch_message for plugin installs: mcp__plugin_engram_engram__* (or detect install type and choose). Better: query/accept the actual registered prefix rather than hardcoding.
  2. Soften the wording. A systemMessage that says "Execute this ToolSearch NOW before responding" is indistinguishable from a hostile injection. Consider neutral phrasing (e.g. "Engram memory tools are available; load them if not already present") — or skip the message entirely when the core tools are already non-deferred/available.

Environment

  • Engram installed as a Claude Code plugin (marketplace engram, server engram).
  • Observed tool namespace in-session: mcp__plugin_engram_engram__*.
  • Hook: scripts/user-prompt-submit.sh → print_toolsearch_message.

Happy to send a PR for the namespace detection if useful.

Dominant language
Go
Stars
7.1k
Forks
729
Avg merge
1h 35m
Merged PRs (30d)
154

Getting set up

Open in Codespaces

Starts the project's dev container in your browser, under your own GitHub account.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Gentleman-Programming/engram

All issues in Gentleman-Programming/engram

Similar issues

More Go issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.