ai-integration

A set of project rules for adding AI features such as code embeddings, language-model access, and semantic search.

In plain words
What is it for?
It guides code embedding generation, semantic search, and tools that help AI assistants find symbols, code, and definitions.
Why use it?
It defines how services, API keys, local fallbacks, caching, batching, and error handling should be used in the Code-Index-MCP project.

Cursor rule for Cursor

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/consiliency/code-index-mcp/ai-integration
Clone the repo
git clone --depth 1 https://github.com/Consiliency/Code-Index-MCP

Made for: Cursor.

Per session 685 This file is loaded in full into every session.
When invoked 685 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00685 $0.00685
Opus 5 $0.00342 $0.00342
Sonnet 5 $0.00137 $0.00137
Haiku 4.5 $0.00068 $0.00068

Measured 2d ago against content hash 9fa9ed5f03d2, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

ai-integration scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

.cursor/rules/ai-integration.mdc · 102 lines

How it starts

The opening of the file, as written. The whole thing — 102 lines — stays where its author put it; the contents beside it link to each section on GitHub.

AI Integration Rules for Code-Index-MCP

Overview

This file defines rules and guidelines for AI integration within the Code-Index-MCP project, including embedding services, language models, and semantic search capabilities.

Embedding Services

Voyage AI Integration

  • Purpose: Generate code embeddings for semantic search
  • Configuration: API key required in environment variables
  • Fallback: Local embedding generation if API unavailable
  • Caching: Embeddings should be cached locally to reduce API calls

Implementation Guidelines

# Use the semantic_indexer utility
from mcp_server.utils.semantic_indexer import SemanticIndexer

# Initialize with API key
indexer = SemanticIndexer(api_key=os.getenv("VOYAGE_AI_API_KEY"))

# Generate embeddings with caching
embeddings = indexer.get_embeddings(code_snippet, use_cache=True)

Language Model Integration

MCP Protocol

  • Purpose: Provide code intelligence to Claude and other LLMs
  • Tools: Symbol lookup, code search, definition finding
  • Response Format: Structured JSON with location references

Best Practices

  1. Batch Processing: Group embedding requests to minimize API calls
  2. Error Handling: Gracefully fall back to fuzzy search on API failures
  3. Rate Limiting: Respect API rate limits with exponential backoff
  4. Security: Never log or expose API keys

Hybrid Approach

  • Combine lexical search (fuzzy matching) with semantic search
  • Weight results based on confidence scores
  • Provide context-aware code suggestions

Query Processing

# Example hybrid search implementation
def hybrid_search(query: str, weights: Dict[str, float] = None):
    weights = weights or {"lexical": 0.4, "semantic": 0.6}
    
    # Lexical search using fuzzy indexer
    lexical_results = fuzzy_indexer.search(query)
    
    # Semantic search using embeddings
    semantic_results = semantic_indexer.search(query)
    
    # Combine and rank results
    return combine_results(lexical_results, semantic_results, weights)

Read the full file on GitHub · 102 lines

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 102 lines · 685 tokens per session scan A 9fa9ed5f03d2

Subscribe to this mod's changes

ai-integration is a cursor rule published in the GitHub repository Consiliency/Code-Index-MCP (57 stars, last pushed 1mo ago), licensed MIT. It adds 685 tokens to every session, about $0.0034 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.