SACL MCP Server

by ulasbilgen

Not rated
GitHub

About

A framework for bias-aware code retrieval using semantic-augmented reranking and localization.

Details

Author
ulasbilgen
Categories
Developer Tools, Knowledge Base, Other

Setup

Install SACL MCP Server in your MCP client (Claude Desktop, Cursor, Windsurf, and others).

Repository: https://github.com/ulasbilgen/sacl

Follow the installation instructions in the repository README, then restart your MCP client.

A framework for bias-aware code retrieval using semantic-augmented reranking and localization.

Semantic-Augmented Reranking and Localization for Code Retrieval

A Model Context Protocol (MCP) server that implements the SACL research framework to provide bias-aware code retrieval for AI coding assistants like Claude Code, Cursor, and other MCP-enabled tools.

SACL addresses the critical problem oftextual biasin code retrieval systems. Traditional systems over-rely on surface-level features like docstrings, comments, and variable names, leading to biased results that favor well-documented code regardless of functional relevance.

- 🧠 Bias Detection: Identifies over-reliance on textual features
- πŸ” Semantic Augmentation: Enriches code understanding beyond surface text
- πŸ“Š Intelligent Reranking: Prioritizes functional relevance over documentation
- 🎯 Code Localization: Pinpoints functionally relevant code segments
- πŸ”— Relationship Analysis: Maps code dependencies and relationships
- 🎨 Context-Aware Retrieval: Returns results with related components
- πŸš€ Agent-Controlled Updates: Explicit file updates for Docker compatibility
- πŸ—„οΈ Knowledge Graph: Persistent semantic storage with Graphiti/Neo4j
- πŸ”§ MCP Integration: Works with Claude Code, Cursor, and other AI tools

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AI Assistant │────│ SACL MCP Server │────│ Graphiti/Neo4j β”‚ β”‚ (Claude, Cursor)β”‚ β”‚ β”‚ β”‚ Knowledge Graph β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ SACL Framework β”‚ β”‚ β”‚ β”‚ β€’ Bias Detectionβ”‚ β”‚ β€’ Semantic Aug. β”‚ β”‚ β€’ Reranking β”‚ β”‚ β€’ Localization β”‚ β”‚ β€’ Relationships β”‚ β”‚ β€’ Context-Aware β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

- Node.js 18+
- Neo4j database
- OpenAI API key

# Clone the repository git clone <repository-url> cd sacl # Install dependencies npm install # Copy environment configuration cp .env.example .env # Edit .env with your settings OPENAI_API_KEY=your_key_here NEO4J_URI=bolt://localhost:7687 NEO4J_USER=neo4j NEO4J_PASSWORD=your_password
# Start Neo4j and SACL server docker-compose up -d # Check logs docker-compose logs -f sacl-mcp-server
# Build the project npm run build # Start the server npm start

The SACL server provides comprehensive MCP tools for bias-aware code analysis:

Performs full SACL analysis of a repository:

{ "repositoryPath": "/path/to/repo", "incremental": false }

Bias-aware code search with optional context:

