### Install and Build Context+ from Source Source: https://github.com/forloopcodes/contextplus/blob/main/README.md Standard npm commands to install dependencies and build the project from its source code. ```bash npm install npm run build ``` -------------------------------- ### Generate MCP Server Config for IDEs Source: https://context7.com/forloopcodes/contextplus/llms.txt Use npx or bunx to generate configuration files for different IDEs. No installation is required. ```bash # Generate config for a specific IDE (no install needed) npx -y contextplus init claude # writes .mcp.json bunx contextplus init cursor # writes .cursor/mcp.json npx -y contextplus init vscode # writes .vscode/mcp.json npx -y contextplus init windsurf # writes .windsurf/mcp.json npx -y contextplus init opencode # writes opencode.json # Preview the project tree from the CLI directly (no IDE required) npx -y contextplus tree ./my-project bunx contextplus skeleton ./src ``` -------------------------------- ### Run Development Server with npm, yarn, pnpm, or bun Source: https://github.com/forloopcodes/contextplus/blob/main/landing/README.md Use these commands to start the local development server for the Next.js project. Open http://localhost:3000 in your browser to view the application. ```bash npm run dev # or yarn dev # or pnpm dev # or bun dev ``` -------------------------------- ### Run Ollama Embedding Model Source: https://github.com/forloopcodes/contextplus/blob/main/README.md Commands to pull the 'nomic-embed-text' model and start the Ollama server, required for using Ollama as the default embedding provider. ```bash ollama pull nomic-embed-text ollama serve ``` -------------------------------- ### Propose Commit Rejected Submission Example Source: https://context7.com/forloopcodes/contextplus/llms.txt This example shows a rejected commit proposal due to missing FEATURE tag and unauthorized inline comments. The tool provides specific feedback on violations. ```typescript // Rejected submission — missing FEATURE: tag and has inline comments { "tool": "propose_commit", "arguments": { "file_path": "src/utils/bad.ts", "new_content": "// Just a helper\n\nfunction doThing() {\n // step 1\n const x = 1; // assign\n // step 2\n return x;\n} " } } ``` -------------------------------- ### Get Project AST with get_context_tree Source: https://context7.com/forloopcodes/contextplus/llms.txt Generates a hierarchical tree of project files and directories. Prunes symbols or headers to fit token limits. ```typescript // MCP tool call — default (full tree with symbols, 20 000-token budget) { "tool": "get_context_tree" } ``` ```typescript // MCP tool call — targeted subtree for a large monorepo { "tool": "get_context_tree", "arguments": { "target_path": "src/api", "depth_limit": 2, "include_symbols": true, "max_tokens": 8000 } } ``` -------------------------------- ### Get Feature Hub - Open Hub by Feature Name Source: https://context7.com/forloopcodes/contextplus/llms.txt Use the `feature_name` argument to open a specific hub. Partial matches are supported, and the output includes file skeletons for all linked files. ```typescript { "tool": "get_feature_hub", "arguments": { "feature_name": "memory" } } ``` -------------------------------- ### Get Feature Hub - Find Orphaned Files Source: https://context7.com/forloopcodes/contextplus/llms.txt Use the `show_orphans` argument to list files that are not linked to any feature hub. The output suggests adding wikilinks to the appropriate hub files. ```typescript { "tool": "get_feature_hub", "arguments": { "show_orphans": true } } ``` -------------------------------- ### Get File Skeleton with get_file_skeleton Source: https://context7.com/forloopcodes/contextplus/llms.txt Extracts function signatures, class methods, and type definitions with line ranges from a single file without loading its full implementation. ```typescript // MCP tool call { "tool": "get_file_skeleton", "arguments": { "file_path": "src/core/memory-graph.ts" } } ``` -------------------------------- ### Get Feature Hub - List All Hubs Source: https://context7.com/forloopcodes/contextplus/llms.txt Call this tool without arguments to list all discovered feature hubs. It provides the hub file path, a descriptive name, and the number of links within each hub. ```typescript { "tool": "get_feature_hub" } ``` -------------------------------- ### Retrieve Graph Nodes with Traversal Source: https://context7.com/forloopcodes/contextplus/llms.txt Use `retrieve_with_traversal` to explore the graph starting from a specific node ID. It returns reachable neighbors up to a specified depth, scoring them by edge weight decay and depth penalty. ```typescript // MCP tool call { "tool": "retrieve_with_traversal", "arguments": { "start_node_id": "mn-1718020000000-x7k2p1", "max_depth": 2, "edge_filter": ["depends_on", "implements", "references"] } } /* Output: Traversal from: JWT Authentication Flow (depth limit: 2) [concept] JWT Authentication Flow (depth: 0, score: 100) Content: The app uses RS256-signed JWTs. Access tokens expire in 15 min... ID: mn-1718020000000-x7k2p1 | Accessed: 4x [symbol] validateToken (depth: 1, score: 69.2) Content: validateToken(token: string, secret: string): Promise Path: JWT Authentication Flow --[depends_on]--> validateToken ID: mn-1718019000000-abc999 | Accessed: 2x [file] src/middleware/auth.ts (depth: 2, score: 41.8) Content: Authentication middleware that validates Bearer tokens on every protected route. Path: JWT Authentication Flow --[depends_on]--> validateToken --[references]--> src/middleware/auth.ts ID: mn-1718018500000-m0n1o2 | Accessed: 1x */ ``` -------------------------------- ### Initialize Context+ MCP Configuration Source: https://github.com/forloopcodes/contextplus/blob/main/README.md These bash commands generate the MCP configuration file for different IDEs. Choose the command that matches your IDE (claude, cursor, opencode). ```bash npx -y contextplus init claude ``` ```bash bunx contextplus init cursor ``` ```bash npx -y contextplus init opencode ``` -------------------------------- ### Run npm Tests Source: https://github.com/forloopcodes/contextplus/blob/main/README.md Execute the test suite for the project. Use `npm run test:demo` for demo tests or `npm run test:all` for all tests. ```bash npm test ``` ```bash npm run test:demo ``` ```bash npm run test:all ``` -------------------------------- ### Create and Restore File Backups with Shadow Backup System Source: https://context7.com/forloopcodes/contextplus/llms.txt Use `createRestorePoint` to back up specified files before modification and `restorePoint` to revert to a previous state. `listRestorePoints` can retrieve all available backup points. Ensure paths resolve within the project root. ```typescript import { createRestorePoint, restorePoint, listRestorePoints } from "./src/git/shadow.js"; // Create a backup of files before modifying them const point = await createRestorePoint( "/project/root", ["src/api/user.ts", "src/api/auth.ts"], "Refactor: flatten nested auth handlers" ); // point.id = "rp-1718020000000-abc123" // point.timestamp, point.files, point.message // List all available restore points const points = await listRestorePoints("/project/root"); // [{ id, timestamp, files: ["src/api/user.ts", ...], message }, ...] // Restore to the pre-change state const restored = await restorePoint("/project/root", "rp-1718020000000-abc123"); // restored = ["src/api/user.ts", "src/api/auth.ts"] ``` -------------------------------- ### Configure Context+ MCP Server (VS Code) Source: https://github.com/forloopcodes/contextplus/blob/main/README.md This JSON configuration is for VS Code's `.vscode/mcp.json` file. It sets up Context+ as a server using stdio communication and defines environment variables for Ollama models and API keys. ```json { "servers": { "contextplus": { "type": "stdio", "command": "bunx", "args": ["contextplus"], "env": { "OLLAMA_EMBED_MODEL": "nomic-embed-text", "OLLAMA_CHAT_MODEL": "gemma2:27b", "OLLAMA_API_KEY": "YOUR_OLLAMA_API_KEY" } } }, "inputs": [] } ``` -------------------------------- ### Configure ContextPlus for OpenAI Embeddings Source: https://github.com/forloopcodes/contextplus/blob/main/README.md Use this configuration to set up ContextPlus to use an OpenAI-compatible embedding provider. Ensure you replace placeholders like YOUR_KEY and your-proxy.example.com with your actual credentials and endpoint. ```json { "mcpServers": { "contextplus": { "command": "npx", "args": ["-y", "contextplus"], "env": { "CONTEXTPLUS_EMBED_PROVIDER": "openai", "CONTEXTPLUS_OPENAI_API_KEY": "YOUR_KEY", "CONTEXTPLUS_OPENAI_BASE_URL": "https://your-proxy.example.com/v1", "CONTEXTPLUS_OPENAI_EMBED_MODEL": "your-model-name" } } } } ``` -------------------------------- ### Context+ MCP Server Config - OpenAI Source: https://context7.com/forloopcodes/contextplus/llms.txt Configuration for Context+ using OpenAI services. Ensure OPENAI_API_KEY and desired models are set. ```json // .mcp.json — OpenAI { "mcpServers": { "contextplus": { "command": "npx", "args": ["-y", "contextplus"], "env": { "CONTEXTPLUS_EMBED_PROVIDER": "openai", "OPENAI_API_KEY": "sk-...", "OPENAI_EMBED_MODEL": "text-embedding-3-small", "CONTEXTPLUS_OPENAI_CHAT_MODEL": "gpt-4o-mini" } } } } ``` -------------------------------- ### Initialize and Search with SearchIndex Source: https://context7.com/forloopcodes/contextplus/llms.txt The `SearchIndex` class provides a hybrid search engine combining vector embeddings and keyword matching. Import `SearchDocument` and use `index` to add documents and `search` to query the index. ```typescript import { SearchIndex, type SearchDocument } from "./src/core/embeddings.js"; const docs: SearchDocument[] = [ { path: "src/auth/jwt.ts", header: "JWT token generation and validation utilities", symbols: ["generateToken", "validateToken", "refreshToken"], content: "generateToken(payload, secret, expiresIn) validateToken(token, secret) refreshToken(oldToken)", }, ]; const index = new SearchIndex(); await index.index(docs, "/path/to/project"); // embeds uncached docs, loads cache for rest const results = await index.search("token expiry and validation", { topK: 3, semanticWeight: 0.72, keywordWeight: 0.28, minCombinedScore: 0.1, // 0–1 or 0–100, both accepted requireSemanticMatch: true, }); /* results[0] = { path: "src/auth/jwt.ts", score: 84.5, // percentage semanticScore: 88.1, keywordScore: 71.2, header: "JWT token generation and validation utilities", matchedSymbols: ["validateToken", "refreshToken"], matchedSymbolLocations: ["validateToken@L34-L58", "refreshToken@L61-L89"] } */ ``` -------------------------------- ### Context+ MCP Server Config - Google Gemini Source: https://context7.com/forloopcodes/contextplus/llms.txt Configuration for Context+ using Google Gemini via an OpenAI-compatible endpoint. Requires setting CONTEXTPLUS_OPENAI_API_KEY and specifying the correct base URL and models. ```json // .mcp.json — Google Gemini (free tier, OpenAI-compatible) { "mcpServers": { "contextplus": { "command": "npx", "args": ["-y", "contextplus"], "env": { "CONTEXTPLUS_EMBED_PROVIDER": "openai", "CONTEXTPLUS_OPENAI_API_KEY": "YOUR_GEMINI_API_KEY", "CONTEXTPLUS_OPENAI_BASE_URL": "https://generativelanguage.googleapis.com/v1beta/openai", "CONTEXTPLUS_OPENAI_EMBED_MODEL": "text-embedding-004", "CONTEXTPLUS_OPENAI_CHAT_MODEL": "gemini-2.0-flash" } } } } ``` -------------------------------- ### List Shadow Restore Points Source: https://context7.com/forloopcodes/contextplus/llms.txt Lists all shadow restore points created by `propose_commit`. Keeps up to the last 100 points per project root. ```typescript // MCP tool call { "tool": "list_restore_points" } ``` -------------------------------- ### list_restore_points Source: https://context7.com/forloopcodes/contextplus/llms.txt Lists all shadow restore points created by propose_commit. Each entry captures the pre-write file state, the timestamp, and the triggering message. Keeps up to the last 100 points per project root. ```APIDOC ## list_restore_points ### Description Lists all shadow restore points created by `propose_commit`. Each entry captures the pre-write file state, the timestamp, and the triggering message. Keeps up to the last 100 points per project root. ### Tool Call ```json { "tool": "list_restore_points" } ``` ### Example Output ``` Restore Points (3): rp-1718020000000-abc123 | 2024-06-10T12:00:00.000Z | src/utils/retry.ts | Pre-commit: src/utils/retry.ts rp-1718019500000-def456 | 2024-06-10T11:51:40.000Z | src/core/embeddings.ts | Pre-commit: src/core/embeddings.ts rp-1718018000000-ghi789 | 2024-06-10T11:26:40.000Z | src/tools/blast-radius.ts, src/tools/context-tree.ts | Pre-commit: src/tools/blast-radius.ts ``` ``` -------------------------------- ### Configure Context+ with OpenAI Source: https://github.com/forloopcodes/contextplus/blob/main/README.md This JSON configuration sets up Context+ to use OpenAI for embeddings. It requires an OpenAI API key and specifies the embedding model to use. ```json { "mcpServers": { "contextplus": { "command": "npx", "args": ["-y", "contextplus"], "env": { "CONTEXTPLUS_EMBED_PROVIDER": "openai", "OPENAI_API_KEY": "sk-வுகளை", "OPENAI_EMBED_MODEL": "text-embedding-3-small" } } } } ``` -------------------------------- ### Configure Context+ MCP Server (Claude Code) Source: https://github.com/forloopcodes/contextplus/blob/main/README.md This JSON configuration is for adding Context+ as an MCP server in Claude Code. It specifies the command to run, arguments, and environment variables for Ollama models and API keys. ```json { "mcpServers": { "contextplus": { "command": "bunx", "args": ["contextplus"], "env": { "OLLAMA_EMBED_MODEL": "nomic-embed-text", "OLLAMA_CHAT_MODEL": "gemma2:27b", "OLLAMA_API_KEY": "YOUR_OLLAMA_API_KEY" } } } } ``` -------------------------------- ### Mandatory File Header Format Source: https://github.com/forloopcodes/contextplus/blob/main/INSTRUCTIONS.md Every file must begin with exactly two comment lines, each 10 words long, describing the file's purpose and its associated feature. ```plaintext // Regex-based symbol extraction engine for multi-language AST parsing // FEATURE: Core parsing layer for structural code analysis ``` -------------------------------- ### get_context_tree Source: https://context7.com/forloopcodes/contextplus/llms.txt Returns a hierarchical tree of every file and directory in the project, annotated with file-purpose headers and symbol definitions. The output is token-aware and prunes symbols or headers if the full tree exceeds the token limit. ```APIDOC ## get_context_tree ### Description Returns a hierarchical tree of every file and directory in the project, annotated with 2-line file-purpose headers and symbol definitions (functions, classes, enums) with line ranges. Output is token-aware: if the full tree exceeds `max_tokens`, symbols are pruned first (Level 1), then headers (Level 0), guaranteeing the response always fits the context window. ### Method TOOL_CALL ### Parameters #### Arguments - **target_path** (string) - Optional - The path to a specific directory or file to focus the tree generation on. - **depth_limit** (number) - Optional - Limits the depth of the returned tree. For example, a depth of 2 would include the root and its immediate children and grandchildren. - **include_symbols** (boolean) - Optional - If true, includes symbol definitions (functions, classes, enums) within files. Defaults to true. - **max_tokens** (number) - Optional - The maximum number of tokens the response should consume. The tool will prune symbols and headers to fit within this limit if necessary. ### Request Example ```json { "tool": "get_context_tree" } { "tool": "get_context_tree", "arguments": { "target_path": "src/api", "depth_limit": 2, "include_symbols": true, "max_tokens": 8000 } } ``` ### Response #### Success Response Returns a JSON object representing the project's file and directory structure, including file headers and symbol definitions as specified by the arguments. The structure is pruned to fit `max_tokens` if necessary. #### Response Example ```json { "example": "./\n src/\n tools/\n blast-radius.ts | Dependency graph analyzer to trace symbol usage across the codebase\n [function] L20-L73 getBlastRadius(options: BlastRadiusOptions): Promise;\n context-tree.ts | Structural tree generator with file headers, symbols, and depth control\n [function] L107-L128 getContextTree(options: ContextTreeOptions): Promise;\n core/\n embeddings.ts | Multi-provider vector embedding engine with cosine similarity search\n [class] L440-L544 SearchIndex;\n [method] L443-L488 index(docs: SearchDocument[], rootDir: string): Promise;\n [method] L490-L539 search(query: string, optionsOrTopK?: ...): Promise;\n" } ``` ``` -------------------------------- ### Configure Context+ with Google Gemini Source: https://github.com/forloopcodes/contextplus/blob/main/README.md This JSON configuration sets up Context+ to use Google Gemini as the embedding provider via an OpenAI-compatible endpoint. It requires a Gemini API key and specifies the model. ```json { "mcpServers": { "contextplus": { "command": "npx", "args": ["-y", "contextplus"], "env": { "CONTEXTPLUS_EMBED_PROVIDER": "openai", "CONTEXTPLUS_OPENAI_API_KEY": "YOUR_GEMINI_API_KEY", "CONTEXTPLUS_OPENAI_BASE_URL": "https://generativelanguage.googleapis.com/v1beta/openai", "CONTEXTPLUS_OPENAI_EMBED_MODEL": "text-embedding-004" } } } } ``` -------------------------------- ### Run Static Analysis on a Single File Source: https://context7.com/forloopcodes/contextplus/llms.txt Specify a target path to run static analysis on a single file. This is useful for checking specific code changes before committing. ```typescript { "tool": "run_static_analysis", "arguments": { "target_path": "src/tools/blast-radius.ts" } } ``` -------------------------------- ### createRestorePoint, restorePoint, listRestorePoints Source: https://context7.com/forloopcodes/contextplus/llms.txt Manages file-level backups for safe refactoring and state restoration. ```APIDOC ## `createRestorePoint` / `restorePoint` — Shadow backup system Creates or restores file-level backups stored in `.mcp_data/backups//`, with a JSON manifest at `.mcp_data/restore-points.json`. Path traversal is blocked — all file paths must resolve within the project root. Manifest is capped at 100 entries. ### `createRestorePoint` **Description**: Creates a backup of specified files before modifications. **Parameters**: - `projectRoot` (string) - The root directory of the project. - `files` (string[]) - An array of file paths to include in the backup. - `message` (string) - A description of the backup. **Returns**: - An object containing `id`, `timestamp`, `files`, and `message` of the created restore point. ### `listRestorePoints` **Description**: Lists all available restore points for a project. **Parameters**: - `projectRoot` (string) - The root directory of the project. **Returns**: - An array of restore point objects, each containing `id`, `timestamp`, `files`, and `message`. ### `restorePoint` **Description**: Restores files to a previous state using a specified restore point. **Parameters**: - `projectRoot` (string) - The root directory of the project. - `id` (string) - The ID of the restore point to restore from. **Returns**: - An array of file paths that were restored. ``` -------------------------------- ### Run Static Analysis for TypeScript Project Source: https://context7.com/forloopcodes/contextplus/llms.txt Use this tool to run the project's native linter or compiler for type checking and code quality. It auto-detects the language and required configuration files. ```typescript { "tool": "run_static_analysis" } ``` -------------------------------- ### Context+ MCP Server Config - Ollama Source: https://context7.com/forloopcodes/contextplus/llms.txt Configuration for Context+ using a local Ollama instance as the default embedding provider. Ensure OLLAMA_EMBED_MODEL and OLLAMA_CHAT_MODEL are set appropriately. ```json // .mcp.json — Ollama (default, local/free) { "mcpServers": { "contextplus": { "command": "bunx", "args": ["contextplus"], "env": { "OLLAMA_EMBED_MODEL": "nomic-embed-text", "OLLAMA_CHAT_MODEL": "gemma2:27b", "OLLAMA_API_KEY": "YOUR_OLLAMA_API_KEY", "CONTEXTPLUS_EMBED_BATCH_SIZE": "8", "CONTEXTPLUS_EMBED_TRACKER": "lazy" } } } } ``` -------------------------------- ### get_file_skeleton Source: https://context7.com/forloopcodes/contextplus/llms.txt Extracts all function signatures, class methods, and type definitions with their line ranges from a single file, without loading the full implementation. This is useful for understanding a module's API before reading its entire content. ```APIDOC ## get_file_skeleton ### Description Extracts all function signatures, class methods, and type definitions with their line ranges from a single file, without loading the full implementation. Ideal for understanding how to call a module before reading it entirely. ### Method TOOL_CALL ### Parameters #### Arguments - **file_path** (string) - Required - The path to the file from which to extract the skeleton. ### Request Example ```json { "tool": "get_file_skeleton", "arguments": { "file_path": "src/core/memory-graph.ts" } } ``` ### Response #### Success Response Returns a JSON object containing the file path, total lines, and a list of top-level symbols (functions, classes, methods) with their respective line ranges and brief descriptions. #### Response Example ```json { "example": "File: src/core/memory-graph.ts (376 lines)\nSymbols: 9 top-level definitions\n\n// In-memory property graph with JSON persistence for linking memory nodes\n// FEATURE: Memory Graph — traversal, decay scoring, auto-similarity edges\n\n[function] L125-L153 upsertNode(rootDir: string, type: NodeType, label: string, content: string, metadata?: Record): Promise;\n[function] L155-L181 createRelation(rootDir: string, sourceId: string, targetId: string, relation: RelationType, weight?: number, metadata?: Record): Promise;\n[function] L183-L218 searchGraph(rootDir: string, query: string, maxDepth: number, topK: number, edgeFilter?: RelationType[]): Promise;\n[function] L251-L271 pruneStaleLinks(rootDir: string, threshold?: number): Promise<{ removed: number; remaining: number }>;\n[function] L273-L310 addInterlinkedContext(rootDir: string, items: Array<...>, autoLink: boolean): Promise<{ nodes: MemoryNode[]; edges: MemoryEdge[] }>;\n[function] L312-L332 retrieveWithTraversal(rootDir: string, startNodeId: string, maxDepth: number, edgeFilter?: RelationType[]): Promise;\n" } ``` ``` -------------------------------- ### parseWikiLinks, parseCrossLinks, discoverHubs, parseHubFile Source: https://context7.com/forloopcodes/contextplus/llms.txt Parses wikilinks and cross-links from Markdown files to build a hub graph. ```APIDOC ## `parseWikiLinks` / `discoverHubs` — Hub graph parser Parses Obsidian-style `[[target|description]]` wikilinks and `@linked-to [[hub]]` cross-links from Markdown hub files. `discoverHubs` recursively walks the project (skipping `node_modules`, `.git`, `build`, `dist`, `.mcp_data`) and returns all `.md` files containing wikilinks. ### `parseWikiLinks` **Description**: Parses Obsidian-style wikilinks from raw markdown content. **Parameters**: - `content` (string) - The raw markdown content to parse. **Returns**: - An array of objects, each with `target` and `description` properties for each wikilink found. ### `parseCrossLinks` **Description**: Parses `@linked-to [[hub]]` cross-links from markdown content. **Parameters**: - `content` (string) - The raw markdown content to parse. - `sourceFile` (string) - The path to the source markdown file. **Returns**: - An array of objects, each with `hubName` and `sourceFile` properties for each cross-link found. ### `discoverHubs` **Description**: Recursively discovers all Markdown files containing wikilinks within a project. **Parameters**: - `projectRoot` (string) - The root directory of the project to scan. **Returns**: - An array of file paths to the discovered hub files. ### `parseHubFile` **Description**: Parses a full hub file, extracting its title, links, and cross-links. **Parameters**: - `hubPath` (string) - The path to the hub markdown file. **Returns**: - An object containing `hubPath`, `title`, `links`, `crossLinks`, and `raw` content of the hub file. ``` -------------------------------- ### Codebase Semantic Mapping Source: https://context7.com/forloopcodes/contextplus/llms.txt Organizes source files into a hierarchical semantic map using spectral clustering. Reveals conceptual structure that directory layout doesn't show. ```typescript { "tool": "semantic_navigate" } ``` ```typescript { "tool": "semantic_navigate", "arguments": { "max_depth": 4, "max_clusters": 15 } } ``` -------------------------------- ### Restore Files from Shadow Restore Point Source: https://context7.com/forloopcodes/contextplus/llms.txt Restores one or more files to their content before a specific `propose_commit` write. Invalidates semantic and identifier search caches. ```typescript // MCP tool call { "tool": "undo_change", "arguments": { "point_id": "rp-1718020000000-abc123" } } ``` -------------------------------- ### Parse Wiki Links and Discover Hubs in Markdown Files Source: https://context7.com/forloopcodes/contextplus/llms.txt Utilize `parseWikiLinks` and `parseCrossLinks` to extract internal and external links from Markdown content. `discoverHubs` recursively finds all Markdown files containing links within a project, while `parseHubFile` parses a specific hub file including its title and links. ```typescript import { parseWikiLinks, parseCrossLinks, discoverHubs, parseHubFile } from "./src/core/hub.js"; // Parse links from raw markdown const content = ` # Auth Feature - [[src/auth/jwt.ts|Token utilities]] - [[src/middleware/auth.ts]] @linked-to [[docs/hubs/payments.md]] `; const links = parseWikiLinks(content); // [{ target: "src/auth/jwt.ts", description: "Token utilities" }, // { target: "src/middleware/auth.ts", description: undefined }] const crossLinks = parseCrossLinks(content, "docs/hubs/auth.md"); // [{ hubName: "docs/hubs/payments.md", sourceFile: "docs/hubs/auth.md" }] // Discover all hubs in a project const hubs = await discoverHubs("/project/root"); // ["docs/hubs/auth.md", "docs/hubs/payments.md", ...] // Parse a full hub including title extraction const info = await parseHubFile("/project/root/docs/hubs/auth.md"); // { hubPath, title: "Auth Feature", links: [...], crossLinks: [...], raw: "..." } ``` -------------------------------- ### Propose Commit for New TypeScript Module Source: https://context7.com/forloopcodes/contextplus/llms.txt Use this tool to write new files. It enforces strict rules including a 2-line comment header with a FEATURE tag and forbids inline comments. A restore point is automatically created. ```typescript // MCP tool call — write a new TypeScript module { "tool": "propose_commit", "arguments": { "file_path": "src/utils/retry.ts", "new_content": "// Exponential backoff retry utility for async operations\n// FEATURE: Network Resilience\n\nexport async function retry(\n fn: () => Promise, maxAttempts: number = 3, baseDelayMs: number = 100, ): Promise {\n for (let attempt = 1; attempt <= maxAttempts; attempt++) {\n try {\n return await fn();\n } catch (error) {\n if (attempt === maxAttempts) throw error;\n await new Promise(r => setTimeout(r, baseDelayMs * 2 ** (attempt - 1)));\n }\n }\n throw new Error('unreachable');\n}\n" } } ``` -------------------------------- ### Dependency Impact Tracing Source: https://context7.com/forloopcodes/contextplus/llms.txt Traces every file and line where a given symbol is imported or referenced. Warns when a symbol has only one usage. ```typescript { "tool": "get_blast_radius", "arguments": { "symbol_name": "fetchEmbedding", "file_context": "src/core/embeddings.ts" } } ``` ```typescript { "tool": "get_blast_radius", "arguments": { "symbol_name": "formatHubLink" } } ``` -------------------------------- ### Create Relation Between Memory Nodes Source: https://context7.com/forloopcodes/contextplus/llms.txt Creates a directed edge between two existing memory nodes. Relation types include `relates_to`, `depends_on`, `implements`, `references`, `similar_to`, `contains`. Edges have a weight that decays over time. ```typescript // MCP tool call { "tool": "create_relation", "arguments": { "source_id": "mn-1718020000000-x7k2p1", "target_id": "mn-1718019000000-abc999", "relation": "depends_on", "weight": 0.9, "metadata": { "note": "refresh endpoint calls validateToken" } } } ``` -------------------------------- ### semantic_code_search Source: https://context7.com/forloopcodes/contextplus/llms.txt Searches the codebase by semantic meaning using a hybrid ranking of vector embeddings and keyword overlap. Returns matched file paths with scores and specific symbol definition lines that triggered the match. ```APIDOC ## semantic_code_search ### Description Searches the codebase by semantic meaning using vector embeddings over file headers and symbol names, combined with keyword overlap in a hybrid ranking (default: 72% semantic + 28% keyword). Returns matched file paths with scores and the specific symbol definition lines that triggered the match. Index is cached to `.mcp_data/` and auto-refreshed by the embedding tracker. ### Method TOOL_CALL ### Parameters #### Arguments - **query** (string) - Required - The natural language query to search for within the codebase. - **top_k** (number) - Optional - The number of top results to return. Defaults to 5. - **semantic_weight** (number) - Optional - The weight given to semantic similarity in the hybrid ranking. Ranges from 0.0 to 1.0. - **keyword_weight** (number) - Optional - The weight given to keyword overlap in the hybrid ranking. Ranges from 0.0 to 1.0. - **min_semantic_score** (number) - Optional - The minimum semantic score required for a match. Ranges from 0.0 to 1.0. - **require_semantic_match** (boolean) - Optional - If true, only results with a semantic match are returned, even if keyword matching is also enabled. ### Request Example ```json { "tool": "semantic_code_search", "arguments": { "query": "user authentication and session management", "top_k": 5 } } { "tool": "semantic_code_search", "arguments": { "query": "vector cosine similarity scoring", "top_k": 3, "semantic_weight": 1.0, "keyword_weight": 0.0, "min_semantic_score": 0.6, "require_semantic_match": true } } ``` ### Response #### Success Response Returns a list of matched files, ranked by a hybrid score. Each entry includes the file path, total score, semantic and keyword score breakdowns, the file header, and the specific symbol definition lines that matched the query. #### Response Example ```json { "example": "Top 3 hybrid matches for: \"vector cosine similarity scoring\"\n\n1. src/core/embeddings.ts (87.4% total)\n Semantic: 91.2% | Keyword: 68.5%\n Header: Multi-provider vector embedding engine with cosine similarity search\n Matched symbols: cosine, SearchIndex, computeCombinedScore\n Definition lines: cosine@L316, SearchIndex@L440-L544, computeCombinedScore@L398-L403\n\n2. src/core/memory-graph.ts (79.1% total)\n Semantic: 82.3% | Keyword: 65.0%\n Header: In-memory property graph with JSON persistence for linking memory nodes\n Matched symbols: cosine, decayWeight\n Definition lines: cosine@L66-L77, decayWeight@L79-L82\n" } ``` ``` -------------------------------- ### create_relation Source: https://context7.com/forloopcodes/contextplus/llms.txt Creates a directed edge between two existing nodes. Relation types: relates_to, depends_on, implements, references, similar_to, contains. Edges carry a weight (0–1) that decays over time using e^(-λt). Duplicate edges update the weight instead of creating a new edge. ```APIDOC ## create_relation ### Description Creates a directed edge between two existing nodes. Relation types: `relates_to`, `depends_on`, `implements`, `references`, `similar_to`, `contains`. Edges carry a weight (0–1) that decays over time using `e^(-λt)`. Duplicate edges update the weight instead of creating a new edge. ### Tool Call ```json { "tool": "create_relation", "arguments": { "source_id": "mn-1718020000000-x7k2p1", "target_id": "mn-1718019000000-abc999", "relation": "depends_on", "weight": 0.9, "metadata": { "note": "refresh endpoint calls validateToken" } } } ``` ### Output ``` ✅ Relation created: mn-1718020000000-x7k2p1 --[depends_on]--> mn-1718019000000-abc999 Edge ID: me-1718020001000-y8m3q2 Weight: 0.9 Graph: 12 nodes, 9 edges ``` ``` -------------------------------- ### Semantic Code Search with semantic_code_search Source: https://context7.com/forloopcodes/contextplus/llms.txt Performs meaning-based code search using vector embeddings and keyword overlap. Results include matched file paths, scores, and symbol definitions. ```typescript // MCP tool call — basic meaning-based search { "tool": "semantic_code_search", "arguments": { "query": "user authentication and session management", "top_k": 5 } } ``` ```typescript // MCP tool call — strict semantic-only, high threshold { "tool": "semantic_code_search", "arguments": { "query": "vector cosine similarity scoring", "top_k": 3, "semantic_weight": 1.0, "keyword_weight": 0.0, "min_semantic_score": 0.6, "require_semantic_match": true } } ``` -------------------------------- ### undo_change Source: https://context7.com/forloopcodes/contextplus/llms.txt Restores one or more files to the exact content they had before a specific propose_commit write. Does not touch git history. Invalidates the semantic search and identifier search caches after restoration. ```APIDOC ## undo_change ### Description Restores one or more files to the exact content they had before a specific `propose_commit` write. Does not touch git history. Invalidates the semantic search and identifier search caches after restoration. ### Tool Call ```json { "tool": "undo_change", "arguments": { "point_id": "rp-1718020000000-abc123" } } ``` ### Example Output ``` Restored 1 file(s): src/utils/retry.ts ``` ``` -------------------------------- ### Add Interlinked Context Nodes Source: https://context7.com/forloopcodes/contextplus/llms.txt Use `add_interlinked_context` to add multiple memory nodes in a single call. It automatically creates `similar_to` edges between nodes with cosine similarity >= 0.72. ```typescript // MCP tool call — import a batch of related concepts { "tool": "add_interlinked_context", "arguments": { "auto_link": true, "items": [ { "type": "concept", "label": "Rate Limiting", "content": "Redis-backed sliding window rate limiter. 100 req/min per IP, 1000 req/min per API key." }, { "type": "symbol", "label": "rateLimitMiddleware", "content": "rateLimitMiddleware(req, res, next): void — Express middleware enforcing rate limits from Redis." }, { "type": "file", "label": "src/middleware/rate-limit.ts", "content": "Rate limiting middleware using Redis sliding window algorithm for per-IP and per-key throttling." } ] } } /* Output: ✅ Added 3 interlinked nodes Auto-linked: 2 similarity edges (threshold ≥ 0.72) Nodes: [concept] Rate Limiting → mn-1718020100000-r1a2b3 [symbol] rateLimitMiddleware → mn-1718020100001-s4d5e6 [file] src/middleware/rate-limit.ts → mn-1718020100002-f7g8h9 Edges: mn-1718020100000-r1a2b3 --[similar_to w:0.81]--> mn-1718020100001-s4d5e6 mn-1718020100001-s4d5e6 --[similar_to w:0.76]--> mn-1718020100002-f7g8h9 Graph total: 15 nodes, 12 edges */ ``` -------------------------------- ### Semantic Search with Memory Graph Traversal Source: https://context7.com/forloopcodes/contextplus/llms.txt Finds direct matches by embedding similarity and traverses neighbors to surface linked context. Edge filters can restrict traversal by relation type. Relevance scoring combines cosine similarity with edge decay weight. ```typescript // MCP tool call { "tool": "search_memory_graph", "arguments": { "query": "token expiry and refresh logic", "top_k": 3, "max_depth": 2, "edge_filter": ["depends_on", "references"] } } ``` -------------------------------- ### upsert_memory_node Source: https://context7.com/forloopcodes/contextplus/llms.txt Creates a node in the persistent in-memory property graph, or updates an existing node matched by (type, label). Automatically generates an embedding from label + content. Returns the node ID for use in create_relation. Nodes are typed as concept, file, symbol, or note. ```APIDOC ## upsert_memory_node ### Description Creates a node in the persistent in-memory property graph, or updates an existing node matched by `(type, label)`. Automatically generates an embedding from `label + content`. Returns the node ID for use in `create_relation`. Nodes are typed as `concept`, `file`, `symbol`, or `note`. ### Tool Call — create a concept node ```json { "tool": "upsert_memory_node", "arguments": { "type": "concept", "label": "JWT Authentication Flow", "content": "The app uses RS256-signed JWTs. Access tokens expire in 15 min, refresh tokens in 7 days. Token rotation happens on each refresh.", "metadata": { "owner": "auth-team", "priority": "high" } } } ``` ### Output ``` ✅ Memory node upserted: JWT Authentication Flow ID: mn-1718020000000-x7k2p1 Type: concept Access count: 1 Graph: 12 nodes, 8 edges ``` ``` -------------------------------- ### search_memory_graph Source: https://context7.com/forloopcodes/contextplus/llms.txt Semantic search with graph traversal. Finds direct matches by embedding similarity, then traverses 1st/2nd-degree neighbors to surface linked context. Edge filters let you restrict traversal to specific relation types. Relevance scoring combines cosine similarity with edge decay weight. ```APIDOC ## search_memory_graph ### Description Semantic search with graph traversal. Finds direct matches by embedding similarity, then traverses 1st/2nd-degree neighbors to surface linked context. Edge filters let you restrict traversal to specific relation types. Relevance scoring combines cosine similarity with edge decay weight. ### Tool Call ```json { "tool": "search_memory_graph", "arguments": { "query": "token expiry and refresh logic", "top_k": 3, "max_depth": 2, "edge_filter": ["depends_on", "references"] } } ``` ### Output ``` Memory Graph Search: "token expiry and refresh logic" Graph: 12 nodes, 9 edges Direct Matches: [concept] JWT Authentication Flow (depth: 0, score: 87.4) Content: The app uses RS256-signed JWTs. Access tokens expire in 15 min... ID: mn-1718020000000-x7k2p1 | Accessed: 3x Linked Neighbors: [symbol] validateToken (depth: 1, score: 61.2) Content: validateToken(token: string, secret: string): Promise Path: JWT Authentication Flow --[depends_on]--> validateToken ID: mn-1718019000000-abc999 | Accessed: 2x ``` ``` -------------------------------- ### Prune Stale Links and Orphan Nodes Source: https://context7.com/forloopcodes/contextplus/llms.txt The `prune_stale_links` function maintains graph relevance by removing edges with decayed weights below a threshold and deleting orphan nodes. Use the default threshold or specify a custom one for aggressive pruning. ```typescript // MCP tool call — default threshold (0.15) { "tool": "prune_stale_links" } // Aggressive pruning — keep only strong recent links { "tool": "prune_stale_links", "arguments": { "threshold": 0.4 } } /* Output: 🧹 Pruning complete Removed: 5 stale links/orphan nodes Remaining edges: 7 */ ```