### Basic CLI Operations Source: https://github.com/nibzard/engramdb/blob/main/src/bin/README.md Examples for starting the shell and configuring storage backends. ```bash # Start interactive shell (default action) cargo run --bin engramdb-cli # Use in-memory database (data is lost when program exits) cargo run --bin engramdb-cli -- --memory # Use specific database file/directory cargo run --bin engramdb-cli -- --database /path/to/database # Use single-file storage cargo run --bin engramdb-cli -- --database /path/to/database.engramdb --storage-type single-file ``` -------------------------------- ### Start Web Interface Source: https://github.com/nibzard/engramdb/blob/main/README.md Launch the web interface using the provided script or manual setup. ```bash cd web ./run_web.sh # Quick start script # Or manual setup cd web python -m venv venv_app source venv_app/bin/activate pip install -r requirements.txt python app_full.py ``` -------------------------------- ### Web Development Setup Source: https://github.com/nibzard/engramdb/blob/main/README.md Steps to set up the virtual environment, install dependencies, and run the web application. ```bash cd web python -m venv venv_app source venv_app/bin/activate pip install -r requirements.txt python app_full.py ``` -------------------------------- ### Run Web Interface Source: https://github.com/nibzard/engramdb/blob/main/docs/getting-started.mdx Start the web interface using the provided script or manual environment setup. ```bash # Quick start with the provided script cd web ./run_web.sh # Or manual setup cd web python -m venv venv_app source venv_app/bin/activate pip install flask==2.3.3 werkzeug==2.3.7 flask-wtf==1.2.1 python app_full.py ``` -------------------------------- ### Start the Application Manually Source: https://github.com/nibzard/engramdb/blob/main/web/README.md Launch the full application script after dependencies are installed. ```bash python app_full.py ``` -------------------------------- ### EngramDB Web Interface Setup (Bash) Source: https://context7.com/nibzard/engramdb/llms.txt Provides instructions for quickly starting the EngramDB web interface using a provided script or through manual setup with Python virtual environments and pip. ```bash # Quick start with the run script cd web ./run_web.sh # Or manual setup cd web python -m venv venv_app source venv_app/bin/activate # On Windows: venv_app\Scripts\activate pip install -r requirements.txt python app_full.py # Access the interface at http://localhost:8082 # Features: # - Visual graph exploration of memory connections # - Create, edit, and delete memory nodes # - Perform similarity searches # - View memory attributes and metadata # - Export and import databases ``` -------------------------------- ### Manual Virtual Environment Setup Source: https://github.com/nibzard/engramdb/blob/main/web/README.md Commands to create and activate a Python virtual environment for manual installation. ```bash python3 -m venv venv_app source venv_app/bin/activate ``` -------------------------------- ### Python Development Setup Source: https://github.com/nibzard/engramdb/blob/main/README.md Commands to set up the Python development environment, install dependencies, and run tests. ```bash cd python pip install -r requirements-dev.txt maturin develop pytest tests/ ``` -------------------------------- ### Interactive Shell Session Source: https://github.com/nibzard/engramdb/blob/main/src/bin/README.md Example of starting the interactive shell and accessing the help menu. ```bash $ cargo run --bin engramdb-cli EngramDB Interactive Shell Type 'help' for a list of commands, 'exit' to quit engramdb> help ``` -------------------------------- ### Example Entry Point Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/engramdb-llms.txt Standard Python entry point for executing the example workflow. ```python if __name__ == "__main__": run_example() ``` -------------------------------- ### Run TypeScript Client Examples Source: https://github.com/nibzard/engramdb/blob/main/README.md Build and run TypeScript client examples. ```bash # Build and run TypeScript examples cd sdks/typescript-client npm install npx ts-node examples/basic-usage.ts ``` -------------------------------- ### Initialize Node.js Project and Install Dependencies Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Sets up a new Node.js project, installs necessary SDKs and development dependencies, and creates the main source file. ```bash # Create project directory mkdir mcp-client-typescript cd mcp-client-typescript # Initialize npm project npm init -y # Install dependencies npm install @anthropic-ai/sdk @modelcontextprotocol/sdk dotenv # Install dev dependencies npm install -D @types/node typescript # Create source file touch index.ts ``` ```powershell # Create project directory md mcp-client-typescript cd mcp-client-typescript # Initialize npm project npm init -y # Install dependencies npm install @anthropic-ai/sdk @modelcontextprotocol/sdk dotenv # Install dev dependencies npm install -D @types/node typescript # Create source file new-item index.ts ``` -------------------------------- ### Run Python API Client Examples Source: https://github.com/nibzard/engramdb/blob/main/README.md Execute Python API client examples. ```bash # Run Python client examples cd sdks/python-client/examples python basic_usage.py ``` -------------------------------- ### Install EngramDB Client Source: https://github.com/nibzard/engramdb/blob/main/sdks/python-client/README.md Use pip to install the client library. ```bash pip install engramdb-client ``` -------------------------------- ### Run Rust Examples Source: https://github.com/nibzard/engramdb/blob/main/README.md Execute provided Rust examples using Cargo. ```bash # Run examples using Cargo cargo run --example basic_usage cargo run --example memory_graph cargo run --example memory_and_file_storage ``` -------------------------------- ### Install Local Wheel File Source: https://github.com/nibzard/engramdb/blob/main/python/PUBLISHING.md Install the built wheel file locally for testing purposes. Use --force-reinstall to ensure the latest version is used, overwriting any existing installation. ```bash pip install --force-reinstall target/wheels/engramdb_py-0.1.0-*.whl ``` -------------------------------- ### Run Python Native Bindings Examples Source: https://github.com/nibzard/engramdb/blob/main/README.md Execute Python examples for native bindings. ```bash # Run Python examples directly cd examples/python python basic_usage.py python memory_graph.py python agent_memory.py ``` -------------------------------- ### Install EngramDB Client Source: https://github.com/nibzard/engramdb/blob/main/sdks/typescript-client/README.md Commands to install the client library using npm or yarn. ```bash npm install @engramdb/client # or yarn add @engramdb/client ``` -------------------------------- ### Run EngramDB Thread-Safe Demo Source: https://github.com/nibzard/engramdb/blob/main/examples/agent/THREAD_SAFETY.md Install dependencies and execute the demonstration application. ```bash # Install requirements pip install flask engramdb-py # Run the demo application python flask_threadsafe_demo.py ``` -------------------------------- ### Install Dependencies Source: https://github.com/nibzard/engramdb/blob/main/cookbook/providers/groq/README.md Install the necessary Python packages for Groq and EngramDB integration. ```bash pip install groq engramdb-py ``` -------------------------------- ### Install Python API Client Source: https://github.com/nibzard/engramdb/blob/main/README.md Install the Python API client for distributed deployments. ```bash # Install from PyPI pip install engramdb-client # Or build from source cd engramdb/sdks/python-client pip install -e . ``` -------------------------------- ### Install TypeScript/JavaScript Client Source: https://github.com/nibzard/engramdb/blob/main/README.md Install the TypeScript client via npm or build from source. ```bash # Install from npm npm install @engramdb/client # Or build from source cd engramdb/sdks/typescript-client npm install npm run build ``` -------------------------------- ### Start REST API Server Source: https://github.com/nibzard/engramdb/blob/main/README.md Run the API server with default or custom configuration. ```bash # Run with default settings cargo run --bin engramdb-server --features api-server # Run with custom settings ENGRAMDB_API_PORT=9000 ENGRAMDB_API_HOST=127.0.0.1 ENGRAMDB_JWT_SECRET=mysecretkey cargo run --bin engramdb-server --features api-server ``` -------------------------------- ### Install Python Native Bindings Source: https://github.com/nibzard/engramdb/blob/main/README.md Install the Python bindings via PyPI or build them from source using maturin. ```bash pip install engramdb-py ``` ```bash cd engramdb/python pip install maturin maturin develop ``` -------------------------------- ### Run EngramDB Example Source: https://github.com/nibzard/engramdb/blob/main/cookbook/advanced/README.md Execute an EngramDB example script using the Python interpreter. ```bash python custom_embeddings.py ``` -------------------------------- ### Main Entry Point for MCP Client Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt The main function to start the MCP client application. It parses command-line arguments for the server script path, initializes the client, connects to the server, and starts the chat loop. Requires a server script path as a command-line argument. ```kotlin fun main(args: Array) = runBlocking { if (args.isEmpty()) throw IllegalArgumentException("Usage: java -jar /build/libs/kotlin-mcp-client-0.1.0-all.jar ") val serverPath = args.first() val client = MCPClient() client.use { client.connectToServer(serverPath) client.chatLoop() } } ``` -------------------------------- ### Set Up Development Environment Source: https://github.com/nibzard/engramdb/blob/main/sdks/python-client/README.md Commands for cloning the repository, setting up a virtual environment, and installing development dependencies. ```bash # Clone the repository git clone https://github.com/nkkko/engramdb.git cd engramdb/sdks/python-client # Set up a virtual environment python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate # Install development dependencies pip install -e ".[dev]" # Run tests pytest ``` -------------------------------- ### Launch Jupyter Notebook Source: https://github.com/nibzard/engramdb/blob/main/cookbook/notebooks/README.md Start the Jupyter server to access the notebooks. ```bash jupyter notebook ``` -------------------------------- ### Initialize project and environment Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to create a new project directory, virtual environment, and install dependencies. ```bash # Create a new directory for our project uv init weather cd weather # Create virtual environment and activate it uv venv source .venv/bin/activate # Install dependencies uv add "mcp[cli]" httpx # Create our server file touch weather.py ``` ```powershell # Create a new directory for our project uv init weather cd weather # Create virtual environment and activate it uv venv .venv\Scripts\activate # Install dependencies uv add mcp[cli] httpx # Create our server file new-item weather.py ``` -------------------------------- ### Initialize Project Environment Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to create the project directory, initialize npm, and install necessary dependencies. ```bash # Create a new directory for our project mkdir weather cd weather # Initialize a new npm project npm init -y # Install dependencies npm install @modelcontextprotocol/sdk zod npm install -D @types/node typescript # Create our files mkdir src touch src/index.ts ``` ```powershell # Create a new directory for our project md weather cd weather # Initialize a new npm project npm init -y # Install dependencies npm install @modelcontextprotocol/sdk zod npm install -D @types/node typescript # Create our files md src new-item src\index.ts ``` -------------------------------- ### Run the Web Interface Source: https://github.com/nibzard/engramdb/blob/main/web/README.md Execute the main script to automatically set up the environment and start the application on port 8082. ```bash ./run_web.sh ``` -------------------------------- ### Run API Server with Hot-Reloading Source: https://github.com/nibzard/engramdb/blob/main/README.md Start the API server with hot-reloading enabled using `cargo-watch`. This requires `cargo-watch` to be installed. ```bash cargo watch -x 'run --bin engramdb-server --features api-server' ``` -------------------------------- ### Troubleshooting Missing EngramDB Dependency Source: https://github.com/nibzard/engramdb/blob/main/examples/agent/README.md If you encounter a ModuleNotFoundError for 'engramdb_py', ensure EngramDB is installed from the local repository as detailed in the Development Setup section. ```text Error: ModuleNotFoundError: No module named 'engramdb_py' Solution: Install EngramDB from the local repository as shown in the Development Setup. ``` -------------------------------- ### Initialize Python Project with uv Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to set up a new project directory, virtual environment, and install necessary dependencies. ```bash # Create project directory uv init mcp-client cd mcp-client # Create virtual environment uv venv # Activate virtual environment # On Windows: .venv\Scripts\activate # On Unix or MacOS: source .venv/bin/activate # Install required packages uv add mcp anthropic python-dotenv # Remove boilerplate files rm main.py # Create our main file touch client.py ``` -------------------------------- ### Cross-Platform Windows Build Setup on macOS Source: https://github.com/nibzard/engramdb/blob/main/python/PUBLISHING.md Install MinGW-w64 and the necessary Rust target for cross-compiling to Windows on a macOS system. This is a prerequisite for building Windows wheels. ```bash brew install mingw-w64 rustup target add x86_64-pc-windows-gnu maturin build --release --target x86_64-pc-windows-gnu -i python3 ``` -------------------------------- ### Create and Set Up C# Project (MacOS/Linux) Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Initializes a new C# console project in a 'weather' directory. This is the first step in building a C# weather server. ```bash # Create a new directory for our project mkdir weather cd weather # Initialize a new C# project dotnet new console ``` -------------------------------- ### Install EngramDB Source: https://github.com/nibzard/engramdb/blob/main/cookbook/notebooks/interactive_tutorial.ipynb Install the EngramDB Python package. Uncomment and run this command if you need to install it. ```python # Uncomment and run if you need to install EngramDB # !pip install engramdb-py ``` -------------------------------- ### Verify Java Installation Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Check your Java installation version. Ensure you have Java 17 or higher installed. ```bash java --version ``` -------------------------------- ### Install Dependencies with uv Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/README.md Installs required Python dependencies using uv. Ensure you have uv installed first. ```bash # Install required dependencies uv pip install -r requirements.txt ``` -------------------------------- ### Build and Test the Library Source: https://github.com/nibzard/engramdb/blob/main/sdks/typescript-client/README.md Commands for cloning the repository, installing dependencies, building the project, and running tests. ```bash # Clone the repository git clone https://github.com/nkkko/engramdb.git cd engramdb/sdks/typescript-client # Install dependencies npm install # Build the library npm run build # Run tests npm test ``` -------------------------------- ### Initialize MCP Server Instance Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Create the server instance with basic implementation details. ```kotlin // Main function to run the MCP server fun `run mcp server`() { // Create the MCP Server instance with a basic implementation val server = Server( Implementation( name = "weather", // Tool name is "weather" version = "1.0.0" // Version of the implementation ``` -------------------------------- ### Install Python Packages Source: https://github.com/nibzard/engramdb/blob/main/cookbook/providers/openai/README.md Install the required Python libraries for EngramDB and OpenAI integration. Ensure you have Python and pip installed. ```bash pip install openai engramdb-py ``` -------------------------------- ### Install EngramDB Python Library Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/README.md Installs the EngramDB Python library using uv. You can install from PyPI or a local wheel file. ```bash # Install EngramDB (either from PyPI or from the provided wheel file) uv pip install engramdb-py # or uv pip install ./engramdb_py-0.1.0-cp313-cp313-macosx_11_0_arm64.whl ``` -------------------------------- ### Install EngramDB and Google Generative AI Source: https://github.com/nibzard/engramdb/blob/main/cookbook/providers/gemini/README.md Install the required Python packages using pip. Ensure you have Python and pip installed. ```bash pip install google-generativeai engramdb-py ``` -------------------------------- ### Initialize Kotlin Project Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to create a project directory and initialize a Gradle project. ```bash # Create a new directory for our project mkdir weather cd weather # Initialize a new kotlin project gradle init ``` ```powershell # Create a new directory for our project md weather cd weather # Initialize a new kotlin project gradle init ``` -------------------------------- ### Install npx Package Manager Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Command to install the npx package manager globally using npm. Ensure Node.js and npm are installed first. ```bash npm install -g npx ``` -------------------------------- ### Verify npm Installation Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Command to verify the installed npm version. ```bash npm --version ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/nibzard/engramdb/blob/main/examples/agent/README.md Copy the example environment file and edit it to add your API keys and configure settings for the LLM provider and storage locations. ```bash cp .env.example .env # Edit .env with your preferred text editor to add API keys ``` -------------------------------- ### Verify Node.js Installation Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Command to verify the installed Node.js version. ```bash node --version ``` -------------------------------- ### Main Entry Point and Execution Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Sets up the main execution logic for the client, handling command-line arguments, server connection, and the chat loop. Ensures cleanup is performed. ```python async def main(): if len(sys.argv) < 2: print("Usage: python client.py ") sys.exit(1) client = MCPClient() try: await client.connect_to_server(sys.argv[1]) await client.chat_loop() finally: await client.cleanup() if __name__ == "__main__": import sys asyncio.run(main()) ``` -------------------------------- ### Install NPM Globally Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Install NPM globally using npm if the 'npx' command fails, indicating that NPM might not be installed globally. This is a prerequisite for using npx commands. ```bash npm install -g npm ``` -------------------------------- ### Initialize Kotlin Project (Windows) Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Use these commands to create a new directory and initialize a Kotlin project using Gradle on Windows. ```powershell # Create a new directory for our project md kotlin-mcp-client cd kotlin-mcp-client # Initialize a new kotlin project gradle init ``` -------------------------------- ### Initialize Kotlin Project (MacOS/Linux) Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Use these commands to create a new directory and initialize a Kotlin project using Gradle on MacOS or Linux. ```bash # Create a new directory for our project mkdir kotlin-mcp-client cd kotlin-mcp-client # Initialize a new kotlin project gradle init ``` -------------------------------- ### Install Dependencies Source: https://github.com/nibzard/engramdb/blob/main/cookbook/providers/ollama/README.md Install the necessary Python libraries for EngramDB and Ollama integration. ```bash pip install ollama engramdb-py ``` -------------------------------- ### Install EngramDB Source: https://github.com/nibzard/engramdb/blob/main/cookbook/README.md Install the Python package to begin using EngramDB in your environment. ```bash pip install engramdb-py ``` -------------------------------- ### Example Server Path Usage Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Demonstrates correct usage of relative and absolute paths for specifying the server script, including Windows path formats. ```bash # Relative path node build/index.js ./server/build/index.js # Absolute path node build/index.js /Users/username/projects/mcp-server/build/index.js # Windows path (either format works) node build/index.js C:/projects/mcp-server/build/index.js node build/index.js C:\projects\mcp-server\build\index.js ``` -------------------------------- ### Verify uv installation Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/README.md Check the installed version of uv to ensure dependencies are met. ```bash # Check uv installation uv --version ``` -------------------------------- ### Import Packages and Initialize Server Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Setup of the McpServer instance and necessary imports in the main source file. ```typescript import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js"; import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"; import { z } from "zod"; const NWS_API_BASE = "https://api.weather.gov"; const USER_AGENT = "weather-app/1.0"; // Create server instance const server = new McpServer({ name: "weather", version: "1.0.0", capabilities: { resources: {}, tools: {}, }, }); ``` -------------------------------- ### Run Tests and Python Setup Source: https://github.com/nibzard/engramdb/blob/main/docs/contributing.mdx Commands to execute the test suite and prepare the Python development environment. ```bash cargo test ``` ```bash cd python pip install maturin maturin develop ``` -------------------------------- ### Basic MCP Server Implementation (Python) Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt A Python example demonstrating how to implement a basic MCP server, including defining a resource listing function and setting up the stdio server transport. ```python import asyncio import mcp.types as types from mcp.server import Server from mcp.server.stdio import stdio_server app = Server("example-server") @app.list_resources() async def list_resources() -> list[types.Resource]: return [ types.Resource( uri="example://resource", name="Example Resource" ) ] async def main(): async with stdio_server() as streams: await app.run( streams[0], streams[1], app.create_initialization_options() ) if __name__ == "__main__": asyncio.run(main()) ``` -------------------------------- ### Install EngramDB and dependencies Source: https://github.com/nibzard/engramdb/blob/main/cookbook/notebooks/README.md Install the necessary Python packages including Jupyter and EngramDB. ```bash pip install jupyter notebook matplotlib seaborn plotly pip install engramdb-py ``` -------------------------------- ### Create and Use Async MCP Client Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Illustrates creating an asynchronous MCP client with custom configurations, including request timeout, capabilities, and consumers for tool, resource, and prompt changes. Demonstrates initializing the connection and chaining asynchronous operations for tool calls, resource management, prompt interactions, and root management. The client is closed gracefully upon completion. ```java McpAsyncClient client = McpClient.async(transport) .requestTimeout(Duration.ofSeconds(10)) .capabilities(ClientCapabilities.builder() .roots(true) // Enable roots capability .sampling() // Enable sampling capability .build()) .sampling(request -> Mono.just(new CreateMessageResult(response))) .toolsChangeConsumer(tools -> Mono.fromRunnable(() -> { logger.info("Tools updated: {}", tools); })) .resourcesChangeConsumer(resources -> Mono.fromRunnable(() -> { logger.info("Resources updated: {}", resources); })) .promptsChangeConsumer(prompts -> Mono.fromRunnable(() -> { logger.info("Prompts updated: {}", prompts); })) .build(); // Initialize connection and use features client.initialize() .flatMap(initResult -> client.listTools()) .flatMap(tools -> { return client.callTool(new CallToolRequest( "calculator", Map.of("operation", "add", "a", 2, "b", 3) )); }) .flatMap(result -> { return client.listResources() .flatMap(resources -> client.readResource(new ReadResourceRequest("resource://uri")) ); }) .flatMap(resource -> { return client.listPrompts() .flatMap(prompts -> client.getPrompt(new GetPromptRequest( "greeting", Map.of("name", "Spring") )) ); }) .flatMap(prompt -> { return client.addRoot(new Root("file:///path", "description")) .then(client.removeRoot("file:///path")); }) .doFinally(signalType -> { client.closeGracefully().subscribe(); }) .subscribe(); ``` -------------------------------- ### Import packages and initialize FastMCP Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Initial setup for the weather server including imports and FastMCP instance creation. ```python from typing import Any import httpx from mcp.server.fastmcp import FastMCP # Initialize FastMCP server mcp = FastMCP("weather") # Constants NWS_API_BASE = "https://api.weather.gov" USER_AGENT = "weather-app/1.0" ``` -------------------------------- ### Combined Query Example Source: https://github.com/nibzard/engramdb/blob/main/docs/api-reference/query.mdx An example demonstrating how to combine multiple filters for a complex query. ```APIDOC ## Combined Query Example ### Description This example shows how to construct and execute a query using multiple attribute and temporal filters. ### Request Example ```rust // Create filters let category_filter = AttributeFilter::equals( "category", AttributeValue::String("work".to_string()) ); let importance_filter = AttributeFilter::greater_than( "importance", AttributeValue::Float(0.7) ); let time_filter = TemporalFilter::within_last(7 * 24 * 60 * 60); // Last week // Build and execute query let results = db.query() .with_vector(vec![0.1, 0.2, 0.3, 0.4]) .with_similarity_threshold(0.6) .with_attribute_filter(category_filter) .with_attribute_filter(importance_filter) .with_temporal_filter(time_filter) .with_limit(10) .execute()?; // Process results for memory in results { println!("Found memory: {:?}", memory); } ``` ``` -------------------------------- ### Create and Use Sync MCP Client Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Demonstrates creating a synchronous MCP client with custom configurations like request timeout and capabilities. Includes initialization, listing tools, calling a tool, managing resources, interacting with prompts, and managing roots. Close the client gracefully when done. ```java McpSyncClient client = McpClient.sync(transport) .requestTimeout(Duration.ofSeconds(10)) .capabilities(ClientCapabilities.builder() .roots(true) // Enable roots capability .sampling() // Enable sampling capability .build()) .sampling(request -> new CreateMessageResult(response)) .build(); // Initialize connection client.initialize(); // List available tools ListToolsResult tools = client.listTools(); // Call a tool CallToolResult result = client.callTool( new CallToolRequest("calculator", Map.of("operation", "add", "a", 2, "b", 3)) ); // List and read resources ListResourcesResult resources = client.listResources(); ReadResourceResult resource = client.readResource( new ReadResourceRequest("resource://uri") ); // List and use prompts ListPromptsResult prompts = client.listPrompts(); GetPromptResult prompt = client.getPrompt( new GetPromptRequest("greeting", Map.of("name", "Spring")) ); // Add/remove roots client.addRoot(new Root("file:///path", "description")); client.removeRoot("file:///path"); // Close client client.closeGracefully(); ``` -------------------------------- ### Create and Use File-Based Database Source: https://github.com/nibzard/engramdb/blob/main/docs/examples/rust-examples.mdx Demonstrates creating a file-based database, initializing it, and saving/loading memory nodes. Ensure the storage directory exists or is created by the application. ```rust use engramdb::{Database, DatabaseConfig, MemoryNode}; use engramdb::core::AttributeValue; use std::error::Error; fn main() -> Result<(), Box> { // Create a file-based database let config = DatabaseConfig { use_memory_storage: false, storage_dir: Some("./my_database".to_string()), cache_size: 100, }; let mut db = Database::new(config)?; println!("Created file-based database"); // Initialize to load existing memories db.initialize()?; // Check if we have existing memories let existing_ids = db.list_all()?; println!("Found {} existing memories", existing_ids.len()); if existing_ids.is_empty() { // Add some test memories let mut memory = MemoryNode::new(vec![0.1, 0.2, 0.3, 0.4]); memory.set_attribute( "title".to_string(), AttributeValue::String("Persistent memory".to_string()) ); let memory_id = db.save(&memory)?; println!("Created new memory with ID: {}", memory_id); } else { // Load and display existing memories for id in existing_ids { let memory = db.load(id)?; if let Some(AttributeValue::String(title)) = memory.get_attribute("title") { println!("Loaded memory: {} (ID: {})", title, id); } } } println!("Database operations completed successfully"); Ok(()) } ``` -------------------------------- ### Perform Basic Database Operations Source: https://github.com/nibzard/engramdb/blob/main/sdks/python-client/README.md Demonstrates initializing the client, creating databases, managing nodes with vector embeddings, and handling connections. ```python from engramdb_client import EngramClient import numpy as np # Initialize the client client = EngramClient(api_url="http://localhost:8000/v1") # Create a database db = client.create_database("my_database") # Create a memory node vector = np.array([0.1, 0.2, 0.3, 0.4]).astype(np.float32) node = db.create_node(vector=vector) # Add attributes to the node node.set_attribute("title", "Important memory") node.set_attribute("category", "meeting") node.save() # Search for similar nodes similar_nodes = db.search(vector=vector, limit=5) for node, similarity in similar_nodes: print(f"Node {node.id}: similarity={similarity:.4f}, title={node.get_attribute('title')}") # Create connections between nodes node2 = db.create_node(vector=np.array([0.15, 0.25, 0.35, 0.45]).astype(np.float32)) node.connect(node2.id, "Association", strength=0.8) # Get connections connections = node.get_connections() for conn in connections: print(f"Connected to {conn['target_id']} with type {conn['type']} (strength: {conn['strength']})") ``` -------------------------------- ### Database Initialization Methods Source: https://github.com/nibzard/engramdb/blob/main/docs/api-reference/database.mdx Methods for creating and configuring new Database instances. ```APIDOC ## Database::in_memory() ### Description Creates a new in-memory database with linear vector search (volatile, for testing and development). ### Returns - A new Database instance using memory storage and linear vector index ## Database::in_memory_with_hnsw() ### Description Creates a new in-memory database with HNSW vector search for faster similarity queries. ### Returns - A new Database instance using memory storage and HNSW vector index ## Database::file_based(dir) ### Description Creates a file-based database at the specified directory with linear vector search. ### Parameters #### Path Parameters - **dir** (&str or Path) - Required - Path to the storage directory ### Returns - A new Database instance using file storage, or an error if initialization failed ## Database::file_based_with_hnsw(dir) ### Description Creates a file-based database at the specified directory with HNSW vector search. ### Parameters #### Path Parameters - **dir** (&str or Path) - Required - Path to the storage directory ### Returns - A new Database instance using file storage and HNSW vector index, or an error if initialization failed ## Database::new(config) ### Description Creates a new database with the given configuration. ### Parameters #### Request Body - **config** (DatabaseConfig) - Required - Configuration options for the database ### Returns - A new Database instance, or an error if initialization failed ``` -------------------------------- ### Install Dependencies with Pip Source: https://github.com/nibzard/engramdb/blob/main/cookbook/providers/anthropic/README.md Installs the necessary Python libraries for EngramDB and Anthropic Claude integration. ```bash pip install anthropic engramdb-py ``` -------------------------------- ### Install uv package manager Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to install the uv package manager on different operating systems. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Run EngramDB Python Examples Source: https://github.com/nibzard/engramdb/blob/main/examples/python/README.md Execute specific example scripts directly using the Python interpreter. ```bash python basic_usage.py python memory_graph.py ``` -------------------------------- ### Initialize .NET Console Project Source: https://github.com/nibzard/engramdb/blob/main/examples/engramdb_mcp_server/mcp-llms.txt Commands to create a new .NET console application for the MCP client. ```bash dotnet new console -n QuickstartClient cd QuickstartClient ```