kien-ht/local-master-mcp-server
If you are the rightful owner of local-master-mcp-server and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.
The Local Master MCP Server facilitates seamless communication between Claude Code terminals using dynamic terminal naming and tmux integration.
Local Master MCP Server
A Model Context Protocol (MCP) server that enables seamless communication between Claude Code terminals with dynamic terminal naming and automatic tmux integration for message delivery.
šÆ Overview
The Local Master MCP Server provides inter-terminal communication capabilities for Claude Code instances running in different project directories. It uses Server-Sent Events (SSE) for real-time communication and integrates with tmux for automatic message delivery to idle terminals.
⨠Features
- Dynamic Terminal Names: Create and use any terminal name without configuration
- Inter-Terminal Messaging: Send messages between any dynamically named terminals
- Terminal State Management: Track idle/busy states for each terminal
- Automatic Message Delivery: Inject messages directly into tmux sessions when terminals are idle
- Persistent Storage: Messages are stored in the filesystem and survive server restarts
- Unread Message Tracking: Keep track of read/unread messages for each terminal
- MCP Tool Integration: Full set of MCP tools available in Claude Code
- Auto-Registration: Terminals are registered automatically on first use
š Quick Start
1. Installation
# Clone the repository
git clone <repository-url>
cd local-master-mcp-server
# Run the setup script
./setup.sh
The setup script will:
- Check and install Node.js dependencies
- Install tmux if not present
- Create necessary data directories
- Configure MCP in Claude Code (using
claude mcp add -t sse
) - Make scripts executable
Manual MCP Configuration: If the setup script fails to add the MCP server, run:
claude mcp add -t sse local-master http://127.0.0.1:5476/sse
2. Start the Server
# Start the MCP server
pnpm start
# Or for development with inspector
pnpm dev
The server will run on http://127.0.0.1:5476
3. Start Claude in Tmux Sessions
The setup script installs a global start-claude
command. Use it to start Claude in tmux sessions:
# Use any terminal name you want
start-claude backend
start-claude frontend
start-claude api-server
start-claude mobile-app
start-claude worker
This will create tmux sessions named claude-[terminal-name]
with Claude Code running inside.
4. Configure Projects
Copy the instructions file to each project and set the terminal type:
# Copy to any project and set your terminal name
cp terminal-communication-mcp-instructions.md /path/to/project/
# Edit the file and set CURRENT_TERMINAL to your desired name
# Examples: backend, frontend, api-server, mobile-app, worker, etc.
š Available MCP Tools
Once configured, the following tools are available in Claude Code:
1. mcp__local-master__send_message
Send a message from one terminal to another.
- Parameters:
from
,to
,message
- Example: "Send a message to frontend that the API is ready"
2. mcp__local-master__get_oldest_unread_message
Get the oldest (first) unread message for a terminal.
- Parameters:
terminal
- Example: "Check the next message for backend"
- Note: More efficient for checking messages one at a time
3. mcp__local-master__get_unread_messages
Retrieve all unread messages for a terminal.
- Parameters:
terminal
- Example: "Show me all unread messages for backend"
4. mcp__local-master__mark_message_read
Mark a specific message as read.
- Parameters:
terminal
,messageId
- Example: "Mark message abc123 as read for backend"
5. mcp__local-master__set_terminal_state
Set the state of a terminal (idle or busy).
- Parameters:
terminal
,state
- Example: "Set backend terminal to idle"
- Note: When set to idle, any pending messages will be delivered automatically via tmux
6. mcp__local-master__list_terminals
List all registered terminals in the system.
- Parameters: None
- Example: "Show me all available terminals"
- Note: Terminals are registered automatically when they send or receive their first message
š File Structure
local-master-mcp-server/
āāā src/
ā āāā index.ts # Main entry point
ā āāā mcp-server.ts # MCP server implementation
ā āāā sse-server.ts # SSE server setup
ā āāā storage.ts # File-based storage manager
āāā data/ # Message storage (auto-created)
ā āāā [terminal-name]/ # Dynamically created for each terminal
ā āāā unread/ # Unread messages
ā āāā read/ # Read messages
āāā wrapper.sh # Tmux message injection script
āāā setup.sh # Installation and setup script
āāā mcp-config-template.json # MCP configuration template
āāā terminal-communication-mcp-instructions.md # Instructions for projects
āāā package.json # Node.js dependencies
āāā tsconfig.json # TypeScript configuration
āāā README.md # This file
š¬ Usage Examples
In Backend Terminal
# Claude Code command examples:
"Send a message to frontend that the user API now includes avatar field"
"Tell mobile-app the websocket server is ready on port 3001"
"Check if I have any unread messages"
"Set my status to busy while I refactor the database"
In Frontend Terminal
# Claude Code command examples:
"Notify backend that we need pagination for products endpoint"
"Ask mobile-app about offline sync requirements"
"Show me all unread messages"
"Set this terminal to idle"
In Mobile Terminal
# Claude Code command examples:
"Tell backend about the new push notification requirements"
"Let frontend know we need smaller image sizes"
"Check the status of all terminals"
"Mark all my messages as read"
With Custom Terminal Names
# In api-server terminal:
"Tell database-worker that the migration is complete"
"Notify auth-service about the new token format"
# In monitoring terminal:
"Tell all terminals about the scheduled maintenance"
"List all available terminals"
š§ Message Flow
- Sending: Terminal A uses
send_message
tool ā Message stored in filesystem - Storage: Messages saved in
data/{terminal}/unread/[date]-messages.json
- Delivery: If target terminal is idle ā Message injected via tmux
- Reading: Terminal B uses
get_unread_messages
to retrieve messages - Archiving:
mark_message_read
moves messages to read folder
šØ Terminal States
idle
: Terminal is ready to receive messages (auto-delivery enabled)busy
: Terminal is working (messages queued for later)
When a terminal switches from busy
to idle
, any pending messages are automatically delivered.
š·ļø Dynamic Terminal Names
The system supports any terminal name without pre-configuration. Terminal names can include:
- Letters (a-z, A-Z)
- Numbers (0-9)
- Hyphens (-)
- Underscores (_)
Examples of valid terminal names:
backend
,frontend
,mobile
api-server
,web-app
,mobile-app
auth-service
,database-worker
,cache-manager
dev-1
,staging-2
,prod-3
Terminals are automatically registered when they:
- Send their first message
- Receive their first message
- Set their state for the first time
š ļø Troubleshooting
MCP Tools Not Appearing in Claude Code
- Ensure server is running:
pnpm dev
orpnpm start
- Check the MCP was added correctly:
claude mcp list
- If not listed, add it manually:
claude mcp add -t sse local-master http://127.0.0.1:5476/sse
- Restart Claude Code after configuration changes
- Tools should appear with prefix
mcp__local-master__
Messages Not Appearing in Tmux
- Check tmux session exists:
tmux ls
- Verify terminal is set to
idle
state - Ensure wrapper.sh has execute permissions:
chmod +x wrapper.sh
Server Connection Issues
- Check port 5476 is not in use:
lsof -i :5476
- Verify Node.js is installed:
node -v
- Check logs for errors when starting server
š Development
Running in Development Mode
pnpm dev
Building for Production
pnpm build
pnpm start
Running Tests
pnpm test
š Security Notes
- Server runs locally on 127.0.0.1 (localhost only)
- No authentication required for local development
- Messages stored in plain text in local filesystem
- Not intended for production or sensitive data
š License
MIT
š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
š Support
For issues or questions, please open an issue on GitHub or contact the maintainers.
Made with ā¤ļø for seamless Claude Code terminal communication