@octocodeai/freellama-mcp-server 0.5.0 → 0.6.1

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.
@@ -1,106 +0,0 @@
1
- # Ollama model metadata
2
-
3
- The MCP `models` tool gives an agent the inventory and capability metadata it needs before
4
- offloading work. It reads your Ollama instance and can enrich results with descriptions from
5
- Ollama's public model library. Supported features and advertised use cases are metadata;
6
- exact-model benchmarks and policy supply quality evidence. Public descriptions do not change
7
- routing confidence, and a successful response still needs task-specific verification.
8
-
9
- ## Requests
10
-
11
- | Request | Result | External access |
12
- |---|---|---|
13
- | `models {view:"installed"}` | Managed inventory with a `knowledge` object for each model | Local backend data only |
14
- | `models {view:"installed", includeLibrary:true}` | Inventory enriched with public guidance for verified local tags | Fetches model family and tag pages from ollama.com |
15
- | `models {view:"detail", model:"gemma3:1b"}` | Ollama details, maximum context, and supported-use explanations | Selected Ollama endpoint only |
16
- | `models {view:"detail", model:"gemma3:1b", includeLibrary:true}` | Details plus public guidance after a tag and digest check | Selected Ollama endpoint and ollama.com |
17
- | `models {view:"library", query:"coding"}` | Public family search with descriptions and advertised feature chips | ollama.com and optional local inventory/profile reads |
18
- | `models {view:"library", model:"gemma3"}` | All public tags with size, digest prefix, context, modalities, and cloud status | ollama.com and optional local inventory/profile reads |
19
-
20
- These are MCP tool requests. The CLI's `models` command reports the core catalog and does not expose these enrichment flags. For CLI setup and routing, see the [CLI reference](CLI.md).
21
-
22
- | Option | Valid views | Default | Meaning |
23
- |---|---|---|---|
24
- | `includeLibrary` | `installed`, `detail` | `false` | Requests public metadata; the default makes no website calls |
25
- | `includeReadme` | Library step 2, or `detail` with `includeLibrary:true` | `false` | Returns README text, capped at 65,536 characters, with its format and truncation flag |
26
- | `includeVerbose` | `detail` | `false` | Returns Ollama's license and Modelfile fields independently of README enrichment |
27
- | `limit`, `cursor` | `raw`, library tag listings; `limit` also applies to library search | Tag/raw page size 20; search limit 10 | Pages large lists; the tag cursor rejects a changed tag list |
28
- | `ollamaEndpoint` | Direct Ollama views and library inventory reads | Configured Ollama endpoint | Chooses the Ollama instance; enriched managed inventory uses each model's assigned backend |
29
-
30
- An incompatible option returns an error before any lookup. Installed enrichment omits full READMEs to keep inventory responses bounded; request one model's detail to read its README.
31
-
32
- ## Supported features
33
-
34
- `knowledge.supportedFeatures` preserves the feature strings available from the selected source. `supportedFeaturesSource` is `ollama_api` for direct Ollama metadata and `freellama_catalog` for the managed catalog. The catalog contains normalized routing capabilities; unknown future strings remain visible in `detail`, `raw`, or enriched installed inventory when Ollama's tag response supplies them. Unknown strings do not create new routing requirements.
35
-
36
- `knowledge.supportedUseCases` explains each recognized feature:
37
-
38
- | Feature | Supported workflow | What to evaluate separately |
39
- |---|---|---|
40
- | `completion` | Text generation | Coding, summarization, reasoning, and instruction-following accuracy |
41
- | `tools` | Tool calls | Argument correctness, tool selection, and agent-loop reliability |
42
- | `vision` | Image input | OCR and visual understanding accuracy |
43
- | `audio` | Audio workflows advertised by the model | Supported audio task and accuracy |
44
- | `embedding` | Retrieval and similarity vectors | Retrieval quality on your documents |
45
- | `thinking` | A thinking mode | Reasoning accuracy, latency, and token cost |
46
- | `insert` | Suffix-based text insertion | Completion accuracy in the target code or text |
47
- | `image` | Image generation | Output quality and supported controls |
48
-
49
- Each explanation contains its `capability`, `use`, `reason`, and `basis:"supported_feature"`. Ollama runtime/version support still applies. The inventory's existing benchmark and policy fields remain separate from `knowledge.quality:"metadata_only"`.
50
-
51
- ## Public guidance and provenance
52
-
53
- For a verified installed model, `knowledge.library` contains the source page, full tag-page URL, `fetchedAt`, `expiresAt`, `cached`, and exact public tag metadata. It also contains:
54
-
55
- | Field | Meaning |
56
- |---|---|
57
- | `description` | The public family description |
58
- | `advertisedFamilyCapabilities` | Family feature chips; these do not extend the local tag's capabilities |
59
- | `advertisedUseCases` | Recognized coding, tool-calling, image-understanding/OCR, reasoning, embedding, summarization, question-answering, translation, and long-context claims |
60
- | `advertisedUseCases[].evidence` | A bounded source excerpt, source URL, and fetch timestamp |
61
- | `usageNotes` | Bounded excerpts about requirements, restrictions, context, memory, languages, or query prefixes |
62
- | `readmeAvailable` | Whether a README was extracted |
63
- | `readme` | Requested text with `format` (`markdown` or `text`) and `truncated` |
64
-
65
- Advertised uses have `basis:"advertised"`, `scope:"family"`, and `quality:"unmeasured"`. Extraction recognizes positive prose mentions and skips fenced code and explicit negative statements. It is a discovery aid, not a complete classification: an omitted use means extraction found no recognized claim. Usage notes also remain family-scoped and can describe other variants. Read the source for the full instructions. These use labels are not the `run_task` task enum; choose a supported routing profile with the capabilities and context your workload requires.
66
-
67
- Local capabilities filter advertised uses. For example, `gemma3:1b` accepts text, while larger Gemma 3 variants accept images. A family-level vision chip cannot make the 1B tag a vision candidate. Likewise, an embedding-only tag does not acquire text-generation workflows from its family description.
68
-
69
- Installed enrichment requires the exact public tag and a matching digest prefix of at least 12 hexadecimal characters against the local 64-character digest. Custom names are never mapped by architecture or guessed base model. Community names use their exact Ollama namespace. Without a verified match, public guidance is withheld. A local modification can therefore prevent enrichment even when its name resembles a public model.
70
-
71
- Library step 2 describes public models before installation, so its top-level `library` guidance remains family-scoped without claiming a local digest match. Each `tags[]` entry carries its own modalities, context, digest prefix, and `cloud` flag. Search returns `cloudAvailable` for the hosted-access badge and `cloudOnly:null`: a family badge alone does not establish that local downloads are absent.
72
-
73
- ## Lookup states
74
-
75
- | `library.status` | Meaning | Next action |
76
- |---|---|---|
77
- | `not_requested` | Website enrichment was not requested | Set `includeLibrary:true` if external lookup is useful |
78
- | `matched` | Installed tag and public digest prefix match | Read the sourced guidance, then evaluate the exact tag |
79
- | `available` | Public family and tag pages were parsed in library step 2 | Inspect the exact tag before recommending a download |
80
- | `unverified` | Digest or current backend inventory could not be verified | Recheck local inventory; retain local feature information |
81
- | `digest_mismatch` | The public tag differs from the installed digest | Treat public guidance as unavailable for this installed model |
82
- | `tag_not_found` | The parsed public tag list has no exact matching tag | Check the source and custom-model provenance |
83
- | `unmatched` | The name cannot resolve to an exact public Ollama name | Keep use-case suitability unknown until provenance is verified |
84
- | `not_found` | A requested public page returned HTTP 404 | Check the source URL or custom name |
85
- | `unavailable` | Transport, timeout, HTTP refusal, or page-size limit prevented lookup | Retry later; local results remain available |
86
- | `parse_error` | HTML content or tag rows were not recognized | Inspect the source; do not conclude the model is absent |
87
- | `remote_model`, `remote_tag` | Remote Ollama fields or a hosted tag identify cloud execution | Select a local download tag for local execution |
88
-
89
- `localModel:false` flags detected remote entries. Known remote entries skip public enrichment, and cloud tags never become local trial recommendations. This metadata is not processor-placement evidence; inspect the execution observation for CPU/GPU placement.
90
-
91
- ## Cache and request bounds
92
-
93
- Each MCP process caches at most 128 families. Successful lookups expire after one hour, failures after one minute; concurrent requests for a family share one lookup. Expired content is not served as current metadata. Restarting the MCP process clears this in-memory cache.
94
-
95
- Installed enrichment runs at most four family lookups concurrently. Each lookup requests the family page and complete `/tags` page in parallel. Requests use GET, refuse redirects, cap each page at 2 MiB, and time out after the smaller of 10 seconds and `FREELLAMA_MCP_FETCH_TIMEOUT_SECONDS`. These requests retrieve metadata without loading or executing a model. They disclose the requested public family name to ollama.com.
96
-
97
- The local inventory is not cached by the enrichment layer. A changed backend inventory or failed lookup leaves the managed model and its existing evidence intact. A size-based library recommendation is only a download trial candidate: download size does not establish runtime memory fit, CPU/GPU placement, or task quality. Model discovery never authorizes a pull.
98
-
99
- ## Sources and related documentation
100
-
101
- - [Ollama model details API](https://docs.ollama.com/api-reference/show-model-details) provides runtime capability and architecture metadata.
102
- - [Ollama model-list API](https://docs.ollama.com/api/tags) provides installed tags and digests.
103
- - [Ollama Gemma 3 page](https://ollama.com/library/gemma3) illustrates variant-specific modalities.
104
- - [MCP tool reference](../packages/mcp/README.md#tools) documents the complete tool surface.
105
- - [Choose local models](MODEL_SELECTION.md) explains quality qualification and measured results.
106
- - [Test FreeLlama](TESTING.md) lists the parser, enrichment, and protocol checks.
@@ -1,78 +0,0 @@
1
- # Ollama sidecar boundary
2
-
3
- FreeLlama exposes task-oriented controls to agents and communicates with Ollama over HTTP.
4
- It defaults to a loopback sidecar: FreeLlama manages delegation policy and resources around each
5
- managed request, while Ollama loads the runner and performs inference.
6
-
7
- ```mermaid
8
- flowchart LR
9
- C["Ollama-compatible client"] --> F["FreeLlama loopback sidecar"]
10
- F -->|"raw /api and /v1"| G["Primary Ollama"]
11
- F -->|"managed primary task"| G
12
- F -->|"managed assigned task"| U["Optional CPU Ollama"]
13
- G --> E["Metal, MLX, CUDA, ROCm, Vulkan, or CPU runner"]
14
- U --> E2["CPU runner"]
15
- ```
16
-
17
- This boundary avoids an Ollama fork and preserves its documented HTTP contract. It also makes a
18
- second, process-isolated CPU backend possible without changing arbitrary client payloads.
19
-
20
- ## Divide ownership
21
-
22
- | Problem | Owner |
23
- |---|---|
24
- | Kernels, prompt processing, and token generation | Ollama and its runner dependencies |
25
- | Runner loading, eviction, and scheduling within one server | Ollama |
26
- | Prompt templates and model defaults | Ollama model metadata or a `Modelfile` |
27
- | Capability and memory filtering | FreeLlama managed routes |
28
- | Evidence policy, confidence, and route receipts | FreeLlama managed routes |
29
- | Session affinity, per-backend bounded admission, and warm runtime feedback | FreeLlama managed routes |
30
- | Forecast memory reservations and requests to evict idle unpinned runners | FreeLlama managed routes |
31
- | Exact model assignment to an optional CPU process | FreeLlama configuration |
32
- | Guarded CPU/GPU preference within assigned eligible models | FreeLlama managed routes |
33
- | Authentication and remote exposure | FreeLlama bearer middleware; external ingress owns TLS and tenant authorization |
34
-
35
- FreeLlama does not make an individual model decode faster. It can improve workload completion by
36
- avoiding unsuitable routes, reducing avoidable transitions, refusing unsupported work early, and
37
- overlapping independent CPU and GPU model requests when the machine benefits from that layout.
38
-
39
- ## Preserve compatibility
40
-
41
- `packages/rust-core/src/proxy.rs` forwards paths, queries, request bodies, and streaming response
42
- bodies. It removes hop-by-hop headers and adds `x-freellama-proxy: 1` to responses. Raw `/api/*`
43
- and `/v1/*` requests always target the primary upstream and are not rewritten for CPU placement.
44
-
45
- ```mermaid
46
- flowchart TD
47
- R["Incoming request"] --> K{"Managed /_freellama/v1 route?"}
48
- K -->|"No"| P["Stream unchanged to primary Ollama"]
49
- K -->|"Yes"| V["Validate, route, assign backend, and admit"]
50
- V --> X["Build bounded Ollama request"]
51
- X --> O["Execute on assigned upstream"]
52
- ```
53
-
54
- The distinction is intentional: existing Ollama clients retain predictable compatibility, while
55
- clients that opt into the managed API receive routing and policy behavior.
56
-
57
- ## Know the remaining limits
58
-
59
- In `serve`, mutating passthrough traffic shares the primary transition lock and receives host-pressure
60
- gating, while managed tasks also reserve forecast memory. Direct Ollama callers bypass these
61
- controls. FreeLlama cannot preempt inference or constrain other processes. A configured but unreachable CPU backend makes managed catalog discovery fail closed;
62
- raw primary passthrough remains usable.
63
-
64
- Runtime feedback is task-specific, token-normalized, and warm-only. It can steer
65
- unpinned `fastest` or `balanced` work after three samples on each backend and a greater-than-10%
66
- advantage; it cannot change CPU eligibility or steer quality routing. The CLI persists a bounded,
67
- versioned snapshot atomically by default, so verified evidence survives restart without changing
68
- Ollama residency.
69
-
70
- Read [Architecture](ARCHITECTURE.md) for all managed flows,
71
- [CPU and GPU model routing](CPU_GPU_ROUTING.md) for the two-process procedure, and
72
- [Ollama and FreeLlama optimization](dev/OLLAMA_SYSTEM_OPTIMIZATION.md) for the full tuning boundary.
73
-
74
- ## Sources
75
-
76
- - [Ollama API introduction](https://docs.ollama.com/api/introduction)
77
- - [Ollama streaming behavior](https://docs.ollama.com/api/streaming)
78
- - [Ollama usage metrics](https://docs.ollama.com/api/usage)
@@ -1,121 +0,0 @@
1
- # Product positioning
2
-
3
- FreeLlama gives AI agents a managed way to offload tasks to local models through Ollama.
4
- Agents submit bounded work through MCP; FreeLlama handles model selection, queues, memory checks,
5
- residency coordination, and routing to configured CPU/GPU backends. It returns results with
6
- execution evidence so the calling agent can verify them.
7
-
8
- > Agents delegate tasks. FreeLlama manages local resources. Ollama runs inference.
9
-
10
- The CLI and control API expose the same management layer to operators and applications.
11
- See [architecture](ARCHITECTURE.md) for the ownership contract and the
12
- [README](../README.md) for installation and first use.
13
-
14
- ## Audience and purpose
15
-
16
- The primary audience is developers operating coding or research agents with Ollama. Typical work
17
- includes grounded repository lookup, embeddings, image/OCR tasks, supplied-content transforms,
18
- and helper-model requests. Local-AI operators can use the CLI for the same routing and resource
19
- controls without an MCP host.
20
-
21
- The purpose is to make suitable local delegation bounded and inspectable. Eligibility checks,
22
- policy, and benchmark evidence help an agent choose a model; they do not prove that an individual
23
- answer is correct. The calling agent retains judgment and final verification.
24
-
25
- ## How the layers fit
26
-
27
- ```mermaid
28
- flowchart LR
29
- A["Calling agent: choose task and constraints"] --> F["FreeLlama: select model and manage resources"]
30
- F -->|"managed primary task"| G["Primary Ollama"]
31
- F -->|"assigned CPU helper"| C["Optional CPU Ollama"]
32
- F -->|"capacity unavailable"| Q["Bounded queue or refusal"]
33
- G --> R["Result and execution evidence"]
34
- C --> R
35
- R --> V["Calling agent: verify and continue"]
36
- ```
37
-
38
- | Layer | Owns |
39
- |---|---|
40
- | Calling agent | What to offload, prompts, task dependencies, independent concurrency, and answer verification |
41
- | FreeLlama | Installed-model eligibility, policy, managed admission, memory forecasts, residency coordination, bounded history, and execution evidence |
42
- | Operator | Ollama installation, endpoints, exact CPU model assignments, lifecycle approval, and runtime configuration |
43
- | Ollama and the host | Model storage, runner loading, inference, and physical CPU/GPU scheduling |
44
-
45
- Start with one Ollama process. A second process is optional for explicitly assigned CPU helpers.
46
- An agent's placement preference chooses only among eligible configured models. Inspect observed
47
- placement before treating CPU/GPU assignment as physical evidence.
48
-
49
- ## What agents receive
50
-
51
- | Need | Surface | Result |
52
- |---|---|---|
53
- | Inspect the machine and models | `doctor`, `models` | Host diagnostics, installed capabilities, and resident-runner observations |
54
- | Preview suitability | `run_task {preview:true}` | A decision and reasons without running inference |
55
- | Execute supplied content | `run_task` | Model output with routing, admission, timing, and placement evidence |
56
- | Look up repository facts | `delegate_research` | A bounded read-only answer, citations, and `accept`, `verify`, or `escalate` verdict |
57
- | Dispatch independent work | `run_task_batch` | Bounded dispatch and separate results or errors |
58
- | Manage longer work | `task_jobs` | Process-local status, result retrieval, cancellation, and removal |
59
- | Reuse conversation history | `scope`, `session`, `warm_model` | Separate controls for message history, model affinity, and residency |
60
-
61
- Preview accepts routing fields only. Submit prompts, messages, images, embedding input, tools,
62
- and runtime controls in a separate execution call. A preview does not reserve capacity.
63
- For requests and result fields, use the [MCP reference](../packages/mcp/README.md).
64
-
65
- ## Resource management
66
-
67
- FreeLlama manages requests before they reach the inference runtime. Its resource controls include:
68
-
69
- - Per-backend weighted admission, finite queues, priorities, wait budgets, and deadlines.
70
- - Host-pressure checks and forecast memory reservations for managed work.
71
- - Model-transition coordination and requests to unload idle, unpinned models when a cold load needs room.
72
- - Explicit routing to the primary or operator-assigned CPU backend.
73
- - Bounded warm execution feedback for eligible speed-oriented automatic routes.
74
- - Receipts and status views that expose queues, resource holds, residency, timing, and placement.
75
-
76
- The operator configures topology and limits. FreeLlama does not preempt inference or control other
77
- processes that call Ollama directly. It coordinates model use through Ollama rather than allocating
78
- physical GPU cores or implementing inference kernels.
79
-
80
- Read [CPU/GPU routing](CPU_GPU_ROUTING.md) for placement and
81
- [monitoring](MONITORING.md) for effective settings and runtime observations.
82
-
83
- ## Context and cost
84
-
85
- Delegated research keeps source files and intermediate local-tool observations out of the calling
86
- agent's prompt. The local worker still consumes input/output tokens and hardware time. Embedding
87
- vectors stay out of MCP results by default unless the caller requests them.
88
-
89
- This can reduce the calling agent's context burden. It does not imply zero-cost computation or a
90
- universal savings rate. The [token economics report](ECONOMICS.md) separates historical measurements,
91
- client-envelope sizes, and session estimates.
92
-
93
- ## Describe the product consistently
94
-
95
- | Context | Wording |
96
- |---|---|
97
- | Category | Local-model delegation and resource management layer |
98
- | One line | FreeLlama helps AI agents offload tasks to local models while managing model selection and resources. |
99
- | Mechanism | Inspect, qualify, preview, admit, execute, and return evidence. |
100
- | Runtime relationship | FreeLlama manages requests around Ollama; Ollama runs inference. |
101
- | Verification | The calling agent verifies answers against the task and returned evidence. |
102
-
103
- Describe model eligibility, verification controls, and measured workload performance. Describe
104
- CPU/GPU overlap as a supported workload arrangement that needs measurement on
105
- the target machine. Local inference consumes hardware, memory, power, and time.
106
-
107
- The name refers to reducing reliance on metered inference. Models are not restricted to the Meta
108
- Llama family: FreeLlama works with eligible models exposed by Ollama.
109
-
110
- ## Evidence and boundaries
111
-
112
- The [findings report](dev/FINDINGS_AND_POSITIONING.md) records dated assessments and comparisons.
113
- [Benchmarks](../benchmark/README.md) separate model correctness, adapter behavior, and hardware
114
- validation. Historical measurements describe their declared model, machine, and workload.
115
-
116
- Managed tasks are non-streaming; raw Ollama passthrough retains upstream streaming behavior.
117
- Scopes and deferred jobs are process-local. A scope is history, a session is affinity, and a warm
118
- model is residency; none is a tenant credential or an engine-cache snapshot.
119
-
120
- FreeLlama targets one operator or a trusted team. Use the [production runbook](PRODUCTION.md) for
121
- authentication, remote access, persistence, and recovery.
@@ -1,55 +0,0 @@
1
- # ADR: Resource-aware backend routing
2
-
3
- Status: Accepted and implemented
4
-
5
- ## Context
6
-
7
- FreeLlama can isolate explicitly assigned helper models in a second Ollama process. Live trials
8
- proved that CPU and GPU requests can overlap, but exact operator assignment alone was too rigid for
9
- agents, and one global admission pool can let GPU work starve a CPU helper. Unconstrained
10
- automatic migration is unsafe because capability, quality, session, and memory constraints
11
- must continue to win.
12
-
13
- ## Decision
14
-
15
- Keep backend eligibility operator-owned and add three bounded controls:
16
-
17
- 1. Callers may send `auto`, `prefer_cpu`, or `prefer_gpu`; this is a fallback-capable hint.
18
- 2. GPU and CPU backends own independent weighted admission pools and transition locks.
19
- 3. `auto` can use task-specific normalized warm latency after three samples exist on both backends
20
- and one backend has more than a 10% advantage.
21
-
22
- Explicit models and session affinity override the hint. Quality routing never follows latency.
23
- Generation normalizes by output tokens; embeddings normalize by input tokens. Cold-load duration
24
- does not enter feedback. Raw Ollama passthrough remains byte-transparent to the primary upstream.
25
- Verified feedback is stored in a bounded, versioned snapshot and replaced atomically. A corrupt or
26
- unsupported snapshot fails startup instead of silently changing learned routing behavior.
27
-
28
- The contract is hardware-neutral: the operator supplies loopback endpoints and exact CPU-eligible
29
- tags, while FreeLlama discovers host capacity and observes Ollama placement. The measured 48 GB Mac
30
- result is validation evidence, not a routing constant. Device-visibility variables remain
31
- Ollama-process configuration because NVIDIA, ROCm, Vulkan, Metal, and CPU-only hosts differ.
32
-
33
- ## Alternatives
34
-
35
- | Alternative | Decision | Reason |
36
- |---|---|---|
37
- | Exact assignment only | Rejected | Safe but too rigid for agents and blind to runtime capacity |
38
- | Let agents supply an upstream or `num_gpu` | Rejected | Bypasses operator eligibility and compatibility boundaries |
39
- | Rewrite every raw Ollama request | Rejected | Breaks passthrough semantics and surprises existing clients |
40
- | Persist every raw runtime event | Rejected | Unbounded traces add privacy and storage risk; persist only aggregate prompt-free feedback |
41
- | Live memory/thermal controller | Deferred | No stable sensor and held-out workload yet justify it |
42
-
43
- ## Verification contract
44
-
45
- - Preview returns placement, upstream, preference satisfaction, reason, and admission capacity.
46
- - Two samples per backend do not change `auto`; the third makes the comparison decision-ready.
47
- - Explicit model and session pins do not move.
48
- - A one-unit GPU pool and one-unit CPU pool admit one task on each concurrently.
49
- - CPU-managed requests contain `options.num_gpu: 0`; raw `/api/*` bodies are unchanged.
50
- - Health exposes both pools and per-task feedback counts.
51
- - Restart reloads the same bounded feedback counts; an unsupported schema refuses startup.
52
-
53
- Rollback is configuration-only for callers: omit the preference or use `auto`. Operators can remove
54
- the CPU backend to restore a single-primary layout. Reverting independent pools requires a code
55
- rollback and is not recommended because it reintroduces cross-backend starvation.