User Guide
Table of Contents
Installation
Prerequisites
- Node.js 18.0.0 or higher
- npm or yarn
Install via NPM
Install from Source
git clone https://github.com/guangda/ling-term-mcp.git
cd ling-term-mcp
npm install
npm run build
npm link
Quick Start
1. Verify Installation
Expected output: 1.1.0
2. Start the Server
The server will start and wait for MCP client connections via stdio.
Connecting to AI Assistants
Cursor
- Open Cursor Settings (
Cmd+,orCtrl+,) - Navigate to "MCP Servers" section
- Add the following configuration:
- Restart Cursor
Claude Desktop
- Open Claude Desktop Settings
- Navigate to "MCP Servers" section
- Add the following configuration:
- Restart Claude Desktop
Other MCP Clients
Any MCP-compatible client can connect to Ling-term-mcp. The server uses stdio transport, which is the most common and recommended method.
Using the Tools
Execute Commands
Ask your AI assistant to execute terminal commands:
The AI assistant will use the execute_command tool to run ls -la.
Manage Sessions
The AI assistant will use the create_session tool.
The AI assistant will use the list_sessions tool.
Sync Terminal State
The AI assistant will use the sync_terminal tool.
Audit and Decision Tracking
Decision Provenance
Ling-term-mcp automatically tracks all command decisions with:
- Decision Records: Each command execution is logged with reasoning, expected outcomes, and actual results
- Source Traces: Tracks the origin and confidence level of each decision
- Behavioral Violations: Detects dangerous patterns like reading sensitive files followed by network commands
Behavioral Contracts
The system enforces behavioral rules to prevent malicious patterns:
- Network After Sensitive Read: Warns if network commands follow reading sensitive files within 5 minutes
- Rapid Command Burst: Alerts when too many commands are executed in a short time window
- Permission Change After Write: Flags suspicious permission modifications
Session Snapshots
When a session is destroyed, a comprehensive snapshot is generated including:
- Commands executed and their outcomes
- Files read and written
- Network commands issued
- Behavioral violations detected
- Duration and activity statistics
Metacognitive Audits
The system evaluates AI decision-making quality:
- Reasoning Specificity: Measures how detailed and specific reasoning is
- Reasoning Consistency: Tracks consistency across decisions
- Outcome Alignment: Compares expected vs actual outcomes
- Temporal Variation: Monitors reasoning pattern changes over time
Audit data is stored in .ling-term-mcp/sessions.json in the working directory.
Configuration
Environment Variables
LING_TERM_MCP_LOG_LEVEL: Logging level (debug, info, warn, error)LING_TERM_MCP_MAX_CONNECTIONS: Maximum concurrent connections (default: 100)LING_TERM_MCP_TIMEOUT: Command timeout in seconds (default: 60)
Configuration File
Create a .ling-term-mcp.json file in your home directory:
Troubleshooting
Server won't start
Problem: command not found: ling-term-mcp
Solution: Make sure you've installed the package globally or linked it:
Commands fail to execute
Problem: Tool returns error messages
Solution:
- Check if the command exists on your system
- Verify you have the necessary permissions
- Check the error message for specific details
Session not found
Problem: "Session not found: xxx-xxx-xxx"
Solution:
- Use
list_sessionsto see available sessions - Create a new session if needed
Permission denied
Problem: "Permission denied" when executing commands
Solution:
- Check file permissions
- Run the server with appropriate user privileges
- Avoid commands requiring
sudo
Connection issues with AI Assistant
Problem: AI assistant can't connect to the MCP server
Solution:
- Verify the server is running
- Check the command path in the configuration
- Restart the AI assistant
- Check AI assistant logs for connection errors
Getting Help
Ling-term-mcp (灵犀) - 心有灵犀一点通,AI 精准操控终端 🚀