{ "query": "function that sorts arrays efficiently", "repositoryPath": "/path/to/repo", "maxResults": 10, "includeContext": false // Set true for relationship context }

Enhanced search with relationship context and related components:

{ "query": "authentication middleware", "repositoryPath": "/path/to/repo", "maxResults": 10, "includeRelated": true }

Explicitly update single file analysis when changes are made:

{ "filePath": "src/services/auth.js", "changeType": "modified" // "created", "modified", or "deleted" }
{ "files": [ { "filePath": "src/index.js", "changeType": "modified" }, { "filePath": "src/utils/new.js", "changeType": "created" } ] }

Analyze code relationships and dependencies:

{ "filePath": "src/controllers/UserController.js", "maxDepth": 3, "relationshipTypes": ["imports", "calls", "extends"] // Optional filter }
{ "filePath": "src/models/User.js", "includeSnippets": true // Include code previews }
{ "filePath": "src/utils/sort.js" // Optional }

Add to yourclaude_desktop_config.json:

{ "mcpServers": { "sacl": { "command": "node", "args": ["/path/to/sacl/dist/index.js"], "env": { "OPENAI_API_KEY": "your-key", "NEO4J_URI": "bolt://localhost:7687", "NEO4J_USER": "neo4j", "NEO4J_PASSWORD": "password" } } } }

Configure in your Cursor settings to connect to the SACL MCP server.

- Docstring Dependency: Over-reliance on documentation
- Identifier Name Bias: Focusing on variable/function names
- Comment Over-reliance: Prioritizing commented code

- Functional Signatures: What the code actually does
- Behavior Patterns: Computational patterns (iteration, recursion, etc.)
- Structural Features: Complexity metrics, AST analysis
- Augmented Embeddings: Bias-adjusted semantic vectors

- Bias-Aware Ranking: Reduces textual weight based on bias score
- Code Localization: Identifies functionally relevant segments
- Semantic Similarity: Uses augmented embeddings
- Functional Relevance: Considers computational patterns

Maps code relationships and dependencies:

- Import/Export Analysis: Module dependencies and exports
- Function Call Mapping: Call graphs and method invocations
- Class Inheritance: Extends/implements relationships
- Dependency Tracking: External and internal dependencies
- Context-Aware Results: Related components with each query result

AI Assistant β†’ analyze_repository β†’ SACL processes all files β†’ Knowledge graph populated
AI Assistant β†’ query_code_with_context("authentication") β†’ SACL retrieval β†’ Context-aware results
AI modifies code β†’ update_file("src/auth.js", "modified") β†’ SACL re-analyzes β†’ Relationships updated
AI Assistant β†’ get_relationships("UserController.js") β†’ Dependency graph β†’ Related components

- Original textual similarity score
- Semantic similarity score
- Bias-adjusted final score
- Localized code regions
- Related components and dependencies
- Context explanation with relationship importance
- Explanation of ranking decisions

- 12.8%improvement in Recall@1 on HumanEval
- 9.4%improvement on MBPP
- 7.0%improvement on SWE-Bench-Lite
- P95 latency: <300ms for retrieval operations

🧠 SACL Bias Analysis File: src/algorithms/quicksort.js Bias Metrics: β€’ Overall Bias Score: 73.2% πŸ”΄ β€’ Semantic Pattern: Recursive divide-and-conquer sorting β€’ Functional Signature: Array input β†’ sorted array output Bias Indicators: β€’ docstring_dependency: High docstring dependency (15.3% of code) β€’ identifier_name_bias: High reliance on descriptive names β€’ comment_over_reliance: Excessive comments (18.7% of code) πŸ’‘ Improvement Suggestions: β€’ Reduce reliance on variable naming for semantic understanding β€’ Focus on structural patterns over comments β€’ Improve functional signature extraction
src/ β”œβ”€β”€ core/ # SACL framework implementation β”‚ β”œβ”€β”€ BiasDetector.ts # Textual bias detection β”‚ β”œβ”€β”€ SemanticAugmenter.ts # Semantic enhancement β”‚ β”œβ”€β”€ SACLReranker.ts # Reranking and localization with context β”‚ └── SACLProcessor.ts # Main orchestrator with relationship support β”œβ”€β”€ mcp/ # MCP server implementation β”‚ └── SACLMCPServer.ts # MCP protocol handlers (9 tools) β”œβ”€β”€ graphiti/ # Knowledge graph integration β”‚ └── GraphitiClient.ts # Graphiti/Neo4j interface with relationships β”œβ”€β”€ utils/ # Utility modules β”‚ └── CodeAnalyzer.ts # AST analysis and relationship extraction β”œβ”€β”€ types/ # TypeScript type definitions β”‚ β”œβ”€β”€ index.ts # Core types and interfaces β”‚ └── relationships.ts # Relationship type definitions └── index.ts # Application entry point
npm run build # Build TypeScript npm run dev # Development with auto-reload npm run lint # Code linting npm run format # Code formatting npm test # Run tests

- Fork the repository
- Create a feature branch
- Implement changes following SACL methodology
- Add tests for new functionality
- Submit a pull request

This implementation is based on the research paper:

"SACL: Understanding and Combating Textual Bias in Code Retrieval with Semantic-Augmented Reranking and Localization"

- Authors: Dhruv Gupta, Gayathri Ganesh Lakshmy, Yiqing Xie
- arXiv: 2506.20081v2
- Systematic Bias Detection: Identifies textual bias through feature masking
- Semantic Augmentation: Enhances code understanding beyond text
- Bias-Aware Ranking: Reduces surface-level feature dependency
- Localization: Pinpoints functionally relevant code regions

- Claude Code: Direct MCP integration
- Cursor: MCP server connection
- VS Code Extensions: Via MCP protocol
- Custom Tools: Any MCP-compatible client

-

JavaScript/TypeScript: Full AST analysis with relationship extraction

- Import/export tracking
- Function call analysis
- Class inheritance detection
- Dynamic imports support

- Import statement parsing
- Class inheritance detection
- Function call patterns

Other Languages(Java, C++, C#, Go, Rust): Basic analysis

- Import/include statements
- Class declarations
- Function definitions

Extensible: Easy to add new language analyzers

MIT License - see LICENSE file for details.

- Issues: GitHub Issues
- Documentation: See/docsdirectory
- Research Paper:arXiv:2506.20081v2

- Multi-language AST parsing for all supported languages
- Real-time Graphiti integration (currently uses mock methods)
- Semantic relationship detection beyond syntactic analysis
- Visual relationship graphs in MCP responses
- Custom bias threshold configuration per project
- Integration with Language Server Protocol (LSP)
- Advanced localization algorithms with machine learning
- Performance optimizations for large codebases (>10k files)
- Real-time bias notifications during code writing
- Custom relationship type definitions

SACL MCP Server- Bringing research-backed bias-aware code retrieval to AI coding assistants.

This is a web browser that enables your coding agent, such as Claude Code, to visit websites on your behalf and assist you in identifying bugs or creating UI test cases.

An advanced code analysis and editing server with semantic search capabilities using vector embeddings.

A platform-agnostic code analysis library with semantic search capabilities and MCP server support.

A knowledge management tool for code repositories using vector embeddings, powered by a local Ollama service.

Transforms raw code into polished solutions with optimized performance and vector embeddings support.

A Python-based server that locally indexes codebases using ChromaDB to provide semantic search for tools like Cursor.

Local-first code intelligence MCP server. Hybrid BM25 + ONNX vector search, symbol-level impact analysis, diff-aware PR review with risk scoring, and persistent memory tied to git state. 20 tools, MIT licensed.

A local-first semantic code search tool with vector and regex capabilities, designed for AI assistants.

Fast, accurate, local code search for agents. Indexes any local path or GitHub repo on demand in ~250ms and answers queries in ~1.5ms. Works on CPU, no API keys or external services.

About Semantic code-search (semcode) MCP. Indexes code symbols and commit history. Combines dense embeddings with sparse BM25 vectors for hybrid search that balances semantic understanding with keyword precision.

AI-to-AI code review platform β€” Claude, Codex, and Gemini cross-check each other via MCP, REST API, and CLI for consensus-based results.

No reviews yet β€” be the first

Sign in to leave a review

Use Google, GitHub, or an email account so ratings stay tied to real people.

Email sign in

No reviews posted yet.