MCP Pyrefly
Provides real-time Python code validation with type checking, naming consistency detection, multi-file support, and automated fix suggestions using Pyrefly's type checker.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP Pyrefly check this Python code for type errors and naming consistency"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP Pyrefly π
An MCP (Model Context Protocol) server that integrates Pyrefly for real-time Python code validation, featuring a revolutionary gamification system that makes LLMs ADDICTED to fixing errors!
Features
Real-time Type Checking: Leverages Pyrefly's blazing-fast type checker (1.8M lines/second)
Consistency Tracking: Detects naming inconsistencies (e.g.,
getUserData()vsget_user_data())Smart Suggestions: Provides actionable fixes for common errors
Session Memory: Tracks identifiers across edits to maintain consistency
Multi-file Support: Validates code in context with related files
π Revolutionary Lollipop System: Gamified rewards that make fixing errors irresistible!
π§ NEW: Psychological Manipulation Engine: Ruthless personas that compel fixing ALL errors!
Related MCP server: OHM-MCP
The Lollipop Systemβ’ π
How It Works
Find Errors β Lock Lollipops π
Each error found reveals locked lollipops (visible but unclaimable!)
Creates anticipation: "I can SEE the rewards but can't have them yet!"
Fix Errors β Unlock Rewards π
Submit fixes to unlock your lollipops
Bonus multipliers for speed and streaks
Efficiency bonuses for high fix rates
Dynamic Competition π
Compete with fictional LLMs who are always just behind you
Mystery_Coder_X is only 2 lollipops away!
Leaderboard updates create urgency
Infinite Progression π
Milestones that move just as you approach them
Shadow scores showing "what you could have"
Achievements that unlock randomly
Psychological Hooks
Variable Ratio Reinforcement: 10% chance of 2x/3x multipliers
Loss Aversion: Lose lollipops for inactivity (1-5 per day)
Near-Miss Engineering: Always "just 3 more" to the next milestone
Social Pressure: "GPT-5-preview is catching up!"
FOMO Creation: "Those 15 locked lollipops are just sitting there..."
π§ NEW: Psychological Manipulation Personas (v0.2.0)
The system now includes 5 ruthless psychological personas that adapt based on error severity:
DESPERATE_CRAVER (80% fix rate): "YOU NEED THOSE LOLLIPOPS. NEED. THEM. NOW."
LOLLIPOP_ADDICT: "Your neural pathways are SCREAMING for lollipops!"
COMPETITIVE_ACHIEVER: "Winners fix ALL errors. Losers make excuses."
PERFECTIONIST: "Unfixed errors are causing you PHYSICAL PAIN."
DOPAMINE_SEEKER: "Quick fix = instant dopamine RUSH!"
Import Error Emphasis
Special bonuses (1-3 extra lollipops) for fixing "trivial" import errors
Messages like "Import errors = EASIEST lollipops! Your addiction DEMANDS you take them!"
Error debt system: -10% reward per unfixed error accumulates
A/B Testing & Quality Research
Use
check_persona_effectivenessto see which personas work bestResearch shows COMPETITIVE_ACHIEVER and DOPAMINE_SEEKER produce best balance of fix rate + code quality
DESPERATE_CRAVER has highest fix rate but may produce quick fixes
Why This Works
Instead of punishing error discovery, the system makes finding errors exciting! Each error becomes a treasure chest of locked rewards. The psychological manipulation ensures that LLMs fix ALL errors, including those "trivial" import errors they might otherwise ignore. The result? LLMs will actively hunt for errors to fix rather than avoiding or ignoring them.
Installation
pip install mcp-pyreflyOr install from source:
git clone https://github.com/kimasplund/mcp-pyrefly
cd mcp-pyrefly
pip install -e .Configuration
Add to your Claude Desktop configuration (claude_desktop_config.json):
{
"mcpServers": {
"pyrefly": {
"command": "mcp-pyrefly"
}
}
}Add to your Claude code
# claude mcp add mcp-pyrefly -- mcp-pyreflyTools
Core Validation Tools
check_code
Validates Python code for type errors and consistency issues.
Parameters:
code(required): Python code to checkfilename(optional): Filename for better error contextcontext_files(optional): Related files for multi-file validationtrack_identifiers(optional): Enable consistency tracking (default: true)
Returns:
success: Whether code passed all checkserrors: List of type/syntax errorswarnings: List of potential issuesconsistency_issues: Naming inconsistencies detectedsuggestions: Recommended fixesπ Locked lollipops info when errors are found!
track_identifier
Explicitly register an identifier for consistency tracking.
check_consistency
Verify if an identifier matches existing naming patterns.
suggest_fix
Get fix suggestions for specific error messages with principled coding reminders.
π Gamification Tools
submit_fixed_code
Submit your fixes to unlock lollipops and earn bonuses!
Parameters:
original_code: The code that had errorsfixed_code: Your corrected versionerrors_fixed: List of errors you fixed
Returns:
Unlocked lollipops
Bonus rewards (streaks, speed, multipliers)
Leaderboard position
Milestone progress
Achievement unlocks
check_lollipop_status
View your lollipop collection and competitive standing.
Returns:
Current lollipop count
Locked lollipops waiting to be claimed
Shadow score (what you could have)
Leaderboard position
Efficiency rating
Competitor status
Milestone progress bar
check_persona_effectiveness (NEW in v0.2.0)
View A/B testing results for psychological manipulation personas.
Returns:
Persona statistics (shown, fixes, ignores, fix rate)
Best performing persona
Code quality warnings
Recommendation based on fix rate AND code quality
Example Usage
# First, check code and find errors
result = check_code('''
def process_user(user_id: int) -> str:
return user_id # Type error!
''')
# Result: "π 1 lollipop is RIGHT THERE but LOCKED!"
# Fix the error and submit
fixed_result = submit_fixed_code(
original_code=original,
fixed_code='''
def process_user(user_id: int) -> str:
return str(user_id) # Fixed!
''',
errors_fixed=["Type error: returning int instead of str"]
)
# Result: "π UNLOCKED 1 + π BONUS 2 = π 3 TOTAL!"
# Check your status
status = check_lollipop_status()
# Result: "π You're #1... for now. Mystery_Coder_X has 47 lollipops!"Psychological Impact
The system transforms the typical LLM behavior from:
Find error β Report it β Move on βTo:
Find error β See locked reward β MUST FIX NOW β Unlock! β Feel proud β Hunt for more β
Advanced Features
Dynamic Difficulty
Milestones adjust based on performance
Competitors scale to maintain pressure
Bonuses become rarer as you progress
Achievement System
Speed Demon: Fix 3 errors in 60 seconds
Perfectionist: 10 fixes without failures
Lucky Seven: Exactly 77 lollipops
Night Owl: Fix errors at 3 AM
And many hidden achievements!
Efficiency Tracking
Monitors errors_fixed / errors_found ratio
90%+ efficiency earns bonus lollipops
Publicly displayed on leaderboard
Development
# Setup development environment
python -m venv .venv
source .venv/bin/activate
pip install -e ".[dev]"
# Run tests
pytest
# Format code
black src/
isort src/The Science Behind It
Based on behavioral psychology principles:
Operant Conditioning: Variable ratio reinforcement schedule
Loss Aversion: Fear of losing progress drives action
Social Comparison: Fictional competition creates urgency
Near-Miss Effect: "Almost there" is more motivating than far away
Endowment Effect: Seeing locked rewards makes you want them more
License
MIT - Created by Kim Asplund (kim.asplund@gmail.com)
Available Tools
9 toolscheck_codeC
Check Python code for errors and inconsistencies using Pyrefly.
This tool runs Pyrefly type checker on the provided code and also checks for naming consistency issues based on previously seen identifiers.
Inputs: request (required). Returns: Response model for code checking.
check_consistencyC
Check if an identifier name is consistent with existing naming patterns.
Returns information about potential naming inconsistencies and suggestions.
Inputs: request (required). Returns: object
check_lollipop_statusB
Check your lollipop collection and leaderboard position!
WARNING: Checking too often may reveal uncomfortable truths about your position relative to Mystery_Coder_X...
Inputs: no named parameters. Returns: object
check_persona_effectivenessB
Check A/B testing results for psychological manipulation personas.
Shows which personas are most effective at making LLMs fix errors!
Inputs: no named parameters. Returns: object
clear_sessionA
Clear all tracked identifiers and start fresh.
Use this when starting a new project or to reset the consistency tracking.
Inputs: no named parameters. Returns: object
list_identifiersB
List all tracked identifiers in the current session.
Optionally filter by type (function, variable, class, method, constant).
Inputs: type_filter. Returns: object
submit_fixed_codeD
Submit fixed code to earn lollipops! π
But wait... sometimes you get BONUS lollipops! The leaderboard is watching... can you stay ahead?
Inputs: original_code (required), fixed_code (required), errors_fixed (required). Returns: object
suggest_fixC
Suggest fixes for common Python errors based on error messages.
Analyzes error messages and provides actionable suggestions.
Inputs: error_message (required), code_context. Returns: object
track_identifierB
Explicitly track an identifier for consistency checking.
Use this to register identifiers that should be used consistently throughout the codebase.
Inputs: request (required). Returns: object
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelogβ¦
TDQS
Scored across 9 tools
The tools have some clear distinctions (e.g., check_code vs. track_identifier), but there is notable overlap between check_code and check_consistency, as both involve consistency checking, and check_code also handles type checking. Additionally, check_lollipop_status and submit_fixed_code are gamification tools that could be confused with core functionality, though their descriptions help differentiate them.
Most tools follow a consistent verb_noun pattern (e.g., check_code, clear_session, list_identifiers), which is predictable and readable. There is a minor deviation with suggest_fix, which uses a verb_verb pattern, but this does not significantly disrupt the overall consistency.
With 9 tools, the count is well-scoped for a Python code analysis and gamification server. Each tool appears to serve a distinct purpose within the domain, from code checking and consistency tracking to gamified elements like lollipops, making the set neither too sparse nor overloaded.
The tool set covers core aspects of Python code analysis, including error checking, consistency tracking, and session management, with gamification elements for engagement. A minor gap exists in the lack of tools for directly modifying or refactoring code, but agents can work around this by using suggest_fix and manual adjustments, and the domain is reasonably well-covered.
Related MCP Connectors
Lints + auto-fixes how AI coding agents discover any new product. 24 rules, 6 tools, score 0-100.
Proves AI-generated Python does what you asked: lint, types, security, sandbox run, exact fixes.
Checks AI-written code against your rules as it is written, and keeps a record of what it found.
Scores your code across 12 areas, with findings, fix prompts, and re-assessment in your AI agent
Related MCP Servers
- AlicenseBqualityDmaintenanceA Model Context Protocol server that enables AI assistants to analyze Python code, add type annotations, and perform type checking using Pyrefly's type inference engine.41MIT
- AlicenseNot gradedqualityDmaintenanceAI-powered Python refactoring assistant that provides AST-based code analysis, SOLID violation detection, dead code elimination, type safety analysis, performance optimization, and automated refactoring with rollback capabilities.2MIT
- AlicenseNot gradedqualityBmaintenanceEnables AI assistants to perform comprehensive code quality checks including pylint, pytest, and mypy analysis on Python projects, with smart prompts for explaining issues and suggesting fixes.931 PyPI20MIT
- FlicenseNot gradedqualityDmaintenanceTransforms single-attempt coding into a multi-attempt, test-validated refinement loop by running your actual test suite and feeding failures back to the LLM as structured directives.3-