llama-mcp-bridge 1.0.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- llama_mcp_bridge-1.0.4/.github/ISSUE_TEMPLATE/bug_report.yml +39 -0
- llama_mcp_bridge-1.0.4/.github/ISSUE_TEMPLATE/feature_request.yml +24 -0
- llama_mcp_bridge-1.0.4/.github/PULL_REQUEST_TEMPLATE.md +10 -0
- llama_mcp_bridge-1.0.4/.github/workflows/ci.yml +78 -0
- llama_mcp_bridge-1.0.4/.github/workflows/release.yml +67 -0
- llama_mcp_bridge-1.0.4/.gitignore +29 -0
- llama_mcp_bridge-1.0.4/.pre-commit-config.yaml +14 -0
- llama_mcp_bridge-1.0.4/AGENTS.md +36 -0
- llama_mcp_bridge-1.0.4/ARCHITECTURE.md +73 -0
- llama_mcp_bridge-1.0.4/CHANGELOG.md +8 -0
- llama_mcp_bridge-1.0.4/CODE_OF_CONDUCT.md +39 -0
- llama_mcp_bridge-1.0.4/CONTRIBUTING.md +49 -0
- llama_mcp_bridge-1.0.4/LICENSE +21 -0
- llama_mcp_bridge-1.0.4/Makefile +18 -0
- llama_mcp_bridge-1.0.4/PKG-INFO +188 -0
- llama_mcp_bridge-1.0.4/README.md +161 -0
- llama_mcp_bridge-1.0.4/ROADMAP.md +14 -0
- llama_mcp_bridge-1.0.4/SECURITY.md +35 -0
- llama_mcp_bridge-1.0.4/SHIPPED.md +83 -0
- llama_mcp_bridge-1.0.4/STABILITY.md +28 -0
- llama_mcp_bridge-1.0.4/TRACKER.md +280 -0
- llama_mcp_bridge-1.0.4/bridge.example.ini +24 -0
- llama_mcp_bridge-1.0.4/docs/advanced.md +38 -0
- llama_mcp_bridge-1.0.4/docs/cli.md +47 -0
- llama_mcp_bridge-1.0.4/docs/config.md +35 -0
- llama_mcp_bridge-1.0.4/docs/enterprise.md +12 -0
- llama_mcp_bridge-1.0.4/docs/failure-classification.md +22 -0
- llama_mcp_bridge-1.0.4/docs/gguf-auto-tuning.md +20 -0
- llama_mcp_bridge-1.0.4/docs/index.md +16 -0
- llama_mcp_bridge-1.0.4/docs/install-bsd.md +29 -0
- llama_mcp_bridge-1.0.4/docs/install-wheel.md +20 -0
- llama_mcp_bridge-1.0.4/docs/install.md +40 -0
- llama_mcp_bridge-1.0.4/docs/models.md +47 -0
- llama_mcp_bridge-1.0.4/docs/reasoning-management.md +23 -0
- llama_mcp_bridge-1.0.4/docs/services.md +14 -0
- llama_mcp_bridge-1.0.4/docs/tools.md +34 -0
- llama_mcp_bridge-1.0.4/docs/troubleshooting.md +21 -0
- llama_mcp_bridge-1.0.4/pyproject.toml +62 -0
- llama_mcp_bridge-1.0.4/server.json +21 -0
- llama_mcp_bridge-1.0.4/skills/llama-mcp-setup/SKILL.md +86 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/__init__.py +3 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/bridge.py +1093 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/client_config.py +201 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/config.py +247 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/config_cli.py +108 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/diagnostics.py +243 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/discovery.py +365 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/enterprise/__init__.py +7 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/enterprise/audit.py +79 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/enterprise/probes.py +63 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/enterprise/tenant.py +73 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/gguf_header.py +313 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/hardware.py +242 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/http_resilience.py +154 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/hygiene.py +438 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/installer.py +870 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/logging_utils.py +74 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/metrics.py +155 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/model_download.py +169 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/models_cli.py +453 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/ollama_import.py +208 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/paths.py +155 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/presets.py +820 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/py.typed +0 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/service_install.py +702 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/signing.py +101 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/skill_install.py +115 -0
- llama_mcp_bridge-1.0.4/src/llama_mcp_bridge/supervisor.py +592 -0
- llama_mcp_bridge-1.0.4/tests/conftest.py +17 -0
- llama_mcp_bridge-1.0.4/tests/test_bridge_tools.py +199 -0
- llama_mcp_bridge-1.0.4/tests/test_cross_platform.py +1567 -0
- llama_mcp_bridge-1.0.4/tests/test_discovery.py +58 -0
- llama_mcp_bridge-1.0.4/tests/test_enterprise.py +73 -0
- llama_mcp_bridge-1.0.4/tests/test_file_discovery.py +94 -0
- llama_mcp_bridge-1.0.4/tests/test_gguf_header.py +229 -0
- llama_mcp_bridge-1.0.4/tests/test_hardware_tiers.py +165 -0
- llama_mcp_bridge-1.0.4/tests/test_hygiene.py +120 -0
- llama_mcp_bridge-1.0.4/tests/test_model_download.py +118 -0
- llama_mcp_bridge-1.0.4/tests/test_presets.py +183 -0
- llama_mcp_bridge-1.0.4/tests/test_skill_install.py +76 -0
- llama_mcp_bridge-1.0.4/tests/test_supervisor_spawn_args.py +237 -0
- llama_mcp_bridge-1.0.4/tests/test_v010_features.py +388 -0
- llama_mcp_bridge-1.0.4/tests/test_v011_features.py +338 -0
- llama_mcp_bridge-1.0.4/tests/test_v012_features.py +307 -0
- llama_mcp_bridge-1.0.4/tests/test_v013_core_hardening.py +193 -0
- llama_mcp_bridge-1.0.4/tests/test_v014_enterprise_extra.py +158 -0
- llama_mcp_bridge-1.0.4/tests/test_v090_hardening.py +226 -0
- llama_mcp_bridge-1.0.4/uv.lock +2016 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
name: Bug Report
|
|
2
|
+
description: Report a bug or unexpected behaviour in llama-mcp-bridge
|
|
3
|
+
title: "[Bug]: "
|
|
4
|
+
labels: ["bug"]
|
|
5
|
+
body:
|
|
6
|
+
- type: textarea
|
|
7
|
+
id: description
|
|
8
|
+
attributes:
|
|
9
|
+
label: What happened?
|
|
10
|
+
description: A clear and concise description of the bug.
|
|
11
|
+
validations:
|
|
12
|
+
required: true
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: reproduce
|
|
15
|
+
attributes:
|
|
16
|
+
label: Steps to reproduce
|
|
17
|
+
description: Commands run, flags passed, or MCP tool invocation that triggered the issue.
|
|
18
|
+
placeholder: |
|
|
19
|
+
1. Run `llama-mcp-install --doctor`
|
|
20
|
+
2. ...
|
|
21
|
+
validations:
|
|
22
|
+
required: true
|
|
23
|
+
- type: textarea
|
|
24
|
+
id: environment
|
|
25
|
+
attributes:
|
|
26
|
+
label: Environment
|
|
27
|
+
description: OS, GPU/VRAM, Python version, and `llama-mcp-install --version` output.
|
|
28
|
+
placeholder: |
|
|
29
|
+
- OS: Linux / macOS / Windows / FreeBSD
|
|
30
|
+
- GPU: e.g. NVIDIA RTX 3070 (8 GB) / Apple M2 / CPU
|
|
31
|
+
- Version: `llama-mcp-install --version`
|
|
32
|
+
validations:
|
|
33
|
+
required: true
|
|
34
|
+
- type: textarea
|
|
35
|
+
id: doctor_output
|
|
36
|
+
attributes:
|
|
37
|
+
label: "`llama-mcp-install --doctor` output"
|
|
38
|
+
description: Paste the output of `llama-mcp-install --doctor` (or `--doctor --json`) if applicable.
|
|
39
|
+
render: text
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
name: Feature Request
|
|
2
|
+
description: Suggest a new feature or enhancement for llama-mcp-bridge
|
|
3
|
+
title: "[Feature]: "
|
|
4
|
+
labels: ["enhancement"]
|
|
5
|
+
body:
|
|
6
|
+
- type: textarea
|
|
7
|
+
id: problem
|
|
8
|
+
attributes:
|
|
9
|
+
label: Problem or use case
|
|
10
|
+
description: Describe the workflow gap or problem this feature would solve.
|
|
11
|
+
validations:
|
|
12
|
+
required: true
|
|
13
|
+
- type: textarea
|
|
14
|
+
id: proposal
|
|
15
|
+
attributes:
|
|
16
|
+
label: Proposed solution
|
|
17
|
+
description: Describe the CLI flag, MCP tool, or configuration behaviour you have in mind.
|
|
18
|
+
validations:
|
|
19
|
+
required: true
|
|
20
|
+
- type: textarea
|
|
21
|
+
id: alternatives
|
|
22
|
+
attributes:
|
|
23
|
+
label: Alternatives considered
|
|
24
|
+
description: Any workarounds or alternative designs you considered.
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
## Summary
|
|
2
|
+
|
|
3
|
+
Describe the changes in this pull request and link any relevant issue or `TRACKER.md` item.
|
|
4
|
+
|
|
5
|
+
## Verification
|
|
6
|
+
|
|
7
|
+
- [ ] `uv run ruff check .` passes with zero errors
|
|
8
|
+
- [ ] `uv run mypy src` passes with zero errors
|
|
9
|
+
- [ ] `uv run pytest -v` passes with zero failures
|
|
10
|
+
- [ ] Updated `README.md`, `TRACKER.md`, or `docs/` if CLI/config behaviour changed
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main ]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
build:
|
|
11
|
+
runs-on: ${{ matrix.os }}
|
|
12
|
+
strategy:
|
|
13
|
+
fail-fast: false
|
|
14
|
+
matrix:
|
|
15
|
+
os: [ubuntu-latest, macos-latest, windows-latest]
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout code
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Setup UV
|
|
22
|
+
uses: astral-sh/setup-uv@v5
|
|
23
|
+
|
|
24
|
+
- name: Sync UV
|
|
25
|
+
run: uv sync --dev
|
|
26
|
+
|
|
27
|
+
- name: Run ruff check
|
|
28
|
+
run: make lint
|
|
29
|
+
|
|
30
|
+
- name: Run pytest
|
|
31
|
+
run: make test
|
|
32
|
+
|
|
33
|
+
- name: Run llama-mcp-install dry-run
|
|
34
|
+
run: uv run llama-mcp-install --dry-run
|
|
35
|
+
|
|
36
|
+
typecheck:
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
steps:
|
|
39
|
+
- name: Checkout code
|
|
40
|
+
uses: actions/checkout@v4
|
|
41
|
+
|
|
42
|
+
- name: Setup UV
|
|
43
|
+
uses: astral-sh/setup-uv@v5
|
|
44
|
+
|
|
45
|
+
- name: Sync UV
|
|
46
|
+
run: uv sync --dev
|
|
47
|
+
|
|
48
|
+
- name: Run mypy
|
|
49
|
+
run: make typecheck
|
|
50
|
+
|
|
51
|
+
freebsd:
|
|
52
|
+
runs-on: ubuntu-latest
|
|
53
|
+
steps:
|
|
54
|
+
- name: Checkout code
|
|
55
|
+
uses: actions/checkout@v4
|
|
56
|
+
|
|
57
|
+
- name: Run tests in FreeBSD VM
|
|
58
|
+
uses: vmactions/freebsd-vm@v1
|
|
59
|
+
with:
|
|
60
|
+
usesh: true
|
|
61
|
+
cache-after-prepare: true
|
|
62
|
+
# Note: cache-after-prepare keys on the VM image and prepare script text rather than pyproject.toml;
|
|
63
|
+
# clear the FreeBSD Actions cache (or bump a comment here) when adding new dependencies.
|
|
64
|
+
prepare: |
|
|
65
|
+
pkg install -y python312 uv rust \
|
|
66
|
+
py312-pydantic2 py312-pydantic-core py312-cryptography \
|
|
67
|
+
py312-rpds-py py312-pyyaml py312-cffi py312-pytest \
|
|
68
|
+
py312-requests py312-rich py312-pathspec py312-anyio \
|
|
69
|
+
py312-httpx py312-jsonschema py312-starlette py312-uvicorn \
|
|
70
|
+
py312-platformdirs py312-python-dotenv
|
|
71
|
+
export PATH="$HOME/.local/bin:/usr/local/bin:$PATH"
|
|
72
|
+
uv pip install --system --break-system-packages -e .
|
|
73
|
+
run: |
|
|
74
|
+
export PATH="$HOME/.local/bin:/usr/local/bin:$PATH"
|
|
75
|
+
pytest -v
|
|
76
|
+
if command -v llama-server >/dev/null 2>&1; then llama-mcp-install --selftest || true; fi
|
|
77
|
+
llama-mcp-install --dry-run
|
|
78
|
+
llama-mcp-install --install-service --dry-run
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
tags:
|
|
6
|
+
- 'v*'
|
|
7
|
+
|
|
8
|
+
permissions:
|
|
9
|
+
contents: write
|
|
10
|
+
id-token: write
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout code
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Setup UV
|
|
20
|
+
uses: astral-sh/setup-uv@v5
|
|
21
|
+
|
|
22
|
+
- name: Build wheel and sdist
|
|
23
|
+
run: uv build
|
|
24
|
+
|
|
25
|
+
- name: Generate CycloneDX SBOM
|
|
26
|
+
run: uv export --frozen --no-dev --format cyclonedx1.5 --no-emit-project -o dist/sbom.cdx.json
|
|
27
|
+
|
|
28
|
+
- name: Sign release artifacts with Sigstore
|
|
29
|
+
uses: sigstore/gh-action-sigstore-python@v3.0.0
|
|
30
|
+
with:
|
|
31
|
+
inputs: >-
|
|
32
|
+
dist/*.whl
|
|
33
|
+
dist/*.tar.gz
|
|
34
|
+
dist/sbom.cdx.json
|
|
35
|
+
|
|
36
|
+
- name: Publish GitHub Release
|
|
37
|
+
uses: softprops/action-gh-release@v2
|
|
38
|
+
with:
|
|
39
|
+
files: dist/*
|
|
40
|
+
generate_release_notes: true
|
|
41
|
+
|
|
42
|
+
- name: Upload dist artifact
|
|
43
|
+
uses: actions/upload-artifact@v4
|
|
44
|
+
with:
|
|
45
|
+
name: dist
|
|
46
|
+
path: |
|
|
47
|
+
dist/*.whl
|
|
48
|
+
dist/*.tar.gz
|
|
49
|
+
|
|
50
|
+
publish-pypi:
|
|
51
|
+
runs-on: ubuntu-latest
|
|
52
|
+
needs: release
|
|
53
|
+
environment: pypi
|
|
54
|
+
permissions:
|
|
55
|
+
id-token: write
|
|
56
|
+
steps:
|
|
57
|
+
- name: Download dist artifact
|
|
58
|
+
uses: actions/download-artifact@v4
|
|
59
|
+
with:
|
|
60
|
+
name: dist
|
|
61
|
+
path: dist/
|
|
62
|
+
|
|
63
|
+
- name: Set up uv
|
|
64
|
+
uses: astral-sh/setup-uv@v5
|
|
65
|
+
|
|
66
|
+
- name: Publish to PyPI via Trusted Publishing
|
|
67
|
+
run: uv publish --trusted-publishing always
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# Python & uv
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.egg-info/
|
|
6
|
+
dist/
|
|
7
|
+
build/
|
|
8
|
+
.eggs/
|
|
9
|
+
.venv/
|
|
10
|
+
.uv/
|
|
11
|
+
.pytest_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
htmlcov/
|
|
16
|
+
|
|
17
|
+
# Local runtime & user config
|
|
18
|
+
bridge.ini
|
|
19
|
+
models.ini
|
|
20
|
+
*.gguf
|
|
21
|
+
*.bin
|
|
22
|
+
*.log
|
|
23
|
+
|
|
24
|
+
# OS & Editor
|
|
25
|
+
.DS_Store
|
|
26
|
+
Thumbs.db
|
|
27
|
+
.vscode/
|
|
28
|
+
.idea/
|
|
29
|
+
*.swp
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
repos:
|
|
2
|
+
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
3
|
+
rev: v0.9.0
|
|
4
|
+
hooks:
|
|
5
|
+
- id: ruff
|
|
6
|
+
- id: ruff-format
|
|
7
|
+
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
8
|
+
rev: v1.15.0
|
|
9
|
+
hooks:
|
|
10
|
+
- id: mypy
|
|
11
|
+
additional_dependencies:
|
|
12
|
+
- types-requests
|
|
13
|
+
args: ["--ignore-missing-imports", "src"]
|
|
14
|
+
pass_filenames: false
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Agent Operating Rules — `llama-mcp-bridge`
|
|
2
|
+
|
|
3
|
+
## 1. Environment & Tooling
|
|
4
|
+
- **Package & Test Runner:** Exclusively use `uv` (`uv run pytest`, `uv run ruff check .`, `uv sync`). Never instruct the user to create or activate a manual `venv` or use raw `pip`.
|
|
5
|
+
- **Python Target:** Python 3.11+ (`src/llama_mcp_bridge/` layout).
|
|
6
|
+
- **Language:** Use British/South African English spelling in documentation and comments where applicable (e.g., `initialise`, `serialise`, `behaviour`).
|
|
7
|
+
|
|
8
|
+
## 2. Hard Safety Boundaries
|
|
9
|
+
- **Read-Only Reference Directory (`/mnt/ai`):** Never modify, delete, or write files inside `/mnt/ai` or `~/.gemini/antigravity/mcp/`. Treat `/mnt/ai/local_bridge.py`, `/mnt/ai/hygiene.py`, and `/mnt/ai/models.ini` strictly as read-only reference specifications.
|
|
10
|
+
- **No Unsolicited Model Downloads:** Never download `.gguf` weights during tests or dry-runs. All unit tests must mock network calls and subprocess probes.
|
|
11
|
+
|
|
12
|
+
## 3. Local Specialist Delegation (`local-ai` MCP)
|
|
13
|
+
Delegate heavy inspection, boilerplate, auditing, and verification to the `local-ai` MCP tools rather than bloating cloud context:
|
|
14
|
+
- `ask_digest`: Structured JSON extraction from configs, logs, and schemas.
|
|
15
|
+
- `ask_coder_fast`: Rapid boilerplate (`pyproject.toml`, `bridge.example.ini`, `.github/workflows/ci.yml`, `pytest` fixtures).
|
|
16
|
+
- `ask_coder` / `ask_coder_long`: Modularizing `bridge.py`, `hardware.py`, `installer.py`, and `supervisor.py`.
|
|
17
|
+
- `ask_analyst`: Auditing cross-platform edge cases (Windows paths, macOS unified memory, Linux ROCm/CUDA, FreeBSD fallback).
|
|
18
|
+
- `ask_reasoner`: Verifying VRAM headroom math and `models.ini` tier budgets.
|
|
19
|
+
|
|
20
|
+
## 4. Verification Standard
|
|
21
|
+
- Every phase must end with `uv run pytest` passing with zero errors before moving to the next phase.
|
|
22
|
+
- Any changes to `hardware.py` must pass the golden 8 GB NVIDIA `sm_86` test asserting exact parity with `/mnt/ai/models.ini` tuning parameters.
|
|
23
|
+
|
|
24
|
+
## 5. Anti-Truncation & Completeness Rules
|
|
25
|
+
- **Copy-Then-Patch for Existing Code:** Never ask `local-ai` tools to regenerate files over 150 lines from scratch. Always copy the `/mnt/ai/` reference file first (`cp /mnt/ai/local_bridge.py src/llama_mcp_bridge/bridge.py`) and apply targeted, small edits.
|
|
26
|
+
- **Small Modular Files:** Keep new modules (`config.py`, `supervisor.py`, `hardware.py`, `installer.py`) under ~180 lines each so `ask_coder` / `ask_coder_long` never exhaust `max_tokens` mid-file.
|
|
27
|
+
- **Hard Phase Gate:** Before advancing to the next phase, run:
|
|
28
|
+
1. `uv run python -m compileall src tests` (catches any truncated syntax immediately)
|
|
29
|
+
2. `uv run pytest -v` (verifies all expected modules and tests exist and pass)
|
|
30
|
+
- **No Silent Stubs:** Never leave `TODO`, `pass`, or placeholder functions in `src/llama_mcp_bridge/`.
|
|
31
|
+
|
|
32
|
+
## 6. Single-Responsibility Tool Calls
|
|
33
|
+
- **One Module Per `local-ai` Call:** Never ask `ask_coder` or `ask_coder_long` to combine hardware probing, INI/config generation, and CLI logic in a single prompt. Split distinct concerns into separate files (`hardware.py` for probes vs. `presets.py` for `models.ini` generation) and generate one file per tool call.
|
|
34
|
+
|
|
35
|
+
## 7. Test Integrity & Anti-Cheating Rule
|
|
36
|
+
- **Never Weaken Tests to Force a Pass:** When a test fails, fix the production code in `src/`—never delete assertions, loosen expected values, or strip edge cases from `tests/` just to make `pytest` exit `0`.
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Architecture — `llama-mcp-bridge`
|
|
2
|
+
|
|
3
|
+
`llama-mcp-bridge` separates **orchestration & MCP exposure** (`bridge.ini` / Python FastMCP server) from **model serving & preset execution** (`models.ini` / `llama-server --models-preset` router mode).
|
|
4
|
+
|
|
5
|
+
## Module Call Graph
|
|
6
|
+
|
|
7
|
+
```mermaid
|
|
8
|
+
flowchart TD
|
|
9
|
+
subgraph CLI["CLI Entrypoints"]
|
|
10
|
+
INSTALL["installer.py<br/>(llama-mcp-install / llama-mcp-ps)"]
|
|
11
|
+
MODELS["models_cli.py<br/>(llama-mcp-models)"]
|
|
12
|
+
CFGCLI["config_cli.py<br/>(llama-mcp-config)"]
|
|
13
|
+
BRIDGE["bridge.py<br/>(llama-mcp-bridge)"]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
subgraph InstallerModules["Installer & Diagnostics"]
|
|
17
|
+
SVC["service_install.py<br/>(binary, archive, systemd/launchd/schtasks/crontab)"]
|
|
18
|
+
DL["model_download.py<br/>(.part resume, SHA-256)"]
|
|
19
|
+
CLIENT["client_config.py<br/>(MCP JSON snippets & harness cleanup)"]
|
|
20
|
+
SKILL["skill_install.py<br/>(SKILL.md installation)"]
|
|
21
|
+
OLLAMA["ollama_import.py<br/>(manifest parser & blob symlinker)"]
|
|
22
|
+
DIAG["diagnostics.py<br/>(--profile, --selftest, --export/--diff-config)"]
|
|
23
|
+
SIGN["signing.py<br/>(cosign/gpg release verification)"]
|
|
24
|
+
HTTP["http_resilience.py<br/>(backoff, circuit breaker, ENOSPC/EMFILE)"]
|
|
25
|
+
ENT["enterprise/<br/>(audit.py, probes.py, tenant.py)"]
|
|
26
|
+
LOG["logging_utils.py<br/>(text & JSON log formatter)"]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
subgraph Core["Core Runtime"]
|
|
30
|
+
CFG["config.py<br/>(BridgeConfig, mtime+bytes cached load_config)"]
|
|
31
|
+
PATHS["paths.py<br/>(workspace, global & named pointers)"]
|
|
32
|
+
HW["hardware.py<br/>(SystemProfile & VRAM tiers)"]
|
|
33
|
+
PRESETS["presets.py<br/>(models.ini generation & HF resolution)"]
|
|
34
|
+
GGUF["gguf_header.py<br/>(GGUF v2/v3 parser & KV math)"]
|
|
35
|
+
DISC["discovery.py<br/>(.gitignore & budget prompt builder)"]
|
|
36
|
+
SUP["supervisor.py<br/>(LlamaSupervisor & stderr classifier)"]
|
|
37
|
+
HYG["hygiene.py<br/>(clean_mcp_output)"]
|
|
38
|
+
MET["metrics.py<br/>(Prometheus /metrics & /healthz sidecar)"]
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
INSTALL --> SVC & DL & CLIENT & SKILL & OLLAMA & DIAG
|
|
42
|
+
INSTALL --> CFG & HW & PRESETS & SUP
|
|
43
|
+
MODELS --> CFG & HW & PRESETS & GGUF & DL & OLLAMA
|
|
44
|
+
CFGCLI --> CFG
|
|
45
|
+
OLLAMA --> GGUF & PRESETS & HW
|
|
46
|
+
DIAG --> CFG & GGUF & PRESETS & HW & SUP
|
|
47
|
+
BRIDGE --> CFG & DISC & SUP & HYG & HW & MET & PATHS
|
|
48
|
+
SVC --> CFG & PATHS & SUP & CLIENT & SIGN
|
|
49
|
+
DL --> PRESETS & HW
|
|
50
|
+
CLIENT --> CFG & PATHS
|
|
51
|
+
CFG --> PATHS
|
|
52
|
+
PRESETS --> HW
|
|
53
|
+
GGUF --> HW
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Request & Data Flow
|
|
57
|
+
|
|
58
|
+
1. **Tool Registration & Hot-Reload:** At startup, `bridge.py` (`_register_configured_tools`) reads `models.ini` under `_TOOL_REG_LOCK`, filters by `allowed_presets`, and exposes configured presets plus `get_bridge_status`, `ask_preset`, and `ask_batch`. Subsequent `models.ini` changes trigger `check_and_reload_models_ini()` and emit `notifications/tools/list_changed`.
|
|
59
|
+
2. **Context Assembly & Warmup:** When a tool is called with `file_paths`, `discovery.py` expands files, directories, and globs with `include > (.gitignore + ignore + DEFAULT_IGNORES)` precedence, sorts smallest-first, and truncates cleanly within `max_total_chars`. Optional `--warmup` preloads configured presets asynchronously on startup.
|
|
60
|
+
3. **Lazy Supervision & Auth:** `bridge.py` invokes `LlamaSupervisor.ensure_running()`, which checks `/health` and auto-spawns `llama-server --models-preset <models.ini>` (with `--api-key` when configured), streaming output to `llama-server.log` and a bounded stderr tail.
|
|
61
|
+
4. **Inference, Streaming & Hygiene:** Requests hit `http://<host>:<port>/v1/chat/completions` with `"stream": false` or `"stream": true` (SSE token accumulation) and per-call `timeout_s`, emitting `notifications/progress` after 30s. Responses pass through `hygiene.py` (`clean_mcp_output`), while `metrics.py` records counters and latency histograms for `GET /metrics`.
|
|
62
|
+
5. **Failure Classification & OOM Fallback:** On HTTP 500/503 or transport failure, `supervisor.py` (`classify_inference_error`) inspects the captured `llama-server` `stderr` tail to distinguish VRAM/RAM OOM from timeouts and, when `fallback_on_oom = true`, retries text-only on `digest`.
|
|
63
|
+
|
|
64
|
+
## Lifecycle & Integration Seams
|
|
65
|
+
|
|
66
|
+
1. **`llama-server` Auto-Spawn Lifecycle (`supervisor.py`):** When `auto_spawn = true`, `LlamaSupervisor.ensure_running()` spawns `llama-server` under `self._lock` with `--host`, `--port`, `--models-preset`, `--models-dir`, and tier+residency `--models-max` / `--sleep-idle-seconds` (or explicit `bridge.ini` overrides), then releases `self._lock` before polling `/health` so status/stop calls never block.
|
|
67
|
+
2. **`models.ini` Hot-Reload (`bridge.py`):** `check_and_reload_models_ini()` caches file state by `(st_mtime_ns, st_size)` under `_TOOL_REG_LOCK` and emits `notifications/tools/list_changed` when presets change; `ask_preset` can also call newly added presets immediately.
|
|
68
|
+
3. **`fallback_on_oom` Flow (`bridge.py`):** If `llama-server` returns HTTP 500 with OOM indicators in captured `stderr` and `fallback_on_oom = true`, text requests automatically retry on the lightweight `digest` preset.
|
|
69
|
+
4. **Four Integration Seams:**
|
|
70
|
+
- **MCP Host ↔ `bridge.py`:** JSON-RPC over stdio (`fastmcp`).
|
|
71
|
+
- **`bridge.py` ↔ `llama-server`:** Local HTTP (`/v1/chat/completions`, `/health`) on `127.0.0.1`.
|
|
72
|
+
- **`installer.py` / `models_cli.py` ↔ Filesystem:** `bridge.ini`, `models.ini`, and GGUF weights under `LLAMA_MCP_HOME`.
|
|
73
|
+
- **`bridge.py` ↔ `enterprise/`:** Opt-in lazy import gated by `--enterprise` / `enterprise_mode = true`.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [1.0.1] - 2026-11-27
|
|
4
|
+
|
|
5
|
+
- **Fixed:** `LlamaSupervisor._start_server()` now passes `--host`, `--port`, `--models-preset`, `--models-dir`, and residency flags (`--models-max`, `--sleep-idle-seconds`) when auto-spawning `llama-server`, preventing `llama-server` from binding the default port `9931` with zero models instead of the configured `bridge.ini` endpoint.
|
|
6
|
+
- **Fixed:** `LlamaServerConfig` and `create_supervisor()` now forward `models_ini`, `models_dir`, and `residency` parameters to `_start_server()`.
|
|
7
|
+
- **Added:** Optional `models_max` and `sleep_idle_seconds` overrides in `bridge.ini` (`BridgeConfig` / `LlamaServerConfig`) to override tier+residency defaults.
|
|
8
|
+
- **Tests:** Added unit tests in `tests/test_supervisor_spawn_args.py` verifying CLI flags across `stingy`, `moderate`, and `snappy` residency profiles.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
|
2
|
+
|
|
3
|
+
## Our Pledge
|
|
4
|
+
|
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, caste, colour, religion, or sexual identity and orientation.
|
|
6
|
+
|
|
7
|
+
## Our Standards
|
|
8
|
+
|
|
9
|
+
Examples of behaviour that contributes to a positive environment for our community include:
|
|
10
|
+
|
|
11
|
+
- Demonstrating empathy and kindness toward other people
|
|
12
|
+
- Being respectful of differing opinions, viewpoints, and experiences
|
|
13
|
+
- Giving and gracefully accepting constructive feedback
|
|
14
|
+
- Accepting responsibility and apologising to those affected by our mistakes, and learning from the experience
|
|
15
|
+
- Focusing on what is best not just for us as individuals, but for the overall community
|
|
16
|
+
|
|
17
|
+
Examples of unacceptable behaviour include:
|
|
18
|
+
|
|
19
|
+
- The use of sexualised language or imagery, and sexual attention or advances of any kind
|
|
20
|
+
- Trolling, insulting or derogatory comments, and personal or political attacks
|
|
21
|
+
- Public or private harassment
|
|
22
|
+
- Publishing others' private information, such as a physical or electronic address, without their explicit permission
|
|
23
|
+
- Other conduct which could reasonably be considered inappropriate in a professional setting
|
|
24
|
+
|
|
25
|
+
## Enforcement Responsibilities
|
|
26
|
+
|
|
27
|
+
Project maintainers are responsible for clarifying and enforcing our standards of acceptable behaviour and will take appropriate and fair corrective action in response to any behaviour that they deem inappropriate, threatening, offensive, or harmful.
|
|
28
|
+
|
|
29
|
+
## Scope
|
|
30
|
+
|
|
31
|
+
This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces.
|
|
32
|
+
|
|
33
|
+
## Enforcement
|
|
34
|
+
|
|
35
|
+
Instances of abusive, harassing, or otherwise unacceptable behaviour may be reported to the project maintainers via GitHub Issues or Security Advisories at <https://github.com/OakHell/llama-mcp-bridge>. All complaints will be reviewed and investigated promptly and fairly.
|
|
36
|
+
|
|
37
|
+
## Attribution
|
|
38
|
+
|
|
39
|
+
This Code of Conduct is adapted from the [Contributor Covenant](https://www.contributor-covenant.org), version 2.1, available at <https://www.contributor-covenant.org/version/2/1/code_of_conduct.html>.
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# Contributing to `llama-mcp-bridge`
|
|
2
|
+
|
|
3
|
+
Thank you for considering contributing to `llama-mcp-bridge`!
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
This project uses `uv` exclusively for environment management, linting, type checking, and testing (Python 3.11+):
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
git clone https://github.com/OakHell/llama-mcp-bridge.git
|
|
11
|
+
cd llama-mcp-bridge
|
|
12
|
+
uv sync --dev
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Verification Checks
|
|
16
|
+
|
|
17
|
+
Run the full local verification suite before opening a pull request:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
uv run ruff check .
|
|
21
|
+
uv run mypy src
|
|
22
|
+
uv run pytest -v
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
You can also use the `Makefile` shortcuts (`make check` or `make test`, `make lint`, `make typecheck`) or install pre-commit hooks via `pre-commit install`.
|
|
26
|
+
|
|
27
|
+
## Coding & Testing Guidelines
|
|
28
|
+
|
|
29
|
+
- **Type annotations:** Keep `uv run mypy src` clean across all modules in `src/llama_mcp_bridge/`.
|
|
30
|
+
- **Modular layout:** Place new installer subcommands or helpers in their focused submodule (`service_install.py`, `model_download.py`, `client_config.py`, `skill_install.py`, `discovery.py`) and re-export from `installer.py` / `bridge.py` where needed for backwards compatibility.
|
|
31
|
+
- **Mock external I/O:** Unit tests must mock network calls (Hugging Face / GitHub APIs) and subprocess probes (`nvidia-smi`, `llama-server`, `systemctl`, `schtasks`) so the suite runs offline across Linux, macOS, Windows, and FreeBSD.
|
|
32
|
+
- **Documentation:** Update `README.md`, `TRACKER.md`, or `docs/` when adding CLI flags, configuration keys, or hardware tier changes.
|
|
33
|
+
|
|
34
|
+
## Pull Request Process
|
|
35
|
+
|
|
36
|
+
1. Create a feature branch from `main` (e.g. `feat/my-change` or `fix/issue-123`).
|
|
37
|
+
2. Ensure `uv run ruff check .`, `uv run mypy src`, and `uv run pytest -v` pass with zero errors.
|
|
38
|
+
3. Fill out the pull request template describing the change and verification performed.
|
|
39
|
+
|
|
40
|
+
## Enterprise Extra (`src/llama_mcp_bridge/enterprise/`)
|
|
41
|
+
- `audit.py` (`E3`), `probes.py` (`E7`), `tenant.py` (`E11`): opt-in `[enterprise]` modules, never imported unless `--enterprise` / `enterprise_mode = true`.
|
|
42
|
+
|
|
43
|
+
## Makefile Targets
|
|
44
|
+
- `make test`: Run `uv run pytest -v`
|
|
45
|
+
- `make lint`: Run `uv run ruff check .`
|
|
46
|
+
- `make typecheck`: Run `uv run mypy src`
|
|
47
|
+
- `make doctor`: Run `uv run llama-mcp-install --doctor`
|
|
48
|
+
- `make verify-all`: Run `uv run llama-mcp-install --verify-all`
|
|
49
|
+
- `make check`: Run `lint`, `typecheck`, and `test`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abdul-Kader Jainoodien
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
.PHONY: test lint typecheck doctor verify-all check
|
|
2
|
+
|
|
3
|
+
test:
|
|
4
|
+
uv run pytest -v
|
|
5
|
+
|
|
6
|
+
lint:
|
|
7
|
+
uv run ruff check .
|
|
8
|
+
|
|
9
|
+
typecheck:
|
|
10
|
+
uv run mypy src
|
|
11
|
+
|
|
12
|
+
doctor:
|
|
13
|
+
uv run llama-mcp-install --doctor
|
|
14
|
+
|
|
15
|
+
verify-all:
|
|
16
|
+
uv run llama-mcp-install --verify-all
|
|
17
|
+
|
|
18
|
+
check: lint typecheck test
|