Design Philosophy
This server embodies the Arch Way principles in its implementation.Minimalism
No unnecessary abstractions or bloat. Every function serves a clear purpose with clean, readable code.
Correctness
Comprehensive error handling at every layer, full type hints, and extensive logging for debugging.
Transparency
Every module is well-documented with clear function signatures, docstrings, and inline comments.
No magic - you can read the source and understand exactly what’s happening.
User-Centricity
Assumes competent users. Provides detailed information and warnings, but doesn’t prevent advanced usage.
AUR warnings inform users of risks but don’t block access - you decide.
Pragmatism
Hybrid local/remote approach: uses fast local queries on Arch, falls back to remote APIs elsewhere.
Simplicity
Standard library and minimal dependencies. No complex frameworks or heavy abstractions.Dependencies: httpx, beautifulsoup4, markdownify, mcp
System Architecture
Module Breakdown
Main Entry Point (__init__.py and server.py)
__init__.py Responsibilities:
- Package initialization
- Function exports
- Async main() entry point
- STDIO transport setup
server.py Responsibilities:
Responsibilities:
- MCP protocol implementation
- Resource URI handling
- Tool invocation routing
- Prompt template management
- STDIO transport setup
- Async operation for all network calls
- URI parsing for resources
- JSON serialization of responses
- Error propagation from modules
HTTP Server Module (http_server.py)
New in v3.1.0: HTTP/SSE transport support for containerized deployments.
Purpose:
- Alternative transport to STDIO for web-based clients
- Server-Sent Events (SSE) for real-time communication
- Containerized deployment support (Docker, Smithery)
- Health check endpoint for monitoring
arch-ops-server- STDIO transport (default)arch-ops-server-http- HTTP/SSE transport
starlette- ASGI framework for HTTP routinguvicorn- ASGI server for productionmcp.server.sse- SSE transport implementation
Tool Metadata System (tool_metadata.py)
New in v3.1.0: Structured tool organization and relationships.
Purpose:
- Categorizes all 41 tools into 9 logical groups
- Defines tool relationships and workflows
- Provides discoverability metadata
- Enables intelligent tool suggestions
category- Logical groupingplatform- “any”, “arch”, or “systemd”permission- “read” or “write”workflow- Usage context (research, installation, cleanup, etc.)related_tools- Tools commonly used togetherprerequisite_tools- Tools to run first
- Auto-suggest related tools to users
- Build guided workflows
- Filter by platform/permission
- Generate documentation
- Analyze tool coverage
Utilities (utils.py)
Core helper functions for platform detection, command execution, and error handling.
All functions use type hints and comprehensive docstrings following Google style.
Arch Wiki Interface (wiki.py)
Manages Arch Wiki searches and page retrieval:
https://wiki.archlinux.org/api.php- Direct page URLs for scraping fallback
- Timeouts (10s default)
- HTTP errors with status codes
- Missing pages (404)
- API errors in response JSON
AUR RPC Interface (aur.py)
Handles AUR package operations and security analysis:
https://aur.archlinux.org/rpchttps://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD
Official Repository Interface (pacman.py)
Hybrid local/remote access to official packages and comprehensive package management:
- On Arch: Fast local queries, offline-capable
- Remote: API-based, works anywhere
System Monitoring (system.py)
System health and diagnostics:
News Integration (news.py)
Arch Linux news feed parsing and analysis:
Transaction Logs (logs.py)
Pacman transaction history analysis:
Mirror Management (mirrors.py)
Repository mirror testing and optimization:
Configuration Parsing (config.py)
System configuration analysis:
Data Flow Examples
Example 1: Reading an Arch Wiki Page
Example 2: Auditing an AUR Package
Error Handling Strategy
Graceful Degradation
Error Response Format
All errors follow consistent structure:NotFound- Resource doesn’t existTimeoutError- Network timeoutHTTPError- HTTP status errorNotSupported- Feature unavailable on platformCommandNotFound- Required command missingRateLimitError- API rate limit exceeded
Concurrency Model
Async/Await Throughout
All network and subprocess operations are async for non-blocking I/O:- Non-blocking I/O
- Concurrent tool calls possible
- Responsive server
- Timeout support built-in
HTTP Client Management
Useshttpx.AsyncClient with context managers:
- Automatic connection pooling
- Timeout enforcement
- Proper cleanup
- HTTP/2 support
Security Considerations
AUR Safety (Defense in Depth)
Multi-layered security approach for AUR package handling.1
Warning Metadata
Every AUR response includes prominent warnings:
Warnings are added automatically by
add_aur_warning() utility function.2
PKGBUILD Analysis
Automated scanning for 50+ threat patterns:
- 🔴 Critical:
rm -rf /, fork bombs, kernel module loading - 🟠 Dangerous:
dd,mkfs, direct/devaccess - 🟡 Suspicious:
curl|sh, eval, base64 pipes
3
Metadata Evaluation
Display community trust indicators:
4
Manual Review Encouragement
Tools facilitate human review:
aur://package/pkgbuild- Easy PKGBUILD access- Formatted, syntax-highlighted display
- Side-by-side with analysis results
5
Official First Policy
Check official repos before AUR:
Command Execution
Only safe read-only commands:pacman -Si- Query package infocheckupdates- Check for updates (no installation)
- Timeout enforcement (default 10s)
- No shell=True (prevents shell injection)
- Whitelist of allowed commands
- Platform checks before execution
Network Safety
- Timeout limits - All requests have timeouts
- HTTPS only - No plaintext HTTP
- Rate limiting - Handle 429 responses
- Input validation - Sanitize user inputs
Performance Optimizations
Caching Strategy
Current: No caching (always live data) Rationale: Rolling release means data changes frequently Future: Consider time-based caching:- Wiki pages: 1 hour
- Package info: 5 minutes
- AUR metadata: 10 minutes
Request Efficiency
- Single API calls - No unnecessary round trips
- Async operations - Concurrent requests possible
- Connection pooling - httpx manages connections
- Timeout limits - Don’t wait forever
Testing Strategy
Functional Tests
Basic tests verify core functionality:- Wiki search and page retrieval
- AUR search and PKGBUILD fetch
- Official package lookup
- Platform detection
Integration Testing
Use MCP Inspector for interactive testing:Manual Testing Checklist
- Resources work on both Arch and non-Arch
- Tools return proper error responses
- Prompts guide users through workflows
- AUR warnings always present
- Timeouts enforced
- Logging goes to stderr
Extension Points
Adding New Tools
- Create async function in appropriate module
- Export from
__init__.py - Add
@server.tool()decorator in main file - Update
list_tools()with schema - Add handler in
call_tool() - Document in README and examples
Adding New Resources
- Define URI scheme
- Add parsing in
read_resource() - Implement fetch logic in module
- Add example to
list_resources() - Document usage
Adding New Prompts
- Design workflow
- Add
@server.prompt()decorator - Implement in
get_prompt() - Add to
list_prompts() - Create example in documentation
Future Enhancements
Planned Features
- Caching layer for performance
- Arch News integration
- Package dependency tree analysis
- Security advisory integration (arch-audit)
- Local pacman.conf parsing
- File list queries for packages
- Systemd unit analysis
- Custom repository support
Potential Improvements
- Metrics collection (response times, error rates)
- More sophisticated PKGBUILD analysis
- Wiki page diff tracking
- AUR package popularity trends
- Integration with Arch forums
- Batch operations support
Contributing
Want to contribute? See the Contributing Guide for:- Development setup and testing
- Code standards and best practices
- Pull request process
- Feature contribution guidelines
References
Built with ❤️ following the Arch Way.