offline-mcp 0.1.0__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.
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: offline-mcp
3
+ Version: 0.1.0
4
+ Summary: Local AI inference for East Africa — Ollama, open weights, degraded-mode fallbacks. 6 tools. Thesis
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastmcp>=0.9
9
+
10
+ # offline-mcp
11
+
12
+ > Local AI inference infrastructure — Ollama wrapper, open weights directory, degraded-mode guide for East Africa.
13
+
14
+ [![PyPI](https://img.shields.io/badge/PyPI-v0.1.0-blue?logo=pypi)](https://pypi.org/project/offline-mcp/)
15
+ [![Thesis Layer](https://img.shields.io/badge/Thesis_Layer-L4_Offline_AI-red)](https://gabrielmahia.github.io/nairobi-stack)
16
+
17
+ **Why:** Never assume OpenAI survives, Anthropic stays accessible, or export controls disappear.
18
+ This matters more in Africa than anywhere else.
19
+
20
+ **1st world equivalent:** Ollama, LLaMA, Mistral local deployment
21
+
22
+ ## Install
23
+ ```bash
24
+ pip install offline-mcp
25
+ ```
26
+
27
+ ## Tools (6)
28
+ | Tool | Description |
29
+ |------|-------------|
30
+ | `check_ollama_status` | Check if Ollama is running locally and list available models |
31
+ | `run_local_inference` | Run a prompt through a local Ollama model |
32
+ | `list_recommended_models` | Best open-weight models for East Africa use cases |
33
+ | `degraded_mode_guide` | 4-level degraded mode architecture for offline operation |
34
+ | `open_weights_directory` | Directory of open-weight models with Africa language support |
35
+ | `local_deployment_guide` | Deployment guide for laptop, server, Raspberry Pi, Android |
36
+
37
+ ## Context
38
+ Runs on a 50W solar panel + Raspberry Pi 4. Viable for rural Kenya clinics, schools, and community offices.
39
+
40
+ → [The Nairobi Stack](https://gabrielmahia.github.io/nairobi-stack)
41
+
42
+ ## License
43
+ MIT © Gabriel Mahia | contact@aikungfu.dev
@@ -0,0 +1,34 @@
1
+ # offline-mcp
2
+
3
+ > Local AI inference infrastructure — Ollama wrapper, open weights directory, degraded-mode guide for East Africa.
4
+
5
+ [![PyPI](https://img.shields.io/badge/PyPI-v0.1.0-blue?logo=pypi)](https://pypi.org/project/offline-mcp/)
6
+ [![Thesis Layer](https://img.shields.io/badge/Thesis_Layer-L4_Offline_AI-red)](https://gabrielmahia.github.io/nairobi-stack)
7
+
8
+ **Why:** Never assume OpenAI survives, Anthropic stays accessible, or export controls disappear.
9
+ This matters more in Africa than anywhere else.
10
+
11
+ **1st world equivalent:** Ollama, LLaMA, Mistral local deployment
12
+
13
+ ## Install
14
+ ```bash
15
+ pip install offline-mcp
16
+ ```
17
+
18
+ ## Tools (6)
19
+ | Tool | Description |
20
+ |------|-------------|
21
+ | `check_ollama_status` | Check if Ollama is running locally and list available models |
22
+ | `run_local_inference` | Run a prompt through a local Ollama model |
23
+ | `list_recommended_models` | Best open-weight models for East Africa use cases |
24
+ | `degraded_mode_guide` | 4-level degraded mode architecture for offline operation |
25
+ | `open_weights_directory` | Directory of open-weight models with Africa language support |
26
+ | `local_deployment_guide` | Deployment guide for laptop, server, Raspberry Pi, Android |
27
+
28
+ ## Context
29
+ Runs on a 50W solar panel + Raspberry Pi 4. Viable for rural Kenya clinics, schools, and community offices.
30
+
31
+ → [The Nairobi Stack](https://gabrielmahia.github.io/nairobi-stack)
32
+
33
+ ## License
34
+ MIT © Gabriel Mahia | contact@aikungfu.dev
@@ -0,0 +1,18 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "offline-mcp"
7
+ version = "0.1.0"
8
+ description = "Local AI inference for East Africa — Ollama, open weights, degraded-mode fallbacks. 6 tools. Thesis "
9
+ readme = "README.md"
10
+ license = { text = "MIT" }
11
+ requires-python = ">=3.10"
12
+ dependencies = ["fastmcp>=0.9"]
13
+
14
+ [project.scripts]
15
+ offline-mcp = "offline_mcp.server:mcp.run"
16
+
17
+ [tool.setuptools.packages.find]
18
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """offline-mcp v0.1.0"""
2
+ __version__ = "0.1.0"
@@ -0,0 +1,143 @@
1
+ """OfflineMCP — Local AI Inference Infrastructure (6 tools).
2
+ Layer 4: Never assume OpenAI survives or stays accessible.
3
+ Build for local inference, open weights, degraded operation.
4
+ """
5
+ from __future__ import annotations
6
+ from typing import Optional
7
+ from fastmcp import FastMCP
8
+ mcp = FastMCP(name="offline-mcp", description="Local AI inference infrastructure for Africa — Ollama, open weights, degraded-mode fallbacks. 6 tools.")
9
+
10
+ RECOMMENDED_MODELS = [
11
+ {"name": "llama3.2:3b", "size_gb": 2.0, "ram_gb": 4, "use_case": "General civic queries, fast responses",
12
+ "command": "ollama pull llama3.2:3b", "africa_fit": "Excellent for low-RAM devices"},
13
+ {"name": "mistral:7b", "size_gb": 4.1, "ram_gb": 8, "use_case": "Better quality civic reasoning",
14
+ "command": "ollama pull mistral:7b", "africa_fit": "Good for higher-spec devices"},
15
+ {"name": "phi3:mini", "size_gb": 2.3, "ram_gb": 4, "use_case": "Microsoft's compact model, efficient",
16
+ "command": "ollama pull phi3:mini", "africa_fit": "Good balance of speed and quality"},
17
+ {"name": "gemma2:2b", "size_gb": 1.6, "ram_gb": 3, "use_case": "Google's compact model",
18
+ "command": "ollama pull gemma2:2b", "africa_fit": "Best for very low RAM environments"},
19
+ {"name": "qwen2.5:3b", "size_gb": 1.9, "ram_gb": 4, "use_case": "Multilingual including Swahili",
20
+ "command": "ollama pull qwen2.5:3b", "africa_fit": "Strong multilingual support for Swahili"},
21
+ ]
22
+
23
+ @mcp.tool(name="check_ollama_status", description="Check if Ollama is running locally and list available models.")
24
+ def check_ollama_status() -> dict:
25
+ import urllib.request as ur
26
+ try:
27
+ req = ur.Request("http://localhost:11434/api/tags", headers={"User-Agent": "offline-mcp/1.0"})
28
+ with ur.urlopen(req, timeout=3) as r:
29
+ d = __import__("json").loads(r.read())
30
+ models = [m["name"] for m in d.get("models", [])]
31
+ return {"ollama_running": True, "models_available": models,
32
+ "count": len(models), "api_endpoint": "http://localhost:11434"}
33
+ except Exception as e:
34
+ return {"ollama_running": False, "error": str(e),
35
+ "install_guide": "curl https://ollama.ai/install.sh | sh",
36
+ "windows": "Download from ollama.ai/download",
37
+ "note": "Ollama provides local AI inference — no internet required once models are downloaded."}
38
+
39
+ @mcp.tool(name="run_local_inference", description="Run a prompt through a local Ollama model.")
40
+ def run_local_inference(prompt: str, model: Optional[str] = "llama3.2:3b") -> dict:
41
+ import urllib.request as ur
42
+ import json as js
43
+ data = js.dumps({"model": model, "prompt": prompt, "stream": False}).encode()
44
+ try:
45
+ req = ur.Request("http://localhost:11434/api/generate",
46
+ data=data, method="POST",
47
+ headers={"Content-Type":"application/json","User-Agent":"offline-mcp/1.0"})
48
+ with ur.urlopen(req, timeout=60) as r:
49
+ result = js.loads(r.read())
50
+ return {"status": "ok", "model": model, "response": result.get("response",""),
51
+ "offline": True, "tokens": result.get("eval_count", 0)}
52
+ except Exception as e:
53
+ return {"status": "error", "error": str(e),
54
+ "fallback": "Ollama not running. Start with: ollama serve",
55
+ "offline": False}
56
+
57
+ @mcp.tool(name="list_recommended_models", description="List recommended open-weight models for East Africa AI use cases.")
58
+ def list_recommended_models(use_case: Optional[str] = None, max_ram_gb: Optional[int] = None) -> dict:
59
+ models = RECOMMENDED_MODELS
60
+ if max_ram_gb:
61
+ models = [m for m in models if m["ram_gb"] <= max_ram_gb]
62
+ if use_case:
63
+ u = use_case.lower()
64
+ models = [m for m in models if u in m["use_case"].lower() or u in m["africa_fit"].lower()] or models
65
+ return {"source": "Ollama model registry", "recommended_for_africa": models,
66
+ "install_commands": [m["command"] for m in models],
67
+ "note": "All models run locally — no API key, no internet after download, no cost per query."}
68
+
69
+ @mcp.tool(name="degraded_mode_guide", description="Guide for operating AI systems when cloud connectivity fails.")
70
+ def degraded_mode_guide() -> dict:
71
+ return {"source": "AI-KungFU offline architecture guide",
72
+ "why_this_matters": "Kenya's connectivity is improving but remains unreliable outside Nairobi/Mombasa. Power outages, data costs, and latency can make cloud AI unusable.",
73
+ "degraded_mode_levels": {
74
+ "level_1_full_online": "Cloud AI + all MCP servers. Best quality. Requires stable internet.",
75
+ "level_2_local_llm": "Ollama local model + MCP servers. Good quality. Requires local setup.",
76
+ "level_3_cached_responses": "Pre-cached MCP responses + local model. Acceptable quality. Fully offline.",
77
+ "level_4_static_reference": "Static lookup tables and reference data only. No AI inference.",
78
+ },
79
+ "implementation": {
80
+ "step_1": "Install Ollama: curl https://ollama.ai/install.sh | sh",
81
+ "step_2": "Download a model: ollama pull llama3.2:3b (2GB)",
82
+ "step_3": "Test: ollama run llama3.2:3b 'Hello, what is the KRA PIN number format?'",
83
+ "step_4": "Configure MCP clients to use localhost:11434 as fallback",
84
+ },
85
+ "hardware_minimums": {"ram_gb": 4, "storage_gb": 5, "cpu": "Any modern CPU (no GPU required for 3B models)"},
86
+ "raspberry_pi": "Ollama runs on Raspberry Pi 4 (4GB RAM) — viable for rural offline deployments."}
87
+
88
+ @mcp.tool(name="open_weights_directory", description="Directory of open-weight AI models suitable for East Africa civic use cases.")
89
+ def open_weights_directory(use_case: Optional[str] = None) -> dict:
90
+ MODELS = [
91
+ {"name": "Llama 3.2 (Meta)", "sizes": ["1B", "3B", "11B"], "languages": ["en", "sw (limited)"],
92
+ "licence": "Llama 3.2 Community License (free for most uses)", "source": "ollama pull llama3.2"},
93
+ {"name": "Mistral 7B (Mistral AI)", "sizes": ["7B"], "languages": ["en", "fr"],
94
+ "licence": "Apache 2.0 — completely free and open", "source": "ollama pull mistral"},
95
+ {"name": "Gemma 2 (Google)", "sizes": ["2B", "9B", "27B"], "languages": ["en", "multilingual"],
96
+ "licence": "Gemma Terms of Use (free for most uses)", "source": "ollama pull gemma2:2b"},
97
+ {"name": "Qwen 2.5 (Alibaba)", "sizes": ["0.5B", "1.5B", "3B", "7B"], "languages": ["en", "zh", "sw (good)"],
98
+ "licence": "Apache 2.0", "source": "ollama pull qwen2.5:3b"},
99
+ {"name": "Aya Expanse (Cohere for AI)", "sizes": ["8B", "32B"], "languages": ["101 languages including sw"],
100
+ "licence": "CC BY-NC 4.0", "source": "huggingface.co/CohereForAI/aya-expanse-8b"},
101
+ {"name": "AfroLM / AfriBERTa (Masakhane)", "sizes": ["Various"], "languages": ["African languages"],
102
+ "licence": "Apache 2.0", "source": "huggingface.co/masakhane"},
103
+ ]
104
+ if use_case:
105
+ u = use_case.lower()
106
+ MODELS = [m for m in MODELS if u in str(m).lower()] or MODELS
107
+ return {"source": "HuggingFace, Ollama, Masakhane", "open_models": MODELS,
108
+ "africa_note": "Aya Expanse and Masakhane models have best African language support.",
109
+ "deployment": "All models above can be deployed locally via Ollama or llama.cpp."}
110
+
111
+ @mcp.tool(name="local_deployment_guide", description="Guide to deploying local AI inference on modest hardware in Kenya/East Africa.")
112
+ def local_deployment_guide(device_type: Optional[str] = "laptop") -> dict:
113
+ GUIDES = {
114
+ "laptop": {
115
+ "recommended_model": "llama3.2:3b or gemma2:2b",
116
+ "min_specs": "4GB RAM, 5GB storage, any modern CPU",
117
+ "setup": "1. Install Ollama (ollama.ai) 2. ollama pull llama3.2:3b 3. ollama serve",
118
+ "inference_speed": "~5-20 tokens/second on 4-core CPU",
119
+ },
120
+ "server": {
121
+ "recommended_model": "mistral:7b or llama3.1:8b",
122
+ "min_specs": "16GB RAM, 20GB storage, 4+ core CPU",
123
+ "setup": "Docker: docker run -p 11434:11434 ollama/ollama",
124
+ "inference_speed": "~20-50 tokens/second",
125
+ },
126
+ "raspberry_pi": {
127
+ "recommended_model": "gemma2:2b or llama3.2:1b",
128
+ "min_specs": "Raspberry Pi 4 with 4GB RAM, 16GB microSD",
129
+ "setup": "curl https://ollama.ai/install.sh | sh && ollama pull gemma2:2b",
130
+ "inference_speed": "~2-5 tokens/second (usable for simple queries)",
131
+ "power": "~15W — solar-compatible for off-grid deployments",
132
+ },
133
+ "android": {
134
+ "recommended_model": "llama3.2:1b via llama.cpp",
135
+ "app": "PocketPal AI (open source) or MLC Chat",
136
+ "min_specs": "Android phone with 6GB+ RAM",
137
+ "note": "Experimental but viable for very simple queries.",
138
+ },
139
+ }
140
+ guide = GUIDES.get(device_type.lower(), GUIDES["laptop"])
141
+ return {"source": "AI-KungFU offline deployment guide", "device_type": device_type,
142
+ **guide, "all_options": list(GUIDES.keys()),
143
+ "solar_note": "Ollama on Raspberry Pi can run on a 50W solar panel — viable for rural Kenya clinics, schools, and offices."}
@@ -0,0 +1,43 @@
1
+ Metadata-Version: 2.4
2
+ Name: offline-mcp
3
+ Version: 0.1.0
4
+ Summary: Local AI inference for East Africa — Ollama, open weights, degraded-mode fallbacks. 6 tools. Thesis
5
+ License: MIT
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastmcp>=0.9
9
+
10
+ # offline-mcp
11
+
12
+ > Local AI inference infrastructure — Ollama wrapper, open weights directory, degraded-mode guide for East Africa.
13
+
14
+ [![PyPI](https://img.shields.io/badge/PyPI-v0.1.0-blue?logo=pypi)](https://pypi.org/project/offline-mcp/)
15
+ [![Thesis Layer](https://img.shields.io/badge/Thesis_Layer-L4_Offline_AI-red)](https://gabrielmahia.github.io/nairobi-stack)
16
+
17
+ **Why:** Never assume OpenAI survives, Anthropic stays accessible, or export controls disappear.
18
+ This matters more in Africa than anywhere else.
19
+
20
+ **1st world equivalent:** Ollama, LLaMA, Mistral local deployment
21
+
22
+ ## Install
23
+ ```bash
24
+ pip install offline-mcp
25
+ ```
26
+
27
+ ## Tools (6)
28
+ | Tool | Description |
29
+ |------|-------------|
30
+ | `check_ollama_status` | Check if Ollama is running locally and list available models |
31
+ | `run_local_inference` | Run a prompt through a local Ollama model |
32
+ | `list_recommended_models` | Best open-weight models for East Africa use cases |
33
+ | `degraded_mode_guide` | 4-level degraded mode architecture for offline operation |
34
+ | `open_weights_directory` | Directory of open-weight models with Africa language support |
35
+ | `local_deployment_guide` | Deployment guide for laptop, server, Raspberry Pi, Android |
36
+
37
+ ## Context
38
+ Runs on a 50W solar panel + Raspberry Pi 4. Viable for rural Kenya clinics, schools, and community offices.
39
+
40
+ → [The Nairobi Stack](https://gabrielmahia.github.io/nairobi-stack)
41
+
42
+ ## License
43
+ MIT © Gabriel Mahia | contact@aikungfu.dev
@@ -0,0 +1,10 @@
1
+ README.md
2
+ pyproject.toml
3
+ src/offline_mcp/__init__.py
4
+ src/offline_mcp/server.py
5
+ src/offline_mcp.egg-info/PKG-INFO
6
+ src/offline_mcp.egg-info/SOURCES.txt
7
+ src/offline_mcp.egg-info/dependency_links.txt
8
+ src/offline_mcp.egg-info/entry_points.txt
9
+ src/offline_mcp.egg-info/requires.txt
10
+ src/offline_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ offline-mcp = offline_mcp.server:mcp.run
@@ -0,0 +1 @@
1
+ fastmcp>=0.9
@@ -0,0 +1 @@
1
+ offline_mcp