Skip to content

feat: inject freshell MCP server into freshclaude SDK sessions#269

Merged
danshapiro merged 3 commits intomainfrom
feat/freshclaude-mcp-injection
Apr 1, 2026
Merged

feat: inject freshell MCP server into freshclaude SDK sessions#269
danshapiro merged 3 commits intomainfrom
feat/freshclaude-mcp-injection

Conversation

@danshapiro
Copy link
Copy Markdown
Owner

Summary

  • Export buildMcpServerCommandArgs from server/mcp/config-writer.ts so it can be reused outside terminal-mode config generation
  • Inject mcpServers into SDK query() call in server/sdk-bridge.ts — freshclaude (agent-chat) sessions now get the freshell MCP tool automatically, matching what terminal-mode Claude already gets via --mcp-config
  • MCP server config includes explicit FRESHELL_URL and FRESHELL_TOKEN env vars so the subprocess can connect back to the Freshell server

Test plan

  • 2 new unit tests for exported buildMcpServerCommandArgs (dev + production paths)
  • 7 new unit tests for mcpServers injection (config shape, env vars, PORT derivation, FRESHELL_URL override, AUTH_TOKEN passthrough, defaults)
  • Typecheck passes
  • Full test suite passes (no regressions)

🤖 Generated with Claude Code

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 948653e903

ℹ️ 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".

Comment on lines +104 to +106
env: {
FRESHELL_URL: process.env.FRESHELL_URL || `http://localhost:${Number(process.env.PORT || 3001)}`,
FRESHELL_TOKEN: process.env.AUTH_TOKEN || '',
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Propagate pane context into SDK MCP environment

The injected MCP env only includes FRESHELL_URL and FRESHELL_TOKEN, so SDK-spawned MCP servers have no FRESHELL_TAB_ID/FRESHELL_PANE_ID identity. In server/mcp/freshell-tool.ts, untargeted actions intentionally fall back to the caller tab/pane and otherwise use the currently active viewport tab/pane; with these vars missing, a background freshclaude session can execute send-keys/split-pane/etc. against whichever tab the user is currently viewing instead of its own pane. This is a functional regression introduced by enabling MCP in SDK sessions without caller context propagation.

Useful? React with 👍 / 👎.

mcpServers: {
freshell: {
command: 'node',
args: buildMcpServerCommandArgs(),
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Pass target platform when building MCP server args

buildMcpServerCommandArgs only converts paths to Windows-compatible UNC form when called with platform: 'windows'. Calling it with no platform here hardcodes Unix-style paths, so in WSL setups where CLAUDE_CMD points to a Windows Claude executable, the SDK process receives MCP args like Linux paths that the Windows-side process cannot resolve, and the freshell MCP server fails to launch.

Useful? React with 👍 / 👎.

Dan Shapiro and others added 3 commits April 1, 2026 00:18
Freshclaude (agent-chat) sessions now get the freshell MCP tool
automatically, matching what terminal-mode Claude already gets via
--mcp-config. The MCP server config includes FRESHELL_URL and
FRESHELL_TOKEN env vars so the subprocess can connect back.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>
@danshapiro danshapiro force-pushed the feat/freshclaude-mcp-injection branch from 948653e to b4e70de Compare April 1, 2026 07:25
@danshapiro danshapiro merged commit 9ea56fa into main Apr 1, 2026
1 check passed
@danshapiro danshapiro deleted the feat/freshclaude-mcp-injection branch April 1, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant