feat(middleware): propagate senderIsOwner security context to MCP server#60
Merged
alexey-pelykh merged 1 commit intomainfrom Feb 27, 2026
Merged
feat(middleware): propagate senderIsOwner security context to MCP server#60alexey-pelykh merged 1 commit intomainfrom
alexey-pelykh merged 1 commit intomainfrom
Conversation
…ver (#59) Gate owner-only MCP tools (cron scheduling, gateway admin) behind a senderIsOwner flag resolved from command authorization. Non-owner channel users can no longer instruct the agent to modify cron schedules or restart the gateway via MCP tools. Pipeline: dispatch site → ChannelMessage.senderIsOwner → ChannelBridge env var → MCP server context → tool registration gate. - Add senderIsOwner and toolProfile fields to McpHandlerContext - Read REMOTECLAW_SENDER_IS_OWNER and REMOTECLAW_TOOL_PROFILE env vars in MCP server createContext() - Gate cron/gateway tool registration on ctx.senderIsOwner in registerAllTools() (29 tools for owner, 17 for non-owner) - Add senderIsOwner and toolProfile to ChannelMessage type - Pass security context as env vars in ChannelBridge.#buildMcpConfig() - Thread senderIsOwner through all dispatch sites: - Auto-reply: propagated from resolveCommandAuthorization() - CLI command: always true (CLI user is the bot owner) - Cron: always false (cron agents must not self-modify) - Voice-call: true (callers have direct phone access) - Secure defaults: senderIsOwner defaults to false at every boundary Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
senderIsOwnerflag resolved from command authorizationsenderIsOwnerandtoolProfileend-to-end: dispatch site →ChannelMessage→ ChannelBridge env var → MCP server context → tool registration gatesenderIsOwnerdefaults tofalseat every boundary (defense-in-depth)Changes
src/middleware/mcp-handlers/context.tssenderIsOwnerandtoolProfilefieldssrc/middleware/mcp-server.tsREMOTECLAW_SENDER_IS_OWNERandREMOTECLAW_TOOL_PROFILEenv varssrc/middleware/mcp-tools.tsctx.senderIsOwnersrc/middleware/channel-bridge.ts#buildMcpConfig()src/middleware/types.tssenderIsOwnerandtoolProfiletoChannelMessagesrc/auto-reply/reply/agent-runner-execution.tssenderIsOwnerfromresolveCommandAuthorization()src/commands/agent.tssenderIsOwner: true(CLI user is always owner)src/cron/isolated-agent/run.tssenderIsOwner: false(cron agents must not self-modify)extensions/voice-call/src/core-bridge.tsChannelMessageextensions/voice-call/src/response-generator.tssenderIsOwner: true(voice callers have direct access)Test plan
registerAllToolswithsenderIsOwner: falseregisters only 17 tools (no cron/gateway)registerAllToolswithsenderIsOwner: trueregisters all 29 toolsChannelBridge.#buildMcpConfig()includesREMOTECLAW_SENDER_IS_OWNERenv varsenderIsOwnerisfalsewhen not set on messageREMOTECLAW_TOOL_PROFILEdefaults to"full"when not setpnpm buildpassespnpm formatandpnpm lintcleanCloses #59
🤖 Generated with Claude Code