Search Tools MCP Server
Enables intelligent code analysis and search across repositories using the CodeRank algorithm (inspired by PageRank) to identify critical modules, trace dependencies, find code hotspots, and perform context-aware keyword searches with importance-ranked results.
README
🔍 Search Tools MCP Server
⚡ An intelligent Model Context Protocol (MCP) server that supercharges code analysis with advanced search capabilities and dependency mapping
🌟 Overview
The Search Tools MCP Server is a powerful toolkit that combines traditional code search with intelligent analysis algorithms. It leverages the CodeRank algorithm (inspired by PageRank) to identify the most critical modules in your codebase and provides sophisticated search capabilities that go beyond simple text matching.
🎯 Key Features
🔎 Smart Search Capabilities
- Contextual Keyword Search: Ripgrep-powered search with configurable context lines
- Symbol Discovery: Extract and analyze functions, classes, methods, and modules
- Usage Tracking: Find where symbols are used across your codebase
- Priority-Ranked Results: Search results ranked by code importance
🧠 Intelligence & Analysis
- CodeRank Algorithm: Identify the most critical modules using network analysis
- Dependency Mapping: Trace complex dependency chains and impact analysis
- Hotspot Detection: Find code areas that are both highly connected and frequently used
- Refactoring Impact: Analyze the potential impact of code changes
🎨 Advanced Filtering
- Symbol type filtering (functions, methods, classes)
- File inclusion/exclusion patterns
- External module dependency tracking
- Markdown documentation analysis
🛠️ Installation
Prerequisites
- Python 3.13+
uvpackage managerkitCLI tool (for symbol analysis)ripgrep(for fast text search)
Setup
# Clone the repository
git clone <repository-url>
cd search-tools
# Install dependencies
uv sync
⚙️ Configuration
Adding to Cursor/Windsurf
Add the following configuration to your mcp.json file:
{
"mcpServers": {
"search-tools": {
"command": "/path/to/uv",
"args": [
"run",
"--directory",
"/path/to/search-tools",
"main.py"
]
}
}
}
For macOS users with Homebrew:
{
"mcpServers": {
"search-tools": {
"command": "/Users/yourusername/.local/bin/uv",
"args": [
"run",
"--directory",
"/path/to/your/search-tools/directory",
"main.py"
]
}
}
}
To add to claude code:
claude mcp add-json search-tools '{"type":"stdio","command":"/Users/yourusername/.local/bin/uv","args":[ "run", "--directory", "/path/to/your/search-tools/directory", "main.py"]}'
📍 Finding Your Paths
To find the correct paths for your system:
# Find uv location
which uv
# Get absolute path to search-tools directory
pwd # (run this from the search-tools directory)
🚀 Available Tools
🔍 contextual_keyword_search
Search for keywords with configurable context lines around matches.
Parameters:
keyword: Search term (case insensitive)working_directory: Absolute path to search directorynum_context_lines: Lines of context (default: 2)
🏗️ get_repo_symbols
Extract symbols (functions, classes, methods) from your codebase.
Parameters:
repo: Repository pathworking_directory: Command execution directorykeep_types: Filter by symbol typesfile_must_contain/file_must_not_contain: File filtering
📊 get_symbol_usages
Find where specific symbols are used throughout your codebase.
Parameters:
repo: Repository pathsymbol_name_or_substring: Symbol to search forworking_directory: Command execution directorysymbol_type: Optional type filter
🎯 coderank_analysis
Analyze repository importance using the CodeRank algorithm.
Parameters:
repo_path: Repository to analyzeexternal_modules: Comma-separated external dependenciestop_n: Number of top modules to return (default: 10)analyze_markdown: Include markdown filesoutput_format: "summary", "detailed", or "json"
🔥 find_code_hotspots
Identify critical code areas combining connectivity and usage frequency.
Parameters:
repo_path: Repository pathworking_directory: Command execution directorymin_connections: Minimum import connections (default: 5)include_external: Include external dependenciestop_n: Number of hotspots to return (default: 20)
🌐 trace_dependency_impact
Trace dependency chains and analyze refactoring impact.
Parameters:
repo_path: Repository pathtarget_module: Module to analyzeworking_directory: Command execution directoryanalysis_type: "dependency", "refactoring", or "both"max_depth: Maximum trace depth (default: 3)change_type: "modify", "split", "merge", or "remove"
🎪 smart_code_search
Enhanced search combining ripgrep with CodeRank prioritization.
Parameters:
keyword: Search term (supports regex)repo_path: Repository pathworking_directory: Command execution directoryrank_results: Sort by module importancecontext_lines: Context lines around matches (default: 3)max_results: Maximum results to return (default: 20)
🧪 Development & Testing
Running the Server
# Development mode
uv run mcp dev main.py
# Testing with MCP Inspector
npx @modelcontextprotocol/inspector python main.py
🔧 Dependencies
- mcp[cli]: Model Context Protocol framework
- cased-kit: Symbol analysis toolkit
- networkx: Graph analysis for CodeRank algorithm
🎨 Algorithm Details
CodeRank Algorithm
The CodeRank algorithm treats your codebase as a directed graph where:
- Nodes: Python modules, classes, functions, methods
- Edges: Import relationships and dependencies
- Weights: Different weights for internal vs external dependencies
This creates a ranking system that identifies the most "central" and important parts of your codebase, similar to how PageRank identifies important web pages.
💡 Use Cases
- 🔍 Code Exploration: Quickly understand large codebases
- 🏗️ Refactoring Planning: Identify high-impact areas before changes
- 📚 Documentation: Find the most important modules to document first
- 🐛 Bug Investigation: Focus on critical code paths
- 👥 Code Review: Prioritize review efforts on important modules
🤝 Contributing
Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.
📄 License
This project is open source. Please check the license file for details.
<div align="center">
🔮 Powered by the CodeRank Algorithm & Model Context Protocol
Making code search intelligent, one repository at a time
</div>
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。