Skip to main content
Glama
code_rag_tools.py•2.48 kB
""" Code RAG Tools - Qdrant integration for code search """ import sys from pathlib import Path from typing import List, Dict, Any import os # Add parent directory to path for imports sys.path.insert(0, str(Path(__file__).parent.parent)) from loguru import logger # Try to import Qdrant client try: from qdrant_client import QdrantClient from qdrant_client.models import Filter, FieldCondition, MatchValue QDRANT_AVAILABLE = True except ImportError: QDRANT_AVAILABLE = False logger.warning("Qdrant client not available. Install with: pip install qdrant-client") def get_qdrant_client(): """Get Qdrant client instance""" if not QDRANT_AVAILABLE: return None qdrant_url = os.getenv("QDRANT_URL", "http://localhost:6333") try: return QdrantClient(url=qdrant_url) except Exception as e: logger.error(f"Failed to connect to Qdrant: {e}") return None def search_code(query: str, top_k: int = 5, collection: str = "code_snippets") -> List[Dict]: """ Search code using Qdrant vector database Args: query: Search query top_k: Number of results to return collection: Collection name (default: code_snippets) Returns: List of search results with metadata """ client = get_qdrant_client() if not client: logger.warning("Qdrant not available, returning empty results") return [] try: # Placeholder: Implement actual vector search # This requires: # 1. Embedding the query # 2. Searching the collection # 3. Returning results with metadata logger.info(f"Searching code: '{query}' (top_k={top_k})") # TODO: Implement actual vector search # For now, return empty results return [] except Exception as e: logger.error(f"Code search failed: {e}") return [] def upsert_code_snippets(snippets: List[Dict]) -> bool: """ Upsert code snippets into Qdrant Args: snippets: List of code snippets with embeddings Returns: True if successful """ client = get_qdrant_client() if not client: return False try: # TODO: Implement actual upsert logger.info(f"Upserting {len(snippets)} code snippets") return True except Exception as e: logger.error(f"Upsert failed: {e}") return False

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/mjdevaccount/AIStack-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server