space-ngrams
Click on "Install 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., "@space-ngramssearch for the function 'calculateTotal' in the codebase"
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.
space-ngrams
MCP server that gives AI agents superpowers to search through your codebase at lightning speed.
Space-nGrams connects to AI coding assistants (Claude Code, Codex CLI, Qwen CLI, OpenCode) and provides them with three essential tools: search code, find files, and read files. All powered by ripgrep for millisecond-level performance.
ποΈ How It Works
Architecture
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β AI Agent β β Space-nGrams β β ripgrep β
β (Claude Code, ββββββΆβ MCP Server ββββββΆβ (rg) β
β Qwen, etc.) βββββββ (Python) βββββββ Search Engine β
βββββββββββββββββββ ββββββββββββββββββββ βββββββββββββββββββ
β β β
β βΌ β
β ββββββββββββββββββββ β
β β Cache Layer β β
β β (~/.space-ngramsβ β
β β /cache/) β β
β ββββββββββββββββββββ β
β β β
β βΌ β
β ββββββββββββββββββββ β
βββββββββββββββΆβ Metrics & Logs βββββββββββββββββ
β (~/.space-ngramsβ
β /server.log) β
ββββββββββββββββββββWhy MCP?
MCP (Model Context Protocol) is a standard that allows AI agents to access external tools and data sources. Instead of embedding all your code into the AI's context (which is slow and expensive), Space-nGrams gives the AI the ability to:
Search on demand β Find any pattern, function, or string in your codebase in milliseconds
Navigate efficiently β Locate files by name, then read only what's needed
Work with large codebases β No need to load everything into context
Why ripgrep?
Blazing fast β SIMD acceleration, regex compilation, parallel search
Smart filtering β Respects
.gitignore, skips binary filesRich output β JSON format with line numbers and context
Battle tested β Used by developers worldwide daily
Why caching?
Repeated searches are common when AI agents explore code. Our cache layer:
Stores results for 5 minutes (configurable)
Persists across sessions on disk
Reduces latency from ~100ms to ~2ms on cache hits
Automatically manages size limits (50 MB default)
Related MCP server: codeweave-mcp
β‘ Features
Feature | Benefit |
Caching | 10-50x faster for repeated searches |
Metrics | Track performance and cache hit rates |
Configuration | Customize limits, timeouts, ignore patterns |
Logging | Debug issues via |
π οΈ Tools
Tool | Description |
| Search for regex/string in code with context |
| Find files by glob pattern |
| Read file content (max 200 lines/call) |
| Get session performance statistics |
π¦ Installation
1. Clone the repository
git clone https://github.com/your-username/space-ngrams.git
cd space-ngrams2. Install ripgrep
# Windows
winget install BurntSushi.ripgrep.MSVC
# macOS
brew install ripgrep
# Linux
sudo apt install ripgrepVerify: rg --version
3. Install Python dependencies
pip install mcp4. Verify the server starts
python src/server.pyThe process will wait on stdin β that's correct. Stop with Ctrl+C.
π Connecting to AI Tools
Claude Code
claude mcp add space-ngrams -- python /path/to/space-ngrams/src/server.pyVerify:
claude mcp list
# space-ngrams: python ... - β ConnectedCodex CLI
Add to ~/.codex/config.toml:
[mcp_servers.space-ngrams]
command = "python"
args = [ "/path/to/space-ngrams/src/server.py" ]Qwen CLI
Add to ~/.qwen/settings.json:
{
"mcpServers": {
"space-ngrams": {
"command": "python",
"args": ["/path/to/space-ngrams/src/server.py"]
}
}
}OpenCode
Add to opencode.json in your project root or home directory:
{
"mcp": {
"space-ngrams": {
"type": "local",
"command": ["python", "/path/to/space-ngrams/src/server.py"]
}
}
}π¬ Usage
The AI agent automatically uses these tools when needed. You can also trigger them explicitly:
find all calls to getUserById in D:/Projects/MyAppshow all .ts files in the src folderread D:/Projects/MyApp/src/auth/service.ts lines 50-100Tool Parameters
search_code
Parameter | Required | Description |
| yes | Regex or literal string |
| yes | Directory or file to search in |
| no | File type filter, e.g. |
| no | Lines of context (default: 2) |
find_files
Parameter | Required | Description |
| yes | Glob, e.g. |
| yes | Root directory to search in |
| no | Maximum results (default: 100) |
read_file
Parameter | Required | Description |
| yes | Absolute or relative path |
| no | First line to read (default: 1) |
| no | Last line (inclusive) |
get_metrics
Returns performance statistics:
{
"search_code": {
"total_calls": 15,
"cache_hits": 8,
"cache_hit_rate": 53.3,
"avg_duration_ms": 45.2,
"min_duration_ms": 2.1,
"max_duration_ms": 234.5
}
}βοΈ Configuration
Create a config file at ./space-ngrams.toml (project-specific) or ~/.space-ngrams/config.toml (global):
[cache]
enabled = true
ttl_seconds = 300 # 5 minutes
max_size_mb = 50
[limits]
max_search_results = 50
max_files_results = 100
max_read_lines = 200
default_context_lines = 2
search_timeout_seconds = 15
[ignore_patterns]
# Additional patterns to ignore (beyond .gitignore)
ignore_patterns = [
"*.log",
"*.tmp",
"node_modules/**",
"__pycache__/**",
]
[metrics]
enabled = trueSee space-ngrams.example.toml for a full example with comments.
π Project Structure
space-ngrams/
βββ src/
β βββ server.py # MCP server implementation
βββ pyproject.toml # Python package metadata
βββ space-ngrams.example.toml # Example configuration
βββ LICENSE
βββ README.md # This file (English)
βββ README_RU.md # Russian translation
βββ docs/
βββ ARCHITECTURE.md # Architecture notes (optional)π Also available in Russian.
π Logs and Cache
Location | Purpose |
| Server logs and metrics |
| Persistent cache storage |
π License
MIT
This server cannot be installed
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityCmaintenanceAn MCP server for semantic code search & navigation that helps AI agents work efficiently without burning through costly tokens. Instead of reading entire files, agents can search conceptually and jump directly to the specific functions, classes, and code chunks they need.118MIT
- Alicense-qualityBmaintenanceAn MCP server that gives AI agents structured code understanding and precise code intelligence via local indexing of AST, call graphs, and semantic search.434Apache 2.0
- Alicense-qualityDmaintenanceAn MCP server that wraps ripgrep to provide powerful text search, search-and-replace, file listing, and file type listing capabilities within a defined scope.14MIT
- Alicense-qualityDmaintenanceAn MCP server that enables AI agents to navigate and understand codebases through file descriptions, semantic search, and code recommendations without repeatedly scanning files.MIT
Related MCP Connectors
An MCP server that gives your AI access to the source code and docs of all public github repos
Driflyte MCP server which lets AI assistants query topic-specific knowledge from web and GitHub.
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/dev993848/mcp-fast-search-code'
If you have feedback or need assistance with the MCP directory API, please join our Discord server