Repository navigation
Share one server between agents over HTTP, with a control lease - #16
Conversation
OBS_MCP_HTTP_PORT serves Streamable HTTP on 127.0.0.1 through the SDK's createMcpHandler and a small node:http adapter. Host and Origin must be localhost (DNS rebinding protection), and OBS_MCP_HTTP_TOKEN requires a bearer token. Resource notifications go through the handler's event bus once, instead of per-request listeners that would leak. obs-claim-control gives one client control of OBS for a set time: tools that change OBS refuse other clients' calls, while reading and stopping outputs always work. obs-release-control and obs-control-status manage it, and obs-take-start claims control for the length of the take. Clients are told apart by the name they report. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Vjn8uBEa4mJshaQU3pFuqX
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18bcc206d6
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const { take } = started; | ||
| // Other clients sharing this server cannot change OBS until the take stops. | ||
| const holder = callerName(server, ctx); | ||
| if (claim(client, holder, 240, `recording take ${take.id}`).ok) take.leaseHolder = holder; |
There was a problem hiding this comment.
Claim control before starting the take
When client A starts a take with no active lease, startTake awaits the preflight, OBS startup, and monitor startup before this claim runs. Client B can claim control during that interval; A will still start recording, this claim then silently returns ok: false, and no leaseHolder is stored, allowing B to modify OBS while the take records and potentially blocking A's subsequent take operations. Reserve control before the asynchronous startup and release it if startup fails.
Useful? React with 👍 / 👎.
| const { take } = started; | ||
| // Other clients sharing this server cannot change OBS until the take stops. | ||
| const holder = callerName(server, ctx); | ||
| if (claim(client, holder, 240, `recording take ${take.id}`).ok) take.leaseHolder = holder; |
There was a problem hiding this comment.
Keep automatic control for the full take
For any take lasting longer than four hours, this hard-coded 240-minute lease expires even though the recording and take monitor continue indefinitely. The next lease check removes it, after which another agent can change OBS during the active take, contradicting the tool's promise to hold control until obs-take-stop; the automatic lease should instead remain tied to the take lifecycle or be renewed while the take is active.
Useful? React with 👍 / 👎.
| return (name: string, config: { annotations?: ToolAnnotations }, callback: (...args: unknown[]) => unknown) => { | ||
| if (config.annotations?.readOnlyHint === true || ALWAYS_ALLOWED.has(name)) { | ||
| return Reflect.apply(registerTool, target, [name, config, callback]); |
There was a problem hiding this comment.
Exempt stop requests sent through generic tools
When a non-holder uses obs-call-request or obs-batch to send StopRecord, StopStream, StopOutput, or another stop request, the wrapper treats the generic tool as an ordinary mutator and rejects it without inspecting its arguments. This breaks the stated guarantee that stopping outputs is always allowed, particularly when tool filtering exposes the protocol escape hatch but not the explicit stop tool; recognize stop-only generic calls while continuing to reject batches containing other mutations.
Useful? React with 👍 / 👎.
Stacked on #15.
Why: Claude and Codex each ran their own stdio server with their own OBS connection, so I had to stay off OBS by hand while Codex recorded. Now both can connect to one server, and whoever is recording holds control.
What
OBS_MCP_HTTP_PORTserves Streamable HTTP athttp://127.0.0.1:<port>/mcp(0picks a free port), using the SDK'screateMcpHandlerand a smallnode:httpadapter (no new dependency).OBS_MCP_HTTP_TOKENrequires a bearer token, compared in constant time.forwardResourceEvents). The stateless per-request servers don't attach OBS listeners, which would leak.OBS_MCP_DYNAMIC_TOOLSETSis ignored over HTTP, with a log line: stateless requests can't keep per-session groups.obs-claim-control(minutes, reason) gives the calling client control. Tools that change OBS then refuse other clients' calls.obs-stop-record/-stream/-output/…,obs-take-stop) always work.obs-release-controlandobs-control-statusmanage it. It expires on its own.obs-take-startclaims control for the length of the take;obs-take-stopreleases it.core93; core read-only 42.Tests
npm run checkpasses: 186 unit, 14 e2e.http.e2e.test.tsagainst the compiled server:🤖 Generated with Claude Code
https://claude.ai/code/session_01Vjn8uBEa4mJshaQU3pFuqX