Apt MCP Server
Enables AI agents to install, remove, update, and query apt packages on Linux via MCP tools.
README
Apt MCP Server
A TypeScript-based Model Context Protocol (MCP) server for controlling the apt package manager on Linux. Designed for integration with AI agents (e.g., Cursor, Claude Desktop, Windsurf) and developer tools, it exposes tools for installing, removing, updating, and querying apt packages using the system's native apt and dpkg binaries with sudo privileges.
Features
- Install, remove, update, and query apt packages via MCP tools
- Secure, passwordless
sudoassumed for all operations - Input validation and robust error handling
- Consistent, human-readable output for all tools
- Designed for stdio transport (default for local AI agent integration)
Setup & Installation
- Clone the repository:
git clone <your-repo-url> cd popos-control-mcp - Install dependencies:
npm install - Build the project:
npm run build - Run the server (stdio transport):
npm run dev # or npm start
Note: The server assumes the user has passwordless
sudofor apt operations.
Tools & API Endpoints
All tools are exposed via MCP and can be called by AI agents or clients. Each tool returns a plain text response with a summary, stdout, stderr, and logs (if any).
1. installAptPackage
- Description: Install one or more apt packages.
- Parameters:
packages: array of package names (e.g.,["curl", "git"])
- Example Input:
{ "packages": ["curl"] } - Example Output:
Result: SUCCESS Summary: Apt install succeeded for: curl [stdout] ... [stderr] ...
2. removeAptPackage
- Description: Remove one or more apt packages.
- Parameters:
packages: array of package names
- Example Input:
{ "packages": ["curl"] } - Example Output:
Result: SUCCESS Summary: Apt remove succeeded for: curl [stdout] ... [stderr] ...
3. queryAptPackageStatus
- Description: Query if a package is installed, available, or upgradable.
- Parameters:
package: package name (string)
- Example Input:
{ "package": "curl" } - Example Output:
Result: SUCCESS Summary: Status for package curl: Installed=installed, Upgradable=false, Available=available [stdout] Package: curl Installed: installed Upgradable: no Available: available
4. updateAptPackages
- Description: Update the apt package list and upgrade all packages.
- Parameters: none
- Example Input:
{} - Example Output:
Result: SUCCESS Summary: Apt update and upgrade completed successfully. [stdout] apt update stdout: ... apt upgrade stdout: ... [stderr] ...
5. listUpgradableAptPackages
- Description: List all upgradable apt packages.
- Parameters: none
- Example Input:
{} - Example Output:
Result: SUCCESS Summary: Listed upgradable packages successfully. [stdout] ... [stderr] ...
6. upgradeSpecificAptPackage
- Description: Upgrade a specific apt package.
- Parameters:
package: package name (string)
- Example Input:
{ "package": "curl" } - Example Output:
Result: SUCCESS Summary: Apt only-upgrade succeeded for: curl [stdout] ... [stderr] ...
Example Usage
CLI (stdio transport)
You can test the server using the MCP CLI or by connecting with an AI agent (e.g., Cursor, Claude Desktop).
Node.js Example
const { Client } = require("@modelcontextprotocol/sdk/client");
const { StdioClientTransport } = require("@modelcontextprotocol/sdk/client/stdio");
const client = new Client({ name: "test-client", version: "1.0.0" });
const transport = new StdioClientTransport();
(async () => {
await client.connect(transport);
const result = await client.callTool("installAptPackage", { packages: ["curl"] });
console.log(result);
})();
Error Handling & Troubleshooting
- All errors are returned in a consistent format with
Result: ERRORand a summary. - Common error causes:
- Invalid package name: check spelling and allowed characters
- Package not found: ensure the package exists in your repositories
- Permission denied: ensure passwordless sudo is configured
- Apt lock: the server retries once automatically, but if the error persists, wait and try again
- Example error output:
Result: ERROR Summary: Apt install failed: E: Unable to locate package notarealpackage [stdout] ... [stderr] E: Unable to locate package notarealpackage
FAQ
Q: Does the server require passwordless sudo? A: Yes, all apt/dpkg commands are run with sudo and assume no password prompt.
Q: What transport does the server use? A: Stdio by default, for easy integration with local AI agents and tools.
Q: Can I use this server remotely? A: You can adapt it to use HTTP/SSE transport, but stdio is recommended for local/agent use.
Q: How do I add new tools?
A: Add a new server.addTool block in src/index.ts following the existing pattern.
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。