How to Build an Autonomous Government Benefit Discovery & Eligibility MCP Server for AI Assistants in Python
Millions of seniors, fixed-income families, and disabled individuals qualify for significant annual assistance across federal, state, and utility programs. Between the Supplemental Nutrition Assistance Program (SNAP) , Low-Income Home Energy Assistance Program (LIHEAP) , Medicare Extra Help (Part D

Millions of seniors, fixed-income families, and disabled individuals qualify for significant annual assistance across federal, state, and utility programs. Between the Supplemental Nutrition Assistance Program (SNAP), Low-Income Home Energy Assistance Program (LIHEAP), Medicare Extra Help (Part D Low-Income Subsidy), Supplemental Security Income (SSI), Lifeline/ACP broadband, and senior property tax freezes, eligible households frequently leave between $3,000 and $12,000+ USD per year completely unclaimed.
The root cause isn't a lack of need—it's administrative friction and extreme jurisdictional fragmentation:
In this tutorial, we will build BenefitFinder MCP —an autonomous Model Context Protocol (MCP) server in Python that equips AI assistants ( Claude Desktop, Cursor, Devin, Cline ) with deterministic eligibility calculation, state tax freeze discovery, non-conflicting portfolio stacking, and caseworker filing packet generation.
The server implements the official Model Context Protocol (MCP) JSON-RPC 2.0 stdio interface. LLMs connect directly to deterministic calculation tools without hallucinating income limits or statutory formulas:
┌────────────────────────────────────────────────────────┐ │ AI Assistant / Agent │ │ (Claude Desktop, Cursor, Devin, Cline) │ └───────────────────────────▲────────────────────────────┘ │ JSON-RPC 2.0 (stdio) ┌───────────────────────────▼────────────────────────────┐ │ BenefitFinder MCP Engine │ ├───────────────────────────┬────────────────────────────┤ │ 1. 2026 FPL Calculator │ 4. State Senior Tax Freeze │ │ (48 States, AK, HI) │ (NY SCHE, TX § 11.26) │ ├───────────────────────────┼────────────────────────────┤ │ 2.
Entitlement Directory │ 5. Portfolio Stacking DAG │ │ (SNAP, LIHEAP, LIS) │ (Categorical Anchors) │ ├───────────────────────────┼────────────────────────────┤ │ 3. Evidence Checklist Gen │ 6.
Local Encrypted Vault │ │ (Identity, Income, Med)│ (Zero-Leak PII Sandbox) │ └────────────────────────────────────────────────────────┘ Enter fullscreen mode Exit fullscreen mode 🧮 Step 1: Modeling 2026 Federal Poverty Guidelines Deterministically The Department of Health and Human Services (HHS) calculates annual poverty guidelines based on household size and geographic jurisdiction. Let's implement the baseline in Python:
# benefitfinder/engine.py from typing import Dict, Any, List, Optional class BenefitFinderEngine: # 2026 Official Federal Poverty Level (FPL) Guidelines (Annual Baseline) FPL_2026 = { " US ": { " base_1 ": 15650.0, " per_person ": 5500.0 }, " AK ": { " base_1 ": 19560.0, " per_person ": 6880.0 }, " HI ": { " base_1 ": 18000.0, " per_person ": 6330.0 }, } FPL_MULTIPLIERS = [ 100, 120, 130, 135, 150, 175, 185, 200, 250, 300 ] def calculate_fpl_threshold ( self, household_size: int = 1, state: str = " US " ) -> Dict [ str, Any ]: size = max ( 1, int ( household_size )) region = state. upper () if state. upper () in self. FPL_2026 else " US " guidelines = self. FPL_2026 [ region ] base_annual = guidelines [ " base_1 " ] + (( size - 1 ) * guidelines [ " per_person " ]) base_monthly = base_annual / 12.0 thresholds = {} for pct in self.
FPL_MULTIPLIERS: thresholds [ f " { pct } % " ] = { " percentage ": pct, " annual_usd ": round ( base_annual * ( pct / 100.0 ), 2 ), " monthly_usd ": round ( base_monthly * ( pct / 100.0 ), 2 ) } return { " household_size ": size, " region ": region, " base_fpl_annual_usd ": base_annual, " base_fpl_monthly_usd ": round ( base_monthly, 2 ), " thresholds ": thresholds } Enter fullscreen mode Exit fullscreen mode For a single senior in the contiguous 48 states, 100% FPL is $1,304.17/month, while 150% FPL (the ceiling for LIHEAP and Medicare Extra Help) is $1,956.25/month.
def assess_program_eligibility ( self, household_size: int = 1, monthly_income: float = 0.0, liquid_assets: float = 0.0, age_head: int = 65, state: str = " US ", has_disability: bool = False, is_medicare_enrolled: bool = False, existing_programs: Optional [ List [ str ]] = None ) -> Dict [ str, Any ]: existing = [ p. lower () for p in ( existing_programs or [])] is_senior = age_head >= 60 fpl_info = self. calculate_fpl_threshold ( household_size = household_size, state = state ) base_monthly_fpl = fpl_info [ " base_fpl_monthly_usd " ] income_pct_fpl = round (( monthly_income / base_monthly_fpl ) * 100.0, 1 ) eligible_programs = [] for pid, prog in self. programs. items (): reasons_fail, reasons_pass = [], [] # Check age condition if prog [ " min_age " ] and age_head < prog [ " min_age " ] and not has_disability: reasons_fail. append ( f " Requires age >= { prog [ ' min_age ' ] }. " ) # Check income ceiling max_pct = prog [ " fpl_elderly_percentage " ] if is_senior else prog [ " fpl_max_percentage " ] if income_pct_fpl > max_pct: reasons_fail. append ( f " Income ( { income_pct_fpl } % FPL) exceeds { max_pct } % limit. " ) else: reasons_pass. append ( f " Income within threshold.
" ) # Check asset limit asset_limit = prog [ " asset_limit_elderly_disabled " ] if is_senior else prog [ " asset_limit_standard " ] if asset_limit and liquid_assets > asset_limit: reasons_fail. append ( f " Assets ($ { liquid_assets } ) exceed $ { asset_limit }. " ) # Categorical shortcuts if pid == " lifeline_acp " and " snap " in existing: reasons_pass. append ( " Categorically qualified via active SNAP enrollment. " ) reasons_fail = [] if not reasons_fail: eligible_programs. append ({ " program_id ": pid, " name ": prog [ " name " ], " estimated_annual_value_usd ": prog [ " estimated_annual_value " ], " reasons ": reasons_pass }) return { " eligible_count ": len ( eligible_programs ), " eligible_programs ": eligible_programs, " total_estimated_annual_benefit_usd ": sum ( p [ " estimated_annual_value_usd " ] for p in eligible_programs ) } Enter fullscreen mode Exit fullscreen mode 🏛️ Step 3: State & County Senior Tax Freezes In many high-cost jurisdictions, property taxes are the greatest threat to aging in place.
BenefitFinder models specialized state rules:
AI agents should never transmit a senior's Social Security Number, bank balances, or medical expense receipts to unauthenticated third-party clouds. BenefitFinder Pro includes a zero-dependency PBKDF2-HMAC-SHA256 authenticated encryption vault:
# benefitfinder/core/pii_vault.py import base64, hashlib, hmac, json, secrets class PIIVault: PBKDF2_ITERATIONS = 100_000 def encrypt_profile ( self, profile: dict, passphrase: str ) -> dict: salt = secrets. token_bytes ( 16 ) iv = secrets. token_bytes ( 16 ) derived = hashlib. pbkdf2_hmac ( " sha256 ", passphrase. encode (), salt, self. PBKDF2_ITERATIONS, dklen = 64 ) enc_key, mac_key = derived [: 32 ], derived [ 32:] raw_json = json. dumps ( profile ). encode () # CTR stream cipher ciphertext = bytearray ( len ( raw_json )) for i in range (( len ( raw_json ) + 31 ) // 32 ): block = hmac. new ( enc_key, iv + i. to_bytes ( 4, ' big ' ), hashlib. sha256 ). digest () for j in range ( min ( 32, len ( raw_json ) - i * 32 )): ciphertext [ i * 32 + j ] = raw_json [ i * 32 + j ] ^ block [ j ] # Encrypt-then-MAC authentication mac = hmac. new ( mac_key, salt + iv + bytes ( ciphertext ), hashlib. sha256 ). digest () return { " salt ": base64. b64encode ( salt ). decode (), " iv ": base64. b64encode ( iv ). decode (), " ciphertext ": base64. b64encode ( ciphertext ). decode (), " mac ": base64. b64encode ( mac ). decode () } Enter fullscreen mode Exit fullscreen mode ⚡ Step 5: Connecting to Claude Desktop / Cursor Add the MCP configuration to claude_desktop_config.json:
{ "mcpServers": { "benefitfinder": { "command": "python", "args": [ "-m", "benefitfinder.server" ] } } } Enter fullscreen mode Exit fullscreen mode When you ask Claude:
"My 68-year-old grandmother lives in Texas on $1,350/month Social Security with $3,000 in savings. What government programs is she missing out on, and what order should she apply in?"
Claude invokes assess_program_eligibility and optimize_benefit_portfolio, outputting:
By transforming fragmented legal and statutory benefit rules into deterministic, testable MCP tools, developers and AI agents can eliminate administrative friction and directly restore thousands of dollars in earned entitlements to those who need them most.