Skip to content

Conversation

@ammar-agent
Copy link
Collaborator

@ammar-agent ammar-agent commented Dec 7, 2025

Summary

Adds MCP (Model Context Protocol) server support, allowing users to extend agent capabilities with external tool providers.

Features

  • Per-project configuration — Servers configured in .mux/mcp.jsonc apply to all workspaces from that project
  • Per-workspace runtime — Each workspace runs isolated server instances with independent state
  • Slash commands/mcp add|remove|edit for quick configuration from chat
  • Settings UI — Manage servers in Settings → Projects with test button and tool discovery
  • Hot reload — Config changes apply on next message without restart
  • 10-minute idle timeout — Servers automatically stop after inactivity to conserve resources
  • Namespaced tools — Tools prefixed with server name (e.g., memory_create_entities) to prevent collisions

Configuration

// .mux/mcp.jsonc
{
  "servers": {
    "memory": "npx -y @modelcontextprotocol/server-memory",
    "chrome": "npx -y chrome-devtools-mcp@latest --headless"
  }
}

Security

  • Commands are not exposed in the system prompt (may contain secrets)
  • Only server names are shown to the model

Files

  • src/node/services/mcpServerManager.ts — Runtime server lifecycle with idle cleanup
  • src/node/services/mcpConfigService.ts — Config CRUD operations
  • src/node/services/mcpStdioTransport.ts — NDJSON stdio transport
  • src/browser/components/Settings/sections/ProjectSettingsSection.tsx — Settings UI
  • docs/mcp-servers.mdx — User documentation

Generated with mux

@ammar-agent ammar-agent force-pushed the mcp-server-configuration branch 6 times, most recently from fa9d241 to 0eeedab Compare December 8, 2025 15:25
@ammar-agent
Copy link
Collaborator Author

/rerun-ci

@ammar-agent ammar-agent force-pushed the mcp-server-configuration branch 2 times, most recently from 982f167 to eeb3e7d Compare December 8, 2025 16:51
- Track worker error state to reject promises immediately if worker is dead
- Clean up debug logging from aiService.ts
- Improve MCP server logging for better diagnostics
- MCP integration test now passes (was blocked by tokenizer, not MCP)
- Add projects.mcp.test ORPC endpoint
- Add MCPServerManager.testServer() that spawns server, fetches tools, closes
- Add Test button with spinner, success (shows tools), and error states
- 30 second timeout for test operations
- Rename sidebar tab from 'Project' to 'Projects'
- Add project dropdown selector at top of page
- Show full project path below dropdown
- Add inline form to add MCP servers (name + command)
- Enter key submits the add form
- Remove reference to /mcp add command (now done in UI)
- Add testCommand endpoint to test a command before saving to config
- Separate Test and Add buttons in the form
- Test shows success with tool count and names, or error message
- Polished UI with better spacing, labels, and visual hierarchy
- Server list shows tool badge when tested successfully
- Error messages use styled alert boxes
- Empty state with icon for no projects
- Add /mcp edit <name> <command> slash command
- Add inline edit button in Settings UI
- Enter to save, Esc to cancel
Prevents Escape from closing the modal when canceling inline edits.
Also disables spellcheck on MCP command input.
DRY helper for Enter-to-save, Escape-to-cancel pattern with stopPropagation.
Also disable spellcheck on the add command input.
Shows configured servers (name + command) when at least one exists.
Explains they're configured in user's local project's .mux/mcp.jsonc.
MCP returns images with type 'image' and 'mimeType', but AI SDK expects
type 'media' with 'mediaType'. This wraps MCP tool execute functions to
transform the result format, enabling proper image handling for tools
like Chrome DevTools MCP's take_screenshot.
- Add fallback to 'image/png' when MCP mimeType is undefined
- JSON.stringify omits undefined values, which caused mediaType to be
  missing from tool results, breaking image rendering in Anthropic provider
- Add debug logging to trace MCP image content transformation
- Add integration test verifying Chrome DevTools MCP screenshot handling
- Extract runServerTest() helper to deduplicate testServer/testCommand
- Move MCPTestResult type to common/types/mcp.ts (single source of truth)
- Remove redundant nullish coalescing where getConfig() guarantees non-null
- Net reduction of 29 lines
- Consolidate ProjectSettingsSection state (18 useState → grouped objects + custom hook)
- Extract parseMCPNameCommand helper to dedupe add/edit parsing in registry.ts
- Unify MCP test API (testServer + testCommand → single test endpoint)
- Add localStorage caching for test results with CachedMCPTestResult type
- Show test age in Settings UI (formatRelativeTime)
- Cache successful test results when adding servers
Align with the shadcn refactor that was done on other Settings sections.
Uses Button component with variant='ghost', 'outline', and default
instead of raw button elements with manual styling.
Automatically stops MCP servers after 10 minutes of inactivity to
conserve resources. Servers restart automatically on next message.

This prevents resource exhaustion for users with many workspaces.
@ammar-agent ammar-agent force-pushed the mcp-server-configuration branch from e0abd40 to 015894f Compare December 8, 2025 17:02
@ammario ammario marked this pull request as ready for review December 8, 2025 17:05
Copy link

@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.

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

Tools are now namespaced as `servername_toolname` (e.g., `memory_create_entities`)
to prevent collisions when multiple servers expose tools with the same name.
@ammar-agent ammar-agent force-pushed the mcp-server-configuration branch from ae54abc to ed1de83 Compare December 8, 2025 17:17
Commands may contain credentials or sensitive env values. Only expose
server names to the model, not the full command strings.
@ammar-agent ammar-agent force-pushed the mcp-server-configuration branch from efb452e to b5f287d Compare December 8, 2025 17:19
@ammario ammario merged commit 1996b75 into main Dec 8, 2025
19 checks passed
@ammario ammario deleted the mcp-server-configuration branch December 8, 2025 17:31
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.

2 participants