Skip to main content
Glama
README.md
# Spectre MCP

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
[![Python 3.12+](https://img.shields.io/badge/python-3.12%2B-blue.svg)](pyproject.toml)
[![Tests](https://img.shields.io/badge/tests-26%20passing-brightgreen.svg)](#testing)

Spectre MCP is a **read-only infrastructure operations MCP server** for AI assistants. It gives models a secure, structured way to inspect and diagnose Linux hosts, Docker, systemd services, security posture, and backups.

## Table of contents

- [Features](#features)
- [Security model](#security-model)
- [Installation](#installation)
- [Configuration](#configuration)
- [Running the server](#running-the-server)
- [OpenCode configuration](#opencode-configuration)
- [Docker deployment](#docker-deployment)
- [Testing](#testing)
- [Project structure](#project-structure)
- [Limitations](#limitations)
- [Contributing](#contributing)
- [License](#license)

## Features

- **Host**: CPU, memory, load, uptime, disk usage, inode exhaustion, OS/kernel info, network interfaces
- **Docker**: daemon health, container inventory, health/restart counts, inspection, bounded logs, images, volumes
- **Services**: systemd status, journal search, failure diagnostics
- **Security**: listening ports, firewall status, SSH audit, TLS certificate expiry, baseline checks
- **Backups**: status, age, destination verification, Restic repository status
- **Diagnostics**: `incident_diagnose`, `security_baseline`, `backup_audit`, `infrastructure_report`

## Security model

- Read-only by default — no write or remediation operations
- No unrestricted shell execution or arbitrary Python evaluation
- Allowlisted commands with validated, non-shell parameters
- Secret redaction (passwords, tokens, API keys, common patterns)
- Path traversal prevention and safe filesystem access
- Command timeouts and bounded output
- Audit logging of every tool invocation
- Permission architecture ready for future controlled remediation

## Installation

```bash
git clone https://github.com/bigwalkdoe/spectre-mcp.git
cd spectre-mcp
python -m venv .venv
source .venv/bin/activate
pip install -e .
```

Copy the example environment file and adjust:

```bash
cp .env.example .env
```

## Configuration

All settings are environment-based (prefix `SPECTRE_`):

| Variable | Default | Description |
|---|---|---|
| `SPECTRE_READ_ONLY_MODE` | `true` | Enforce read-only operation |
| `SPECTRE_ALLOWED_DOCKER_RESOURCES` | _(empty)_ | Comma-separated allowlist |
| `SPECTRE_ALLOWED_SYSTEMD_SERVICES` | _(empty)_ | Comma-separated allowlist |
| `SPECTRE_MAX_LOG_OUTPUT_BYTES` | `65536` | Output truncation limit |
| `SPECTRE_COMMAND_TIMEOUT_SECONDS` | `15` | Subprocess timeout |
| `SPECTRE_AUDIT_LOG_PATH` | `~/.spectre/audit.log` | Audit log location |
| `SPECTRE_LOG_LEVEL` | `INFO` | Logging level |
| `SPECTRE_RESTIC_REPOSITORY` | _(empty)_ | Restic repository path |
| `SPECTRE_BACKUP_DIRECTORIES` | _(empty)_ | Comma-separated backup paths |
| `SPECTRE_TLS_CERT_PATHS` | _(empty)_ | Comma-separated certificate paths |

## Running the server

```bash
spectre-mcp
```

The server uses **stdio transport** and exposes **no network port**.

## OpenCode configuration

```json
{
  "mcp": {
    "spectre-mcp": {
      "type": "local",
      "command": ["spectre-mcp"],
      "environment": {
        "SPECTRE_READ_ONLY_MODE": "true"
      },
      "enabled": true
    }
  }
}
```

## Docker deployment

Build:

```bash
docker build -t spectre-mcp .
```

Run over stdio:

```bash
docker run -i --rm spectre-mcp
```

`docker-compose.yml` provides a default no-port deployment. Docker socket and host filesystem mounts are **not** enabled by default — document and enable them only in trusted environments.

## Testing

```bash
pytest
python scripts/smoke_test.py
```

Lint and type check:

```bash
ruff check .
mypy spectre_mcp
```

## Project structure

```
spectre_mcp/
├── server.py
├── config.py
├── security/
├── tools/
├── integrations/
├── models/
└── audit/
```

## Limitations

- Read-only MVP; remediation is not implemented
- Some integrations require system utilities and permissions
- Host metrics inside containers reflect the container unless host `/proc` is mounted

## Contributing

Contributions are welcome. Please run tests, linting, and type checks before submitting a pull request.

## License

Released under the [MIT License](LICENSE).

TDQS

B3/5.0

Scored across 26 tools

Disambiguation3/5

Most tools target a distinct resource (host, docker, systemd, backup), but there is real overlap between aggregate tools (incident_diagnose, infrastructure_report, backup_audit, security_baseline) and the granular tools that feed them, so an agent may pick the summary tool when a specific probe was intended. The backup family is especially dense (backup_status, backup_age, backup_audit, backup_destination_verification, restic_status), with status vs. age being a subtle distinction.

Naming Consistency4/5

All names are snake_case noun/verb phrases with a predictable domain prefix (host_*, docker_*, service_*, backup_*). A few tools drop the prefix convention (listening_ports, firewall_status, tls_cert_expiry, journal_search), which is a minor inconsistency but still readable and unambiguous.

Tool Count3/5

At 26 tools the surface is just over the heavy threshold, and the backup/security area carries several closely related variants that could be consolidated. The count is defensible for broad infrastructure observability, but it sits at the upper edge of what stays easy to navigate.

Completeness4/5

Coverage is strong for a read-only diagnostic server: host resources, Docker objects and logs, systemd/journal, network, firewall/SSH/TLS security, backups, and roll-up reports. Gaps remain around process-level inspection (top processes, open files), user/account and package/patch auditing, and non-journal log sources, but these are workable omissions.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues