🌐 Connecting MCP Server to Local Scripts – Offline Power! 💻🔗

May 20, 2025 (2d ago)
👁️ ... views

අද අපේ topic එක offline automation ගැන. Internet නැති වෙලාවටත් ඔයාගේ scripts run වෙන system එකක් තියෙන්න ඕනේනෙ? ඒකට තමයි MCP (Minimal Command Processing) Server + Local Scripts combo එක.


🔍 MCP Server කියන්නෙ මොකද්ද?

MCP Server කියන්නෙ lightweight offline command-processing server එකක්. ඔයාට CLI commands, Python/Bash scripts run කරන්න පුළුවන් – without needing the internet!

MCP = "Minimal Command Processor"
ඔයාගේ system එකට offline brain එකක් වගේ!


🛠️ MCP Setup එක – Local Machine එකේ

  1. Install Python (මොකද්ද MCP backend එක mostly Python)

  2. Create a project folder:

   mkdir my-mcp-server && cd my-mcp-server
  1. Add MCP base script: mcp.py
   import os  
   import subprocess  
 
   def run_command(cmd):  
       try:  
           output = subprocess.check_output(cmd, shell=True, stderr=subprocess.STDOUT)  
           return output.decode()  
       except subprocess.CalledProcessError as e:  
           return e.output.decode()  
 
   while True:  
       command = input("MCP> ")  
       if command.lower() in ['exit', 'quit']:  
           break  
       print(run_command(command))
  1. Run it:
   python mcp.py

🧠 දැන් ඔයාට local scripts, system tasks, custom tools CLI එකෙන් run කරන්න පුළුවන්!


🧪 Connect MCP to Your Local Scripts

උදාහරණයක්: Let's say you have a custom script called generate_report.py.

🔗 Add a command shortcut in commands.txt or map manually in mcp.py like:

   if command == "report":  
       os.system("python generate_report.py")

➡️ දැන් report කියලා MCP> CLI එකේ ලියන්න පුළුවන්.


🚀 Use Cases (Offline Power! 💪)


🔐 Bonus Tip – Secure Your MCP


🧠 Final Thoughts

Offline tools are underrated. MCP + your own scripts කියන්නේ pure freedom. Internet නැති වෙලාවටත් smart automation, powerful utilities, and offline AI workflows run කරන්න පුළුවන්.


🔥 ඔබට මේ system එකට GUI එකක් හදන හැටි දැනගන්න ඕනෙද? නැත්තං Discord CLI MCP bot එකක්?


Stay Offline, Stay Powerful. 💻🧠