parch-ops-server
Officialby parchlinux
README.md
<!-- SPDX-License-Identifier: AGPL-3.0-or-later -->
# parch-ops-server
A clean-room, AGPL-3.0-or-later licensed [Model Context Protocol](https://modelcontextprotocol.io/)
server for **Parch Linux** operations, documentation lookup, and package auditing.
The server is written from scratch. It does not copy or translate code from other
MCP servers, and every runtime dependency uses a permissive license.
## Features
- Detects Parch Linux before falling back to generic Arch-family detection.
- Reads Parch Wiki (Wiki.js) content, with an Arch Wiki fallback for upstream topics.
- Searches Parch forum topics and renders Discourse threads as Markdown.
- Queries pacman for packages, pending updates, owners, integrity, and orphans.
- Parses `/etc/pacman.conf`, `/etc/makepkg.conf`, and `/var/log/pacman.log`.
- Reports disk, memory, failed systemd units, and boot errors.
- Probes Parch, Arch, and Chaotic mirrors concurrently and ranks them by latency.
- Searches AUR RPC v5, computes an advisory trust score, and statically audits
PKGBUILDs **without executing them**.
- Uses guarded subprocesses, explicit timeouts, no shell interpolation, and
passwordless-sudo checks.
- Dry-runs all mutations by default. Orphan removal requires `confirm=true`.
## Requirements
- Python 3.11+
- [uv](https://docs.astral.sh/uv/) for the recommended workflow
- A Parch/Arch host for pacman and systemd tools
- Network access for Wiki, forum, AUR, and mirror tools
The knowledge and AUR tools work from any client host. Host tools return a
structured `unsupported_host` error when pacman/systemd are unavailable.
## Install
```bash
cd parch-mcp
uv sync --all-extras
```
`--all-extras` also installs the optional HTTP transport dependencies. To install
only the stdlib/stdio dependencies:
```bash
uv sync
```
## Run over stdio (default)
```bash
uv run parch-ops-server
```
Or, for a client that starts the server itself:
```json
{
"mcpServers": {
"parch-linux": {
"command": "uv",
"args": [
"--directory",
"/home/sohi/parch/experiment/mcp/parch-mcp",
"run",
"parch-ops-server"
]
}
}
}
```
STDIO uses stdout exclusively for JSON-RPC frames. All logging is routed to
stderr. `PARCH_OPS_LOG_LEVEL` controls the log level (`INFO` by default).
## Run over HTTP
The HTTP entry point uses the MCP SDK's Starlette/Uvicorn integration. It is
intended for local or trusted-network use; put an authenticating reverse proxy in
front of it before exposing it remotely.
```bash
# Streamable HTTP at /mcp
uv run parch-ops-server-http
# SSE at /sse with messages at /messages/
PARCH_OPS_HTTP_TRANSPORT=sse uv run parch-ops-server-http
```
Environment variables:
| Variable | Default | Description |
| --- | --- | --- |
| `PARCH_OPS_HTTP_HOST` | `127.0.0.1` | Bind host |
| `PARCH_OPS_HTTP_PORT` | `8000` | Bind port |
| `PARCH_OPS_HTTP_TRANSPORT` | `streamable-http` | `streamable-http` or `sse` |
| `PARCH_OPS_HTTP_PATH` | `/mcp` | Streamable HTTP path |
| `PARCH_OPS_SSE_PATH` | `/sse` | SSE path |
| `PARCH_OPS_SSE_MESSAGE_PATH` | `/messages/` | SSE message path |
| `PARCH_OPS_STATELESS_HTTP` | unset | Set to `1`/`true` for stateless HTTP |
## Tools
| Tool | Purpose | Write? |
| --- | --- | --- |
| `parch_get_distro_info` | Parch variant, tooling, AUR helpers, repositories | No |
| `parch_search_wiki` | Search Parch Wiki, with Arch Wiki fallback | No |
| `parch_get_wiki_page` | Fetch a Parch/Arch wiki page as Markdown | No |
| `parch_search_forum` | Search Parch Discourse topics | No |
| `parch_get_forum_topic` | Fetch a forum thread as Markdown | No |
| `parch_search_packages` | Search sync and installed pacman databases | No |
| `parch_get_package_info` | Structured package metadata | No |
| `parch_check_updates` | Safe pending-update check via `checkupdates` | No |
| `parch_manage_orphans` | List orphans; remove only with `confirm=true` | Yes |
| `parch_verify_package` | Check installed files with `pacman -Qkk` | No |
| `parch_query_file_ownership` | File owner, package file list, or repository owner | No |
| `parch_search_aur` | Search AUR RPC v5 with trust scores | No |
| `parch_audit_pkgbuild` | Static PKGBUILD risk scan | No |
| `parch_diagnose_system` | Disks, memory, failed units, boot errors | No |
| `parch_query_history` | Filtered pacman log history | No |
| `parch_analyze_pacman_conf` | Parse and review pacman/makepkg config | No |
| `parch_test_mirrors` | Concurrent mirror reachability and latency test | No |
Read-only tools carry `readOnlyHint=true`. `parch_manage_orphans` carries
`destructiveHint=true` and returns a dry-run preview unless the caller passes
`confirm=true` **and** passwordless sudo is available.
## Resources
Static resources:
- `pacman://installed`
- `pacman://orphans`
- `pacman://log/recent`
- `system://info`
- `system://services/failed`
- `config://pacman`
- `mirrors://parch`
Templates:
- `parchwiki://{slug}`
- `parchforum://topic/{topic_id}`
- `parchrepo://{package}`
- `aur://{package}/pkgbuild`
## Prompts
- `parch_troubleshoot(symptom)` — evidence-first diagnostics, history, and
documentation search.
- `parch_safe_upgrade` — disk, mirror, forum, config, and update checks before an
upgrade.
- `parch_aur_audit(package)` — metadata, PKGBUILD review, and a build decision.
## Safety model
- Subprocesses use `asyncio.create_subprocess_exec`; no `shell=True`.
- Commands have hard timeouts and process-group cleanup.
- Privileged commands run only when `sudo -n true` succeeds. The server never
waits for interactive password input on a stdio session.
- The PKGBUILD scanner is advisory. It can miss malicious code or flag legitimate
patterns. Always read the full PKGBUILD and its sources before building.
- Mirror and network tools make outbound requests only to configured or
explicitly supplied URLs.
## Tests
```bash
uv run pytest
```
The suite covers distro detection, host guards, pacman parsers, AUR trust scoring
and malicious/benign PKGBUILD fixtures, Wiki/forum clients with `respx`, MCP tool
registration and annotations, resources, prompts, and stderr logging.
## Project layout
```text
src/parch_ops_server/
├── __init__.py # stdio and HTTP entry points
├── server.py # MCPServer instance, tools, resources, prompts
├── http_server.py # SSE / Streamable HTTP runner
├── core/
│ ├── distro.py # Parch/Arch detection
│ ├── exec.py # async subprocess runner and host guards
│ ├── pacman.py # pacman queries, updates, orphans, integrity
│ ├── config.py # pacman.conf and makepkg.conf parsing/analysis
│ ├── logs.py # pacman.log parsing and filtering
│ ├── mirrors.py # mirror file parsing and latency probing
│ └── system.py # system diagnostics, systemd, journal
└── clients/
├── wiki.py # Parch Wiki REST/GraphQL/HTML + Arch Wiki fallback
├── forum.py # Parch Discourse JSON API
└── aur.py # AUR RPC v5, trust scoring, PKGBUILD scanner
```
The Parch Wiki currently exposes a Wiki.js REST API at
`https://wikinext.parchlinux.com/_api`. The client prefers that API, then tries
GraphQL and HTML fallbacks, and finally falls back to the Arch Wiki for generic
upstream topics. Responses always include source metadata so callers can tell
which wiki answered.
## License
Copyright (c) 2026 Parch Linux MCP Contributors.
GNU Affero General Public License v3.0 or later (`AGPL-3.0-or-later`). See
[`LICENSE`](LICENSE).
The AGPL's network-use clause applies: if you run a modified version of this
server and let other users interact with it over a network, you must offer those
users the corresponding source code. Running an unmodified copy is unaffected.
Third-party dependencies remain under their own permissive licenses.
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues