bima-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.
bima_mcp-0.1.0/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Gabriel Mahia / AI Kung Fu LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files, to deal in the Software without restriction.
6
+
7
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND.
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: bima-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Kenya insurance intelligence โ€” NHIF, parametric crop risk, microinsurance comparison
5
+ Author-email: Gabriel Mahia <contact@aikungfu.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/gabrielmahia/bima-mcp
8
+ Project-URL: Repository, https://github.com/gabrielmahia/bima-mcp
9
+ Project-URL: Issues, https://github.com/gabrielmahia/bima-mcp/issues
10
+ Keywords: mcp,insurance,kenya,africa,nhif,parametric,microinsurance,bima
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: fastmcp>=2.0.0
21
+ Dynamic: license-file
22
+
23
+ # ๐Ÿ›ก๏ธ bima-mcp โ€” Kenya Insurance Intelligence MCP Server
24
+
25
+ **First insurance intelligence MCP server for East Africa.**
26
+
27
+ Exposes Kenya insurance data, NHIF coverage analysis, parametric crop risk scoring,
28
+ and microinsurance comparison through the Model Context Protocol.
29
+
30
+ ## Why Insurance Infrastructure Matters
31
+
32
+ In mature economies, insurance is invisible infrastructure โ€” it enables risk-taking by
33
+ capping downside. A farmer plants a new crop because crop insurance limits loss.
34
+ A parent starts a business because health insurance protects the family.
35
+ Without this floor, the rational choice is perpetual caution.
36
+
37
+ Kenya's insurance penetration: **2.3% of GDP** vs 8โ€“11% in developed markets.
38
+ The gap is not cultural โ€” it is the cost of distribution, claims verification,
39
+ and actuarial data. All three can be compressed by technology.
40
+
41
+ ## Tools
42
+
43
+ | Tool | What it does |
44
+ |------|-------------|
45
+ | `kenya_insurance_products` | List IRA-registered products by type (health, life, crop, device) |
46
+ | `nhif_coverage_query` | Query NHIF benefits by hospital tier and procedure type |
47
+ | `premium_estimate` | Estimate monthly premiums for any coverage type + income bracket |
48
+ | `parametric_crop_risk` | NDMA-based crop insurance risk for smallholder farmers |
49
+ | `compare_microinsurance` | Compare affordable products by target group and budget |
50
+ | `community_pool_calculator` | Size a chama pooled insurance arrangement |
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ pip install bima-mcp # coming soon to PyPI
56
+ bima-mcp # starts the MCP server on stdio
57
+ ```
58
+
59
+ ## Claude Desktop Integration
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "bima-mcp": {
65
+ "command": "bima-mcp"
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Use Cases
72
+
73
+ - **Farmers**: "What crop insurance do I need for my 2-acre maize farm in Nakuru?"
74
+ - **Informal workers**: "What NHIF tier 4 inpatient coverage do I get for KES 500/month?"
75
+ - **Chama treasurers**: "How do I set up pooled hospitalization cover for 25 members?"
76
+ - **Researchers**: "Compare parametric crop insurance risk across Kenya counties"
77
+
78
+ ## Research Basis
79
+
80
+ - ACRE Africa Parametric Crop Insurance Methodology (2023)
81
+ - Kenya IRA Annual Report 2024
82
+ - World Bank Insurance Primer for Low-Income Markets (2023)
83
+ - NDMA County Drought Monitoring Reports
84
+
85
+ ## โš ๏ธ Disclaimers
86
+
87
+ > DEMO data โ€” not real insurance products or binding quotes.
88
+ > Not affiliated with NHIF, IRA, or any insurance provider.
89
+ > Always consult a licensed IRA-registered insurance agent for actual products.
90
+ > Kenya IRA: ira.go.ke
91
+
92
+ ---
93
+ *ยฉ 2026 Gabriel Mahia / AI Kung Fu LLC ยท MIT License*
@@ -0,0 +1,71 @@
1
+ # ๐Ÿ›ก๏ธ bima-mcp โ€” Kenya Insurance Intelligence MCP Server
2
+
3
+ **First insurance intelligence MCP server for East Africa.**
4
+
5
+ Exposes Kenya insurance data, NHIF coverage analysis, parametric crop risk scoring,
6
+ and microinsurance comparison through the Model Context Protocol.
7
+
8
+ ## Why Insurance Infrastructure Matters
9
+
10
+ In mature economies, insurance is invisible infrastructure โ€” it enables risk-taking by
11
+ capping downside. A farmer plants a new crop because crop insurance limits loss.
12
+ A parent starts a business because health insurance protects the family.
13
+ Without this floor, the rational choice is perpetual caution.
14
+
15
+ Kenya's insurance penetration: **2.3% of GDP** vs 8โ€“11% in developed markets.
16
+ The gap is not cultural โ€” it is the cost of distribution, claims verification,
17
+ and actuarial data. All three can be compressed by technology.
18
+
19
+ ## Tools
20
+
21
+ | Tool | What it does |
22
+ |------|-------------|
23
+ | `kenya_insurance_products` | List IRA-registered products by type (health, life, crop, device) |
24
+ | `nhif_coverage_query` | Query NHIF benefits by hospital tier and procedure type |
25
+ | `premium_estimate` | Estimate monthly premiums for any coverage type + income bracket |
26
+ | `parametric_crop_risk` | NDMA-based crop insurance risk for smallholder farmers |
27
+ | `compare_microinsurance` | Compare affordable products by target group and budget |
28
+ | `community_pool_calculator` | Size a chama pooled insurance arrangement |
29
+
30
+ ## Quick Start
31
+
32
+ ```bash
33
+ pip install bima-mcp # coming soon to PyPI
34
+ bima-mcp # starts the MCP server on stdio
35
+ ```
36
+
37
+ ## Claude Desktop Integration
38
+
39
+ ```json
40
+ {
41
+ "mcpServers": {
42
+ "bima-mcp": {
43
+ "command": "bima-mcp"
44
+ }
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Use Cases
50
+
51
+ - **Farmers**: "What crop insurance do I need for my 2-acre maize farm in Nakuru?"
52
+ - **Informal workers**: "What NHIF tier 4 inpatient coverage do I get for KES 500/month?"
53
+ - **Chama treasurers**: "How do I set up pooled hospitalization cover for 25 members?"
54
+ - **Researchers**: "Compare parametric crop insurance risk across Kenya counties"
55
+
56
+ ## Research Basis
57
+
58
+ - ACRE Africa Parametric Crop Insurance Methodology (2023)
59
+ - Kenya IRA Annual Report 2024
60
+ - World Bank Insurance Primer for Low-Income Markets (2023)
61
+ - NDMA County Drought Monitoring Reports
62
+
63
+ ## โš ๏ธ Disclaimers
64
+
65
+ > DEMO data โ€” not real insurance products or binding quotes.
66
+ > Not affiliated with NHIF, IRA, or any insurance provider.
67
+ > Always consult a licensed IRA-registered insurance agent for actual products.
68
+ > Kenya IRA: ira.go.ke
69
+
70
+ ---
71
+ *ยฉ 2026 Gabriel Mahia / AI Kung Fu LLC ยท MIT License*
@@ -0,0 +1,33 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "bima-mcp"
7
+ version = "0.1.0"
8
+ description = "MCP server for Kenya insurance intelligence โ€” NHIF, parametric crop risk, microinsurance comparison"
9
+ authors = [{name = "Gabriel Mahia", email = "contact@aikungfu.dev"}]
10
+ license = {text = "MIT"}
11
+ readme = "README.md"
12
+ requires-python = ">=3.9"
13
+ keywords = ["mcp", "insurance", "kenya", "africa", "nhif", "parametric", "microinsurance", "bima"]
14
+ classifiers = [
15
+ "Development Status :: 4 - Beta",
16
+ "Intended Audience :: Developers",
17
+ "License :: OSI Approved :: MIT License",
18
+ "Programming Language :: Python :: 3",
19
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
20
+ "Topic :: Office/Business :: Financial",
21
+ ]
22
+ dependencies = ["fastmcp>=2.0.0"]
23
+
24
+ [project.urls]
25
+ Homepage = "https://github.com/gabrielmahia/bima-mcp"
26
+ Repository = "https://github.com/gabrielmahia/bima-mcp"
27
+ Issues = "https://github.com/gabrielmahia/bima-mcp/issues"
28
+
29
+ [project.scripts]
30
+ bima-mcp = "bima_mcp.main:main"
31
+
32
+ [tool.setuptools.packages.find]
33
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,2 @@
1
+ """bima-mcp: Kenya Insurance Intelligence MCP Server"""
2
+ __version__ = "0.1.0"
@@ -0,0 +1,500 @@
1
+ #!/usr/bin/env python3
2
+ # bima-mcp โ€” Kenya Insurance Intelligence MCP Server
3
+ # ยฉ 2026 Gabriel Mahia / AI Kung Fu LLC โ€” MIT License
4
+ #
5
+ # Western parallel: Lemonade API, Root Insurance, Policygenius, ACRE Africa parametric methodology
6
+ # East Africa context: Insurance penetration ~2.3% GDP vs 8-11% in developed markets
7
+ # Source: Kenya IRA Annual Report 2024, World Bank FinSAT database
8
+ #
9
+ # TRUST INTEGRITY: All data is DEMO / synthetic unless explicitly marked otherwise.
10
+ # No real insurance products, premiums, or coverages are implied.
11
+ # Always consult a licensed IRA-registered insurance agent for actual products.
12
+ # =============================================================================
13
+
14
+ from __future__ import annotations
15
+ import json
16
+ import datetime
17
+ from typing import Annotated
18
+ from fastmcp import FastMCP
19
+
20
+ mcp = FastMCP(
21
+ name="bima-mcp",
22
+ instructions="""Kenya insurance intelligence MCP server.
23
+ Provides tools for exploring insurance products, NHIF coverage, premium estimation,
24
+ parametric crop risk, and microinsurance comparison for the East African market.
25
+
26
+ IMPORTANT: All data is DEMO/synthetic for educational purposes.
27
+ Not affiliated with any insurer or the Kenya IRA.
28
+ Always consult a licensed insurance agent for actual products and pricing.
29
+ """,
30
+ )
31
+
32
+ # โ”€โ”€ DEMO DATASET: Kenya Insurance Products โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
33
+ _PRODUCTS = [
34
+ {
35
+ "id": "NHIF-001", "type": "health", "provider": "NHIF (National Hospital Insurance Fund)",
36
+ "name": "NHIF Individual Cover", "monthly_premium_kes": 500,
37
+ "coverage": "Inpatient + Outpatient (select facilities)", "regulatory_body": "NHIF Board",
38
+ "mpesa_paybill": "200222", "target": "Employed individuals (PAYE deduction)",
39
+ "source": "DEMO โ€” Synthetic. Reference: nhif.or.ke",
40
+ },
41
+ {
42
+ "id": "NHIF-002", "type": "health", "provider": "NHIF",
43
+ "name": "NHIF Voluntary Cover", "monthly_premium_kes": 500,
44
+ "coverage": "Inpatient (Level 2โ€“6 hospitals)", "regulatory_body": "NHIF Board",
45
+ "mpesa_paybill": "200222", "target": "Self-employed, informal sector",
46
+ "source": "DEMO โ€” Synthetic. Reference: nhif.or.ke",
47
+ },
48
+ {
49
+ "id": "MBELE-001", "type": "life", "provider": "Jubilee Life Insurance",
50
+ "name": "Mbele Savings Plan", "monthly_premium_kes": 1000,
51
+ "coverage": "Life cover + savings maturity benefit", "regulatory_body": "Kenya IRA",
52
+ "mpesa_paybill": "220000", "target": "Working adults 18โ€“60",
53
+ "source": "DEMO โ€” Synthetic. Reference: jubaileealife.com",
54
+ },
55
+ {
56
+ "id": "PULA-001", "type": "crop", "provider": "Pula Advisors",
57
+ "name": "Pula Smallholder Crop Insurance", "monthly_premium_kes": 0,
58
+ "coverage": "Area-based yield index โ€” pays if county yield < trigger",
59
+ "regulatory_body": "Kenya IRA", "mpesa_paybill": "N/A",
60
+ "target": "Smallholder farmers (KALRO partnership)", "min_acreage": 0.1,
61
+ "source": "DEMO โ€” Synthetic. Reference: pula-advisors.com",
62
+ },
63
+ {
64
+ "id": "ACRE-001", "type": "crop", "provider": "ACRE Africa",
65
+ "name": "ACRE Maize Cover", "monthly_premium_kes": 0,
66
+ "coverage": "Satellite NDVI + rainfall index trigger, pays via M-PESA",
67
+ "regulatory_body": "Kenya IRA", "mpesa_paybill": "N/A",
68
+ "target": "Maize smallholders, bundled with input loans",
69
+ "source": "DEMO โ€” Synthetic. Reference: acreafrica.com",
70
+ },
71
+ {
72
+ "id": "TURACO-001", "type": "health", "provider": "Turaco",
73
+ "name": "Turaco Afya Cover", "monthly_premium_kes": 200,
74
+ "coverage": "Inpatient hospitalization up to KES 100,000",
75
+ "regulatory_body": "Kenya IRA", "mpesa_paybill": "4018228",
76
+ "target": "Informal workers, gig economy", "min_age": 18, "max_age": 65,
77
+ "source": "DEMO โ€” Synthetic. Reference: turaco.io",
78
+ },
79
+ {
80
+ "id": "BIMA-001", "type": "device", "provider": "Airtel x Jubilee",
81
+ "name": "Bima ya Simu (Device Insurance)", "monthly_premium_kes": 100,
82
+ "coverage": "Smartphone theft/damage up to device value", "regulatory_body": "Kenya IRA",
83
+ "mpesa_paybill": "N/A", "target": "Mobile phone owners",
84
+ "source": "DEMO โ€” Synthetic. Based on bundled airtime insurance models",
85
+ },
86
+ ]
87
+
88
+ # โ”€โ”€ DEMO: NDMA Drought History by County โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€
89
+ _NDMA_DROUGHT = {
90
+ "Turkana": {"drought_frequency_pct": 85, "phase": "Crisis", "last_drought": "2023"},
91
+ "Marsabit": {"drought_frequency_pct": 75, "phase": "Emergency", "last_drought": "2022"},
92
+ "Mandera": {"drought_frequency_pct": 80, "phase": "Crisis", "last_drought": "2023"},
93
+ "Wajir": {"drought_frequency_pct": 78, "phase": "Crisis", "last_drought": "2023"},
94
+ "Garissa": {"drought_frequency_pct": 72, "phase": "Alert", "last_drought": "2022"},
95
+ "Isiolo": {"drought_frequency_pct": 65, "phase": "Alert", "last_drought": "2022"},
96
+ "Kajiado": {"drought_frequency_pct": 45, "phase": "Stressed", "last_drought": "2021"},
97
+ "Machakos": {"drought_frequency_pct": 40, "phase": "Stressed", "last_drought": "2021"},
98
+ "Kitui": {"drought_frequency_pct": 55, "phase": "Alert", "last_drought": "2022"},
99
+ "Makueni": {"drought_frequency_pct": 50, "phase": "Stressed", "last_drought": "2021"},
100
+ "Nairobi": {"drought_frequency_pct": 10, "phase": "Minimal", "last_drought": "2009"},
101
+ "Kiambu": {"drought_frequency_pct": 15, "phase": "Minimal", "last_drought": "2011"},
102
+ "Nakuru": {"drought_frequency_pct": 25, "phase": "Stressed", "last_drought": "2019"},
103
+ "Kisumu": {"drought_frequency_pct": 20, "phase": "Minimal", "last_drought": "2016"},
104
+ "Mombasa": {"drought_frequency_pct": 18, "phase": "Minimal", "last_drought": "2017"},
105
+ "Uasin Gishu": {"drought_frequency_pct": 20, "phase": "Minimal", "last_drought": "2016"},
106
+ "Trans Nzoia": {"drought_frequency_pct": 15, "phase": "Minimal", "last_drought": "2014"},
107
+ "Nyandarua": {"drought_frequency_pct": 12, "phase": "Minimal", "last_drought": "2012"},
108
+ "Nyeri": {"drought_frequency_pct": 18, "phase": "Minimal", "last_drought": "2015"},
109
+ "Kakamega": {"drought_frequency_pct": 12, "phase": "Minimal", "last_drought": "2013"},
110
+ }
111
+
112
+ _CROP_RISK_MULTIPLIERS = {
113
+ "maize": 1.0, "beans": 0.9, "potatoes": 0.8, "wheat": 0.85, "sorghum": 0.7,
114
+ "millet": 0.65, "cassava": 0.6, "tea": 0.5, "coffee": 0.55, "cotton": 0.95,
115
+ }
116
+
117
+ def _audit(tool: str, params: dict, result: str):
118
+ ts = datetime.datetime.utcnow().isoformat()
119
+ entry = {"ts": ts, "tool": tool, "params": params, "result": result, "source": "bima-mcp"}
120
+ return entry
121
+
122
+
123
+ @mcp.tool(
124
+ description=(
125
+ "List Kenya insurance product categories and representative products. "
126
+ "Returns DEMO synthetic data for educational/research purposes. "
127
+ "Not real insurance products or binding quotes."
128
+ ),
129
+ annotations={"readOnlyHint": True},
130
+ )
131
+ def kenya_insurance_products(
132
+ product_type: Annotated[str, "Filter by type: health, life, crop, device, or 'all'"] = "all",
133
+ ) -> dict:
134
+ _audit("kenya_insurance_products", {"product_type": product_type}, "OK")
135
+ products = _PRODUCTS if product_type == "all" else [
136
+ p for p in _PRODUCTS if p.get("type") == product_type.lower()
137
+ ]
138
+ return {
139
+ "status": "OK",
140
+ "products": products,
141
+ "count": len(products),
142
+ "note": "DEMO โ€” Synthetic data for educational purposes. Verify at ira.go.ke before advising clients.",
143
+ "regulatory_body": "Insurance Regulatory Authority (IRA) Kenya โ€” ira.go.ke",
144
+ "source": "bima-mcp synthetic dataset, 2026. Reference: IRA Annual Report 2024, NHIF, ACRE Africa.",
145
+ }
146
+
147
+
148
+ @mcp.tool(
149
+ description=(
150
+ "Query NHIF (National Hospital Insurance Fund) coverage details by hospital tier and procedure. "
151
+ "NHIF is Kenya's state health insurer, analogous to Medicare in the US or NHS in the UK. "
152
+ "DEMO data โ€” verify at nhif.or.ke."
153
+ ),
154
+ annotations={"readOnlyHint": True},
155
+ )
156
+ def nhif_coverage_query(
157
+ tier: Annotated[str, "Hospital tier: level_2, level_3, level_4, level_5, level_6"] = "level_4",
158
+ procedure_type: Annotated[str, "Procedure type: inpatient, outpatient, maternity, renal, cancer, mental_health"] = "inpatient",
159
+ ) -> dict:
160
+ _audit("nhif_coverage_query", {"tier": tier, "procedure_type": procedure_type}, "OK")
161
+
162
+ NHIF_BENEFITS = {
163
+ "level_2": {"inpatient": 1800, "outpatient": 0, "maternity": 2500, "renal": 0, "cancer": 0},
164
+ "level_3": {"inpatient": 2500, "outpatient": 0, "maternity": 5000, "renal": 2500, "cancer": 0},
165
+ "level_4": {"inpatient": 8000, "outpatient": 0, "maternity": 8000, "renal": 7000, "cancer": 0},
166
+ "level_5": {"inpatient": 20000, "outpatient": 0, "maternity": 20000, "renal": 15000, "cancer": 20000},
167
+ "level_6": {"inpatient": 100000, "outpatient": 0, "maternity": 100000, "renal": 50000, "cancer": 100000},
168
+ }
169
+
170
+ tier_data = NHIF_BENEFITS.get(tier.lower(), NHIF_BENEFITS["level_4"])
171
+ benefit = tier_data.get(procedure_type.lower(), 0)
172
+
173
+ return {
174
+ "status": "OK",
175
+ "tier": tier,
176
+ "procedure_type": procedure_type,
177
+ "nhif_benefit_kes_per_day": benefit if benefit > 0 else "Not covered at this tier",
178
+ "coverage_notes": {
179
+ "outpatient": "NHIF outpatient only available at accredited facilities with Super Cover (SHIF 2024)",
180
+ "renal": "Dialysis covered from Level 3 upward",
181
+ "mental_health": "Limited coverage โ€” SHA 2024 expanding this",
182
+ "cancer": "Available at Level 5 and 6 (KNH, Aga Khan, Nairobi Hospital)",
183
+ },
184
+ "monthly_premium": {"employed": "KES 500 (PAYE deduction)", "self_employed": "KES 500 voluntary"},
185
+ "gap_analysis": {
186
+ "typical_inpatient_cost_kes": 15000 if tier == "level_4" else 50000,
187
+ "nhif_covers": f"KES {benefit:,}" if benefit > 0 else "Not covered",
188
+ "out_of_pocket_risk": f"KES {max(0, 15000 - benefit):,}+ at {tier}",
189
+ },
190
+ "note": "DEMO โ€” Synthetic data. Verify at nhif.or.ke. SHA (Social Health Authority) restructuring underway 2024.",
191
+ "source": "bima-mcp synthetic dataset. Reference: NHIF Benefits Schedule 2023.",
192
+ }
193
+
194
+
195
+ @mcp.tool(
196
+ description=(
197
+ "Estimate monthly insurance premium for a Kenya individual. "
198
+ "Covers health, life, crop, and device insurance types. "
199
+ "Western parallel: Online insurance quote engines (Policygenius, Lemonade). "
200
+ "DEMO estimation โ€” not a binding quote."
201
+ ),
202
+ annotations={"readOnlyHint": True},
203
+ )
204
+ def premium_estimate(
205
+ insurance_type: Annotated[str, "Type: health, life, crop, device"],
206
+ age: Annotated[int, "Age in years (18โ€“65)"],
207
+ monthly_income_kes: Annotated[int, "Monthly income in KES"],
208
+ county: Annotated[str, "Kenya county of residence"] = "Nairobi",
209
+ acreage: Annotated[float, "Farm acreage (crop insurance only)"] = 0.0,
210
+ crop: Annotated[str, "Crop type (crop insurance only)"] = "maize",
211
+ ) -> dict:
212
+ _audit("premium_estimate", {
213
+ "insurance_type": insurance_type, "age": age,
214
+ "monthly_income_kes": monthly_income_kes
215
+ }, "OK")
216
+
217
+ base_rates = {
218
+ "health": 0.03, # 3% of income, min KES 300
219
+ "life": 0.01, # 1% of income โ€” term life
220
+ "crop": 0.08, # 8% of season input cost (ACRE Africa benchmark)
221
+ "device": 0.025, # 2.5% of device value per month
222
+ }
223
+
224
+ est = 0
225
+ notes = []
226
+
227
+ if insurance_type == "health":
228
+ est = max(300, int(monthly_income_kes * base_rates["health"]))
229
+ est = min(est, 5000) # cap at KES 5,000 for basic health
230
+ notes = [
231
+ "NHIF minimum: KES 500/month covers inpatient only",
232
+ f"For income KES {monthly_income_kes:,}, private supplement ~KES {est:,}/month",
233
+ "Top-up cover from providers like Jubilee, AAR adds KES 1,000โ€“5,000",
234
+ ]
235
+ elif insurance_type == "life":
236
+ age_factor = 1.0 + max(0, (age - 35) * 0.03)
237
+ est = max(500, int(monthly_income_kes * base_rates["life"] * age_factor))
238
+ notes = [
239
+ f"Term life for age {age}: age loading factor {age_factor:.2f}x",
240
+ f"KES {monthly_income_kes * 12 * 5:,} sum assured (5ร— annual income rule)",
241
+ "ICEA Lion, Jubilee Life, Britam Life offer KES 500โ€“3,000/month term plans",
242
+ ]
243
+ elif insurance_type == "crop":
244
+ drought_data = _NDMA_DROUGHT.get(county, {"drought_frequency_pct": 30})
245
+ drought_pct = drought_data["drought_frequency_pct"]
246
+ crop_mult = _CROP_RISK_MULTIPLIERS.get(crop.lower(), 1.0)
247
+ input_cost_kes = acreage * 8000 # ~KES 8,000/acre input cost
248
+ est = int(input_cost_kes * base_rates["crop"] * (drought_pct / 50) * crop_mult)
249
+ notes = [
250
+ f"County drought frequency: {drought_pct}% ({county})",
251
+ f"Crop risk multiplier ({crop}): {crop_mult}x",
252
+ f"Estimated input cost: KES {input_cost_kes:,} for {acreage} acres",
253
+ f"ACRE Africa: pays via M-PESA when NDVI index drops below trigger",
254
+ ]
255
+ else: # device
256
+ device_value = max(5000, monthly_income_kes * 2)
257
+ est = int(device_value * base_rates["device"])
258
+ notes = [
259
+ f"Estimated device value: KES {device_value:,} (2ร— monthly income proxy)",
260
+ "Bundled insurance via Airtel/Safaricom: KES 100โ€“500/month",
261
+ ]
262
+
263
+ return {
264
+ "status": "OK",
265
+ "insurance_type": insurance_type,
266
+ "estimated_monthly_premium_kes": est,
267
+ "annual_premium_kes": est * 12,
268
+ "affordability_ratio": f"{est / monthly_income_kes * 100:.1f}% of income",
269
+ "notes": notes,
270
+ "note": "DEMO โ€” Rough estimation for educational purposes only. Not a binding quote. Consult an IRA-licensed broker.",
271
+ "source": "bima-mcp synthetic dataset. Reference: IRA 2024, ACRE Africa, World Bank Insurance Primer.",
272
+ }
273
+
274
+
275
+ @mcp.tool(
276
+ description=(
277
+ "Calculate parametric crop insurance risk for a Kenya smallholder farmer. "
278
+ "Based on ACRE Africa methodology: NDVI satellite index + NDMA drought history. "
279
+ "Western parallel: Root Insurance telematic scoring, Skywatch EasyCrop satellite insurance. "
280
+ "DEMO data โ€” actual payouts require enrollment with a licensed insurer."
281
+ ),
282
+ annotations={"readOnlyHint": True},
283
+ )
284
+ def parametric_crop_risk(
285
+ county: Annotated[str, "Kenya county name (e.g., Nakuru, Turkana, Machakos)"],
286
+ crop: Annotated[str, "Crop type: maize, beans, potatoes, wheat, sorghum, millet, cassava, tea, coffee"],
287
+ acreage: Annotated[float, "Farm size in acres"],
288
+ season: Annotated[str, "Farming season: long_rains (Mar-May) or short_rains (Oct-Dec)"] = "long_rains",
289
+ ) -> dict:
290
+ _audit("parametric_crop_risk", {"county": county, "crop": crop, "acreage": acreage}, "OK")
291
+
292
+ drought = _NDMA_DROUGHT.get(county, {"drought_frequency_pct": 30, "phase": "Minimal", "last_drought": "2020"})
293
+ crop_mult = _CROP_RISK_MULTIPLIERS.get(crop.lower(), 1.0)
294
+ drought_pct = drought["drought_frequency_pct"]
295
+
296
+ # Risk score: 0โ€“100
297
+ risk_score = min(100, int(drought_pct * crop_mult))
298
+
299
+ # Premium as % of input cost
300
+ input_cost = acreage * 8000 # KES 8,000/acre inputs (seeds, fertilizer, labor)
301
+ season_premium_kes = int(input_cost * 0.08 * (drought_pct / 100))
302
+
303
+ risk_category = (
304
+ "VERY HIGH" if risk_score > 65 else
305
+ "HIGH" if risk_score > 45 else
306
+ "MEDIUM" if risk_score > 25 else "LOW"
307
+ )
308
+
309
+ # Expected payout probability and value
310
+ payout_trigger = drought_pct > 40
311
+ expected_payout_kes = int(input_cost * 0.9 * (drought_pct / 100)) if payout_trigger else 0
312
+
313
+ return {
314
+ "status": "OK",
315
+ "county": county,
316
+ "crop": crop,
317
+ "acreage": acreage,
318
+ "season": season,
319
+ "risk_score": risk_score,
320
+ "risk_category": risk_category,
321
+ "drought_frequency_pct": drought_pct,
322
+ "current_ndma_phase": drought["phase"],
323
+ "last_major_drought": drought["last_drought"],
324
+ "economics": {
325
+ "estimated_input_cost_kes": input_cost,
326
+ "recommended_premium_kes": season_premium_kes,
327
+ "premium_as_pct_of_inputs": f"{season_premium_kes / input_cost * 100:.1f}%",
328
+ "payout_if_drought_triggers": f"KES {expected_payout_kes:,}",
329
+ "trigger_threshold": "County NDVI below 0.3 for >3 consecutive weeks OR <60% normal rainfall",
330
+ },
331
+ "payment_flow": {
332
+ "enrollment": "Via ACRE Africa app or Pula bundled with input loan",
333
+ "premium_payment": "M-PESA at start of planting season",
334
+ "payout_mechanism": "Automatic M-PESA transfer within 14 days of trigger confirmation",
335
+ "trigger_verification": "Satellite (Copernicus NDVI) + NDMA field assessment",
336
+ },
337
+ "note": "DEMO โ€” Synthetic risk model for educational purposes. Real parametric insurance requires enrollment with ACRE Africa or Pula Advisors. NDMA data: ndma.go.ke.",
338
+ "source": "bima-mcp synthetic dataset. Reference: ACRE Africa Methodology Paper 2023, NDMA County Reports.",
339
+ }
340
+
341
+
342
+ @mcp.tool(
343
+ description=(
344
+ "Compare available microinsurance options for low-income Kenyans. "
345
+ "Western parallel: Insurtech comparison platforms (Policygenius, The Zebra, NerdWallet Insurance). "
346
+ "East Africa context: 67% of Kenyans cannot afford conventional insurance premiums. "
347
+ "DEMO data โ€” verify products at ira.go.ke."
348
+ ),
349
+ annotations={"readOnlyHint": True},
350
+ )
351
+ def compare_microinsurance(
352
+ target_group: Annotated[str, "Target group: informal_worker, farmer, student, elderly, refugee"] = "informal_worker",
353
+ max_monthly_budget_kes: Annotated[int, "Maximum monthly premium budget in KES"] = 500,
354
+ ) -> dict:
355
+ _audit("compare_microinsurance", {"target_group": target_group, "budget": max_monthly_budget_kes}, "OK")
356
+
357
+ affordable = [p for p in _PRODUCTS if p.get("monthly_premium_kes", 0) <= max_monthly_budget_kes]
358
+
359
+ TARGET_GUIDANCE = {
360
+ "informal_worker": {
361
+ "priority": "Health (hospitalization) + device protection",
362
+ "risks": "Medical bills, phone theft/damage",
363
+ "best_fit": ["NHIF-002", "TURACO-001", "BIMA-001"],
364
+ },
365
+ "farmer": {
366
+ "priority": "Crop insurance + health",
367
+ "risks": "Drought, crop failure, illness during planting",
368
+ "best_fit": ["ACRE-001", "PULA-001", "NHIF-002"],
369
+ },
370
+ "student": {
371
+ "priority": "Device + small life cover",
372
+ "risks": "Phone loss, accidental death/disability",
373
+ "best_fit": ["BIMA-001", "MBELE-001"],
374
+ },
375
+ "elderly": {
376
+ "priority": "Health (inpatient) + last expense cover",
377
+ "risks": "High hospitalization costs, funeral expenses",
378
+ "best_fit": ["NHIF-002", "MBELE-001"],
379
+ },
380
+ "refugee": {
381
+ "priority": "Health โ€” limited options",
382
+ "risks": "Medical access, UNHCR may provide some coverage",
383
+ "best_fit": ["NHIF-002"],
384
+ },
385
+ }
386
+
387
+ guidance = TARGET_GUIDANCE.get(target_group, TARGET_GUIDANCE["informal_worker"])
388
+
389
+ return {
390
+ "status": "OK",
391
+ "target_group": target_group,
392
+ "max_budget_kes": max_monthly_budget_kes,
393
+ "affordable_products": [p for p in affordable if p["id"] in guidance["best_fit"]],
394
+ "priority_risks": guidance["risks"],
395
+ "coverage_priority": guidance["priority"],
396
+ "gap_analysis": {
397
+ "west_comparison": "In the US/UK, basic health + life cover costs $50โ€“150/month. In Kenya, NHIF covers less at KES 500/month โ€” ~$4.",
398
+ "what_kenbright_would_say": "The protection gap in Kenya is structural, not cultural. Technology can close it.",
399
+ "biggest_gap": "Disability/income protection insurance โ€” virtually absent in Kenya microinsurance market",
400
+ },
401
+ "how_to_enroll": {
402
+ "NHIF": "Walk into any Huduma Centre or go to nhif.or.ke",
403
+ "Turaco": "Download Turaco app or enroll via employer",
404
+ "ACRE Africa": "Enroll at planting time through agrivet shops or KALRO extension officers",
405
+ "Payment": "All accept M-PESA payments",
406
+ },
407
+ "note": "DEMO โ€” Synthetic comparison for educational purposes. Verify all products at ira.go.ke.",
408
+ "source": "bima-mcp synthetic dataset. Reference: IRA Kenya, Turaco, ACRE Africa public disclosures.",
409
+ }
410
+
411
+
412
+ @mcp.tool(
413
+ description=(
414
+ "Calculate parameters for a community group (chama) pooled insurance arrangement. "
415
+ "Western parallel: Fraternal benefit societies, mutual insurance companies, credit unions with insurance. "
416
+ "Kenya parallel: Chama savings groups can formalize as Micro Insurance Groups under IRA. "
417
+ "DEMO educational tool โ€” not a licensed insurance product."
418
+ ),
419
+ annotations={"readOnlyHint": True},
420
+ )
421
+ def community_pool_calculator(
422
+ group_size: Annotated[int, "Number of chama members (5โ€“200)"],
423
+ monthly_contribution_kes: Annotated[int, "Monthly contribution per member in KES"],
424
+ coverage_goal: Annotated[str, "Coverage goal: hospitalization, funeral, crop_loss, education"] = "hospitalization",
425
+ ) -> dict:
426
+ _audit("community_pool_calculator", {
427
+ "group_size": group_size, "monthly_contribution_kes": monthly_contribution_kes,
428
+ "coverage_goal": coverage_goal
429
+ }, "OK")
430
+
431
+ monthly_pool = group_size * monthly_contribution_kes
432
+ annual_pool = monthly_pool * 12
433
+ reserve_ratio = 0.3 # 30% reserve (standard for mutual insurance)
434
+ claims_pool = annual_pool * (1 - reserve_ratio)
435
+
436
+ BENEFIT_STRUCTURES = {
437
+ "hospitalization": {
438
+ "max_per_claim_kes": min(50000, claims_pool // max(1, group_size // 5)),
439
+ "waiting_period_days": 30,
440
+ "max_claims_per_year": 2,
441
+ "exclusions": "Pre-existing conditions in year 1, self-inflicted",
442
+ },
443
+ "funeral": {
444
+ "max_per_claim_kes": min(80000, claims_pool // max(1, group_size // 10)),
445
+ "waiting_period_days": 60,
446
+ "max_claims_per_year": 1,
447
+ "exclusions": "Suicide",
448
+ },
449
+ "crop_loss": {
450
+ "max_per_claim_kes": min(30000, claims_pool // max(1, group_size // 3)),
451
+ "waiting_period_days": 14,
452
+ "max_claims_per_year": 2,
453
+ "exclusions": "Self-caused damage, non-agricultural losses",
454
+ },
455
+ "education": {
456
+ "max_per_claim_kes": min(40000, claims_pool // max(1, group_size // 4)),
457
+ "waiting_period_days": 0,
458
+ "max_claims_per_year": 1,
459
+ "exclusions": "Non-registered institutions",
460
+ },
461
+ }
462
+
463
+ structure = BENEFIT_STRUCTURES.get(coverage_goal, BENEFIT_STRUCTURES["hospitalization"])
464
+
465
+ return {
466
+ "status": "OK",
467
+ "group_size": group_size,
468
+ "monthly_contribution_kes": monthly_contribution_kes,
469
+ "coverage_goal": coverage_goal,
470
+ "pool_economics": {
471
+ "monthly_pool_kes": monthly_pool,
472
+ "annual_pool_kes": annual_pool,
473
+ "reserve_fund_kes": int(annual_pool * reserve_ratio),
474
+ "available_for_claims_kes": int(claims_pool),
475
+ },
476
+ "suggested_benefit_structure": structure,
477
+ "sustainability_check": {
478
+ "viable": group_size >= 10 and monthly_pool >= 5000,
479
+ "note": "IRA recommends minimum 10 members and KES 5,000/month pool for sustainability",
480
+ "actuarial_warning": "Group must track claims history and adjust contributions annually",
481
+ },
482
+ "formalization_path": {
483
+ "step_1": "Register as a chama at Ministry of Public Service, Gender, Senior Citizens Affairs",
484
+ "step_2": "Open a group M-PESA Paybill or business account",
485
+ "step_3": "Draft a constitution with claims committee and dispute resolution",
486
+ "step_4": "After 2 years of history, apply for IRA Micro Insurance License",
487
+ "ira_contact": "ira.go.ke / +254 20 499 0000",
488
+ },
489
+ "western_parallel": "Fraternal benefit societies in the US (e.g., Mutual of Omaha origins) started as community pooling arrangements in the 1800s.",
490
+ "note": "DEMO โ€” Educational tool. Not a licensed insurance product. Consult IRA for formal registration.",
491
+ "source": "bima-mcp synthetic dataset. Reference: IRA Micro Insurance Framework 2022.",
492
+ }
493
+
494
+
495
+ def main():
496
+ mcp.run()
497
+
498
+
499
+ if __name__ == "__main__":
500
+ main()
@@ -0,0 +1,93 @@
1
+ Metadata-Version: 2.4
2
+ Name: bima-mcp
3
+ Version: 0.1.0
4
+ Summary: MCP server for Kenya insurance intelligence โ€” NHIF, parametric crop risk, microinsurance comparison
5
+ Author-email: Gabriel Mahia <contact@aikungfu.dev>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/gabrielmahia/bima-mcp
8
+ Project-URL: Repository, https://github.com/gabrielmahia/bima-mcp
9
+ Project-URL: Issues, https://github.com/gabrielmahia/bima-mcp/issues
10
+ Keywords: mcp,insurance,kenya,africa,nhif,parametric,microinsurance,bima
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
16
+ Classifier: Topic :: Office/Business :: Financial
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: fastmcp>=2.0.0
21
+ Dynamic: license-file
22
+
23
+ # ๐Ÿ›ก๏ธ bima-mcp โ€” Kenya Insurance Intelligence MCP Server
24
+
25
+ **First insurance intelligence MCP server for East Africa.**
26
+
27
+ Exposes Kenya insurance data, NHIF coverage analysis, parametric crop risk scoring,
28
+ and microinsurance comparison through the Model Context Protocol.
29
+
30
+ ## Why Insurance Infrastructure Matters
31
+
32
+ In mature economies, insurance is invisible infrastructure โ€” it enables risk-taking by
33
+ capping downside. A farmer plants a new crop because crop insurance limits loss.
34
+ A parent starts a business because health insurance protects the family.
35
+ Without this floor, the rational choice is perpetual caution.
36
+
37
+ Kenya's insurance penetration: **2.3% of GDP** vs 8โ€“11% in developed markets.
38
+ The gap is not cultural โ€” it is the cost of distribution, claims verification,
39
+ and actuarial data. All three can be compressed by technology.
40
+
41
+ ## Tools
42
+
43
+ | Tool | What it does |
44
+ |------|-------------|
45
+ | `kenya_insurance_products` | List IRA-registered products by type (health, life, crop, device) |
46
+ | `nhif_coverage_query` | Query NHIF benefits by hospital tier and procedure type |
47
+ | `premium_estimate` | Estimate monthly premiums for any coverage type + income bracket |
48
+ | `parametric_crop_risk` | NDMA-based crop insurance risk for smallholder farmers |
49
+ | `compare_microinsurance` | Compare affordable products by target group and budget |
50
+ | `community_pool_calculator` | Size a chama pooled insurance arrangement |
51
+
52
+ ## Quick Start
53
+
54
+ ```bash
55
+ pip install bima-mcp # coming soon to PyPI
56
+ bima-mcp # starts the MCP server on stdio
57
+ ```
58
+
59
+ ## Claude Desktop Integration
60
+
61
+ ```json
62
+ {
63
+ "mcpServers": {
64
+ "bima-mcp": {
65
+ "command": "bima-mcp"
66
+ }
67
+ }
68
+ }
69
+ ```
70
+
71
+ ## Use Cases
72
+
73
+ - **Farmers**: "What crop insurance do I need for my 2-acre maize farm in Nakuru?"
74
+ - **Informal workers**: "What NHIF tier 4 inpatient coverage do I get for KES 500/month?"
75
+ - **Chama treasurers**: "How do I set up pooled hospitalization cover for 25 members?"
76
+ - **Researchers**: "Compare parametric crop insurance risk across Kenya counties"
77
+
78
+ ## Research Basis
79
+
80
+ - ACRE Africa Parametric Crop Insurance Methodology (2023)
81
+ - Kenya IRA Annual Report 2024
82
+ - World Bank Insurance Primer for Low-Income Markets (2023)
83
+ - NDMA County Drought Monitoring Reports
84
+
85
+ ## โš ๏ธ Disclaimers
86
+
87
+ > DEMO data โ€” not real insurance products or binding quotes.
88
+ > Not affiliated with NHIF, IRA, or any insurance provider.
89
+ > Always consult a licensed IRA-registered insurance agent for actual products.
90
+ > Kenya IRA: ira.go.ke
91
+
92
+ ---
93
+ *ยฉ 2026 Gabriel Mahia / AI Kung Fu LLC ยท MIT License*
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/bima_mcp/__init__.py
5
+ src/bima_mcp/main.py
6
+ src/bima_mcp.egg-info/PKG-INFO
7
+ src/bima_mcp.egg-info/SOURCES.txt
8
+ src/bima_mcp.egg-info/dependency_links.txt
9
+ src/bima_mcp.egg-info/entry_points.txt
10
+ src/bima_mcp.egg-info/requires.txt
11
+ src/bima_mcp.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ bima-mcp = bima_mcp.main:main
@@ -0,0 +1 @@
1
+ fastmcp>=2.0.0
@@ -0,0 +1 @@
1
+ bima_mcp