### Example Client Command for Weather Tutorial Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md An example command for running the client if you are continuing the weather tutorial from the server quickstart. ```bash python client.py .../weather/src/weather/server.py ``` -------------------------------- ### Set up Python Project and Environment (Windows) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Creates a new project directory, initializes a virtual environment using uv, installs MCP and httpx dependencies, and creates the main server file. This setup is for Windows. ```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 ``` -------------------------------- ### Set up Python Project and Environment Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Creates a new project directory, initializes a virtual environment using uv, installs MCP and httpx dependencies, and creates the main server file. This setup is for MacOS/Linux. ```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 ``` -------------------------------- ### Build and Start Server with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/build-with-bun.md Combines the build and start processes into a single command for convenience. ```bash bun run build:start ``` -------------------------------- ### Install Bun Runtime Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/bun-migration.md Use this command to install the Bun runtime on your system. ```bash curl -fsSL https://bun.sh/install | bash ``` -------------------------------- ### Verify Installation with Help Flag Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/npx-usage.md Check the installation and available commands by running Memory Bank MCP with the --help flag. ```bash npx @movibe/memory-bank-mcp --help ``` -------------------------------- ### Inspect NPM Package Server Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Start an MCP server package from NPM using the Inspector. This example demonstrates how to run a 'server-postgres' package with its arguments. ```bash npx -y @modelcontextprotocol/inspector npx # For example npx -y @modelcontextprotocol/inspector npx server-postgres postgres://127.0.0.1/testdb ``` -------------------------------- ### Install Dependencies and Run Integration Test Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/integration-testing-guide.md These commands show how to install the necessary npm package and execute the integration test script. ```bash # Install dependencies npm install axios # Run the test script node test-integration.js ``` -------------------------------- ### Start Server with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/build-with-bun.md Launches the Memory Bank Server using Bun. ```bash bun run start ``` -------------------------------- ### Inspect PyPi Package Server Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Start an MCP server package from PyPi using the Inspector. This example shows how to run a 'mcp-server-git' package with its repository path. ```bash npx @modelcontextprotocol/inspector uvx # For example npx @modelcontextprotocol/inspector uvx mcp-server-git --repository ~/code/mcp/servers.git ``` -------------------------------- ### Install and Run Python MCP Server with pip Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Install and run a Python-based MCP server using pip. Ensure the server is installed before running. ```bash pip install mcp-server-git python -m mcp_server_git ``` -------------------------------- ### Asynchronous MCP Server Setup Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md This snippet illustrates the setup for an asynchronous MCP server. It covers server creation, capability configuration, asynchronous registration of components with reactive callbacks, sending logging notifications, and closing the server. ```java McpAsyncServer asyncServer = McpServer.async(transport) .serverInfo("my-server", "1.0.0") .capabilities(ServerCapabilities.builder() .resources(true) // Enable resource support .tools(true) // Enable tool support .prompts(true) // Enable prompt support .logging() // Enable logging support .build()) .build(); // Register tools, resources, and prompts asyncServer.addTool(asyncToolRegistration) .doOnSuccess(v -> logger.info("Tool registered")) .subscribe(); asyncServer.addResource(asyncResourceRegistration) .doOnSuccess(v -> logger.info("Resource registered")) .subscribe(); asyncServer.addPrompt(asyncPromptRegistration) .doOnSuccess(v -> logger.info("Prompt registered")) .subscribe(); // Send logging notifications asyncServer.loggingNotification(LoggingMessageNotification.builder() .level(LoggingLevel.INFO) .logger("custom-logger") .data("Server initialized") .build()); // Close the server when done asyncServer.close() .doOnSuccess(v -> logger.info("Server closed")) .subscribe(); ``` -------------------------------- ### Install and Run Python MCP Server with uvx Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Install and run a Python-based MCP server using uvx, the recommended package manager. ```bash uvx mcp-server-git ``` -------------------------------- ### Install npx Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Installs npx globally using npm. Ensure npm is installed first. ```bash npm install -g npx ``` -------------------------------- ### Create MCP Client Manually with Java Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Instantiate and use the McpClient to connect to an MCP server via STDIO transport. This example demonstrates listing tools and calling a tool to get weather forecast. ```java var stdioParams = ServerParameters.builder("java") .args("-jar", "/ABSOLUTE/PATH/TO/PARENT/FOLDER/mcp-weather-stdio-server-0.0.1-SNAPSHOT.jar") .build(); var stdioTransport = new StdioClientTransport(stdioParams); var mcpClient = McpClient.sync(stdioTransport).build(); mcpClient.initialize(); ListToolsResult toolsList = mcpClient.listTools(); CallToolResult weather = mcpClient.callTool( new CallToolRequest("getWeatherForecastByLocation", Map.of("latitude", "47.6062", "longitude", "-122.3321"))); CallToolResult alert = mcpClient.callTool( new CallToolRequest("getAlerts", Map.of("state", "NY"))); mcpClient.closeGracefully(); ``` -------------------------------- ### Example Root URIs Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Illustrates example URIs that can be used as roots, including local file paths and HTTP URLs. ```plaintext file:///home/user/projects/myapp https://api.example.com/v1 ``` -------------------------------- ### Command Line Usage Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cline-integration.md You can specify the initial mode when starting the server using the command line. ```APIDOC ## Command Line Usage You can specify the initial mode when starting the server: ```bash memory-bank-mcp --mode architect # or memory-bank-mcp -m code ``` ``` -------------------------------- ### Verify Node.js and npm Installation Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Check if Node.js and npm are installed and meet the version requirements for the project. ```bash node --version npm --version ``` -------------------------------- ### Specify Initial Mode on Server Start Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cline-integration.md Use the `--mode` or `-m` flag to set the initial operating mode when starting the memory-bank-mcp server. ```bash memory-bank-mcp --mode architect # or memory-bank-mcp -m code ``` -------------------------------- ### Start Server in Development Mode with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/build-with-bun.md Initiates the server in development mode, enabling hot reloading for faster iteration. ```bash bun run dev ``` -------------------------------- ### Main Module Entry Point Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/modular-architecture-proposal.md This is the main entry point for the application. It imports and instantiates the MemoryBankServer and starts the server. ```typescript #!/usr/bin/env node import { MemoryBankServer } from "./server/MemoryBankServer"; const server = new MemoryBankServer(); server.run().catch(console.error); ``` -------------------------------- ### YAML Rule File Example Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/rule-formats.md Example of a rule file in YAML format, used for architect mode. Includes general and UMB-specific instructions, along with mode triggers. ```yaml # Rules for architect mode mode: architect instructions: # General instructions applied to all interactions general: - Act as an experienced software architect - Provide high-level guidance on code structure - Suggest appropriate design patterns # UMB (Universal Memory Bank) specific configuration umb: trigger: architect instructions: - Analyze the project structure in the Memory Bank - Suggest architectural improvements based on the current context override_file_restrictions: true # Triggers that automatically activate this mode mode_triggers: architect: - condition: How should we structure - condition: What is the best architecture - condition: Design pattern for ``` -------------------------------- ### Start Memory Bank Server Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/testing-clinerules.md Execute the command to start the Memory Bank Server. Ensure the server detects the .clinerules-code file and operates in the 'code' mode. ```bash memory-bank-mcp ``` -------------------------------- ### Implement MCP Server Resource Handling (TypeScript) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Example implementation of an MCP server in TypeScript, demonstrating how to handle resource listing and reading requests. ```typescript const server = new Server({ name: "example-server", version: "1.0.0" }, { capabilities: { resources: {} } }); // List available resources server.setRequestHandler(ListResourcesRequestSchema, async () => { return { resources: [ { uri: "file:///logs/app.log", name: "Application Logs", mimeType: "text/plain" } ] }; }); // Read resource contents server.setRequestHandler(ReadResourceRequestSchema, async (request) => { const uri = request.params.uri; if (uri === "file:///logs/app.log") { const logContents = await readLogFile(); return { contents: [ { uri, mimeType: "text/plain", text: logContents } ] }; } throw new Error("Resource not found"); }); ``` -------------------------------- ### Start Memory Bank MCP Server in Ask Mode Source: https://github.com/movibe/memory-bank-mcp/blob/main/README.md Initiates the Memory Bank MCP server, optimizing it for answering questions and providing information. ```bash npx @movibe/memory-bank-mcp --mode ask ``` -------------------------------- ### Run MCP Client with Relative Server Path Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Example of using a relative path to specify the server script when running the client. ```bash uv run client.py ./server/weather.py ``` -------------------------------- ### Clinerules Integration Tests Setup Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/testing-clinerules.md Sets up a temporary directory and .clinerules files for testing. Initializes ExternalRulesLoader and ModeManager. Cleans up resources after tests. ```typescript import fs from "fs-extra"; import path from "path"; import { spawn } from "child_process"; import { ExternalRulesLoader } from "../src/utils/ExternalRulesLoader"; import { ModeManager } from "../src/utils/ModeManager"; describe("Clinerules Integration Tests", () => { const tempDir = path.join(__dirname, "temp"); let rulesLoader: ExternalRulesLoader; let modeManager: ModeManager; beforeEach(async () => { // Create temporary directory await fs.ensureDir(tempDir); // Create test .clinerules files await fs.writeFile( path.join(tempDir, ".clinerules-code"), JSON.stringify({ mode: "code", instructions: { general: ["Test instruction"], umb: { trigger: "^(Update Memory Bank|UMB)$", instructions: ["Test UMB instruction"], override_file_restrictions: true, }, }, }) ); // Initialize test objects rulesLoader = new ExternalRulesLoader(tempDir); modeManager = new ModeManager(rulesLoader); await modeManager.initialize(); }); afterEach(async () => { // Clean up modeManager.dispose(); await fs.remove(tempDir); }); test("Should detect and load .clinerules files", async () => { const rules = await rulesLoader.detectAndLoadRules(); expect(rules.size).toBe(1); expect(rules.has("code")).toBe(true); }); test("Should switch modes correctly", () => { const result = modeManager.switchMode("code"); expect(result).toBe(true); const state = modeManager.getCurrentModeState(); expect(state.name).toBe("code"); }); test("Should detect UMB trigger", () => { const result = modeManager.checkUmbTrigger("Update Memory Bank"); expect(result).toBe(true); }); // Add more tests as needed }); ``` -------------------------------- ### List Memory Bank Files Response Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/mcp-protocol-specification.md Example JSON response for the GET /memory-bank/files endpoint, listing all available files. ```json { "files": [ "activeContext.md", "productContext.md", "progress.md", "decisionLog.md", "systemPatterns.md" ], "status": "success" } ``` -------------------------------- ### Basic Test Structure with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/testing.md Organize tests using `describe` for grouping and `test` for individual cases. Use `beforeEach` and `afterEach` for setup and cleanup. ```typescript describe("Feature Name", () => { beforeEach(() => { // Setup code }); afterEach(() => { // Cleanup code }); test("should do something", () => { // Test code expect(result).toBe(expectedValue); }); }); ``` -------------------------------- ### List Memory Bank Modes Response Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/mcp-protocol-specification.md Example JSON response for the GET /memory-bank/modes endpoint, listing available operational modes. ```json { "modes": [ "architect", "code", "ask", "debug", "test" ], "status": "success" } ``` -------------------------------- ### Retrieve Memory Bank File Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/mcp-protocol-specification.md Example JSON response for retrieving the content of a Memory Bank file using GET /memory-bank/file/:filename. ```json { "content": "# File Content\n\nThis is the content of the file.", "status": "success" } ``` -------------------------------- ### Initialize MCP Client Environment Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Sets up the project directory, virtual environment, and installs necessary packages using `uv`. Activates the virtual environment for subsequent commands. ```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 hello.py # Create our main file touch client.py ``` -------------------------------- ### Set up Node.js Project Environment (Windows) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Commands to create a new project directory, initialize an npm project, install dependencies, and set up project files on Windows. ```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 ``` -------------------------------- ### Set Up Initial Tasks Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cursor-integration.md Updates the active context with initial tasks and next steps for a project. Use this after initializing the project. ```bash /mcp memory-bank-mcp update_active_context tasks=["Set up project structure", "Implement core features"] nextSteps=["Create initial files", "Set up testing framework"] ``` -------------------------------- ### Create and Use Async MCP Client Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Illustrates setting up an asynchronous MCP client with custom configurations for timeouts, capabilities, and event consumers for tools, resources, and prompts. The example shows chaining asynchronous operations for initialization, tool calls, resource management, and prompt interactions, concluding with graceful client closure. ```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(); ``` -------------------------------- ### Set up Node.js Project Environment (MacOS/Linux) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Commands to create a new project directory, initialize an npm project, install dependencies, and set up project files on MacOS/Linux. ```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 ``` -------------------------------- ### Install uv Package Manager Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Installs the uv package manager for MacOS/Linux or Windows. Restart your terminal after installation. ```bash curl -LsSf https://astral.sh/uv/install.sh | sh ``` ```powershell powershell -ExecutionPolicy ByPass -c "irm https://astral.sh/uv/install.ps1 | iex" ``` -------------------------------- ### Install Memory Bank MCP Source: https://github.com/movibe/memory-bank-mcp/blob/main/README.md Install the Memory Bank MCP package using npm. You can install it locally for a specific project or globally for system-wide access. Alternatively, use npx to run it without installation. ```bash # Install from npm npm install @movibe/memory-bank-mcp # Or install globally npm install -g @movibe/memory-bank-mcp # Or run directly with npx (no installation required) npx @movibe/memory-bank-mcp ``` -------------------------------- ### Create and Use Sync MCP Client Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Demonstrates creating a synchronous MCP client with custom configurations for request timeouts and capabilities. Shows initialization, listing tools, calling a tool, managing resources, and interacting with prompts. Ensure to close the client gracefully after use. ```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(); ``` -------------------------------- ### Install NPM Globally Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md If the `npx` command fails, it may be due to NPM not being installed globally. Run this command to install NPM globally, which is often a prerequisite for `npx` to function correctly. ```bash npm install -g npm ``` -------------------------------- ### Web Client Integration Example Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/ai-assistant-integration.md This HTML and JavaScript code demonstrates how to set up a basic chat interface for an AI assistant that uses Memory Bank MCP for context. It includes initializing the clients, handling user input, sending messages to the assistant with project context, and displaying responses. ```html AI Assistant with Memory Bank
``` -------------------------------- ### Build and Run Application (JAR) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Builds the application and runs it as a JAR file. ```bash ./mvnw clean install java -jar ./target/ai-mcp-brave-chatbot-0.0.1-SNAPSHOT.jar ``` -------------------------------- ### Global Installation Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/npx-usage.md Install Memory Bank MCP globally using npm for direct command-line access. ```bash npm install -g @movibe/memory-bank-mcp ``` ```bash memory-bank-mcp ``` -------------------------------- ### Implement MCP Server Resource Handling (Python) Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Example implementation of an MCP server in Python, demonstrating how to handle resource listing and reading requests, including server startup. ```python app = Server("example-server") @app.list_resources() async def list_resources() -> list[types.Resource]: return [ types.Resource( uri="file:///logs/app.log", name="Application Logs", mimeType="text/plain" ) ] @app.read_resource() async def read_resource(uri: AnyUrl) -> str: if str(uri) == "file:///logs/app.log": log_contents = await read_log_file() return log_contents raise ValueError("Resource not found") # Start server async with stdio_server() as streams: await app.run( streams[0], streams[1], app.create_initialization_options() ) ``` -------------------------------- ### Main Entry Point for Client Script Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Sets up the main execution logic for the client script, including argument parsing, client initialization, server connection, and chat loop execution. ```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()) ``` -------------------------------- ### Clone Repository and Navigate Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Clones the spring-ai-examples repository and navigates into the brave-chatbot directory. ```bash git clone https://github.com/spring-projects/spring-ai-examples.git cd model-context-protocol/brave-chatbot ``` -------------------------------- ### Verify npx Installation Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cursor-integration.md Check if npx is installed and available on your system. This is a prerequisite for running Memory Bank MCP via npx. ```bash npx --version ``` -------------------------------- ### Configure MCP Client Boot Starter Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Set the 'spring.ai.mcp.client.stdio.servers-configuration' property to the path of your 'claude_desktop_config.json' file. This allows auto-configuration to create MCP clients on application startup. ```properties spring.ai.mcp.client.stdio.servers-configuration=file:PATH/TO/claude_desktop_config.json ``` -------------------------------- ### Start Memory Bank MCP Server Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/ai-assistant-integration.md Command to start the Memory Bank MCP server on a specified port and memory bank path. ```bash # Start Memory Bank MCP server npx memory-bank-mcp-server --port 3000 --memory-bank-path /path/to/memory-bank ``` -------------------------------- ### Write Product Context Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cursor-integration.md Writes content to a product context file. Ensure the content is properly formatted before writing. ```bash /mcp memory-bank-mcp write_memory_bank_file filename=product-context.md content="..." ``` -------------------------------- ### Verify Node.js Installation Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Run this command in your terminal or command prompt to check if Node.js is installed on your system. If an error occurs, download Node.js from nodejs.org. ```bash node --version ``` -------------------------------- ### Start Conversation in Code Mode Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/usage-modes.md Use this cURL command to start a chat session in Code Mode. This mode is for writing, modifying, and maintaining code. ```bash curl -X POST http://localhost:3000/chat \ -H "Content-Type: application/json" \ -d '{ "messages": [ { "role": "system", "content": "You are in code mode. Help implement features." }, { "role": "user", "content": "I need to implement a function to validate JWT tokens." } ], "mode": "code" }' ``` -------------------------------- ### Synchronous MCP Server Setup Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Use this snippet to create and configure a synchronous MCP server. It demonstrates how to set server information, define capabilities, register components, send logging notifications, and close the server. ```java McpSyncServer syncServer = McpServer.sync(transport) .serverInfo("my-server", "1.0.0") .capabilities(ServerCapabilities.builder() .resources(true) // Enable resource support .tools(true) // Enable tool support .prompts(true) // Enable prompt support .logging() // Enable logging support .build()) .build(); // Register tools, resources, and prompts syncServer.addTool(syncToolRegistration); syncServer.addResource(syncResourceRegistration); syncServer.addPrompt(syncPromptRegistration); // Send logging notifications syncServer.loggingNotification(LoggingMessageNotification.builder() .level(LoggingLevel.INFO) .logger("custom-logger") .data("Server initialized") .build()); // Close the server when done syncServer.close(); ``` -------------------------------- ### Implement Basic Tool in Python Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Example of implementing a 'calculate_sum' tool in an MCP server using Python. Includes defining the tool and handling its invocation using decorators. ```python app = Server("example-server") @app.list_tools() async def list_tools() -> list[types.Tool]: return [ types.Tool( name="calculate_sum", description="Add two numbers together", inputSchema={ "type": "object", "properties": { "a": {"type": "number"}, "b": {"type": "number"} }, "required": ["a", "b"] } ) ] @app.call_tool() async def call_tool( name: str, arguments: dict ) -> list[types.TextContent | types.ImageContent | types.EmbeddedResource]: if name == "calculate_sum": a = arguments["a"] b = arguments["b"] result = a + b return [types.TextContent(type="text", text=str(result))] raise ValueError(f"Tool not found: {name}") ``` -------------------------------- ### Example: Fix Bug Commit Source: https://github.com/movibe/memory-bank-mcp/blob/main/CONTRIBUTING.md An example of a commit message for fixing a bug, detailing the issue and the resolution. It also includes closing a GitHub issue. ```markdown fix(core): resolve issue with file path resolution The file path resolution was not working correctly on Windows. This commit fixes the issue by using path.resolve() instead of string concatenation. Closes #456 ``` -------------------------------- ### TOML Rule File Example Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/rule-formats.md Example of a rule file in TOML format, used for debug mode. Features nested configurations for instructions and mode triggers. ```toml # Rules for debug mode mode = "debug" [instructions] # General instructions applied to all interactions general = [ "Act as a debugging expert", "Help identify and fix code issues", "Suggest debugging tools and techniques" ] # UMB (Universal Memory Bank) specific configuration [instructions.umb] trigger = "debug" instructions = [ "Analyze logs and errors in the Memory Bank context", "Suggest debugging strategies based on project history" ] override_file_restrictions = true # Triggers that automatically activate this mode [mode_triggers.debug] condition = [ { condition = "How can I debug" }, { condition = "I'm getting an error" }, { condition = "The code isn't working" } ] ``` -------------------------------- ### Example: Add Feature Commit Source: https://github.com/movibe/memory-bank-mcp/blob/main/CONTRIBUTING.md An example of a commit message for adding a new feature, including type, scope, subject, body, and closing a GitHub issue. ```markdown feat(memory-bank): add support for custom templates Add ability to use custom templates for Memory Bank files. Closes #123 ``` -------------------------------- ### Import Packages and Set Up MCP Server Instance Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Initial TypeScript code for setting up the MCP server instance, including necessary imports and server configuration. ```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", }); ``` -------------------------------- ### Install and Run MCP Inspector Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Run the MCP Inspector directly using npx without prior installation. This command is used to execute various inspector commands. ```bash npx @modelcontextprotocol/inspector ``` ```bash npx @modelcontextprotocol/inspector ``` -------------------------------- ### Build Project with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/build-with-bun.md Executes a clean build of the project, outputting artifacts to the build directory. ```bash bun run build ``` -------------------------------- ### Get Prompt Request and Response Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Demonstrates a typical request to get a prompt named 'analyze-code' and its corresponding response structure, including user messages with text content. ```typescript // Request { method: "prompts/get", params: { name: "analyze-code", arguments: { language: "python" } } } // Response { description: "Analyze Python code for potential improvements", messages: [ { role: "user", content: { type: "text", text: "Please analyze the following Python code for potential improvements:\n\n```python\ndef calculate_sum(numbers):\n total = 0\n for num in numbers:\n total = total + num\n return total\n\nresult = calculate_sum([1, 2, 3, 4, 5])\nprint(result)\n```" } } ] } ``` -------------------------------- ### Implement MCP Server in Python Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Basic example of implementing an MCP server using the Python SDK. Defines a server instance and a request handler for listing resources using a decorator, then runs the server over stdio. ```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) ``` -------------------------------- ### get_current_mode Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/cline-integration.md Gets information about the current mode. ```APIDOC ## get_current_mode Gets information about the current mode. ### Request Body ```json { "name": "get_current_mode", "arguments": { "random_string": "dummy" } } ``` ``` -------------------------------- ### Initialize FastMCP Server and Define Constants Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Imports necessary packages and initializes the FastMCP server instance. Defines constants for the National Weather Service API base URL and a user agent. ```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" ``` -------------------------------- ### Example Test Structure with Bun Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/testing-guide.md Demonstrates a typical test file structure using Bun's testing utilities, including describe blocks, beforeEach/afterEach hooks, and assertions. ```typescript import { test, expect, describe, beforeEach, afterEach, mock } from "bun:test"; import { SomeClass } from "../path/to/module.js"; describe("SomeClass Tests", () => { let instance: SomeClass; beforeEach(() => { // Setup code instance = new SomeClass(); }); afterEach(() => { // Cleanup code }); test("Should do something", () => { // Test code const result = instance.someMethod(); expect(result).toBe(expectedValue); }); }); ``` -------------------------------- ### Get Memory Bank Status Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/mcp-protocol-specification.md Checks the status of the Memory Bank. ```APIDOC ## mcp__get_memory_bank_status ### Description Checks Memory Bank status. ### Parameters None ``` -------------------------------- ### Basic MCP Client Structure Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/requirements.md Initializes the MCP client with necessary imports, session management, and an Anthropic client instance. Loads environment variables from a `.env` file. ```python import asyncio from typing import Optional from contextlib import AsyncExitStack from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client from anthropic import Anthropic from dotenv import load_dotenv load_dotenv() # load environment variables from .env class MCPClient: def __init__(self): # Initialize session and client objects self.session: Optional[ClientSession] = None self.exit_stack = AsyncExitStack() self.anthropic = Anthropic() # methods will go here ``` -------------------------------- ### Initialize Memory Bank Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/testing-clinerules.md Use the 'initialize_memory_bank' tool to set up a new memory bank instance, specifying the path for its storage. This is a prerequisite for subsequent operations. ```json { "name": "initialize_memory_bank", "arguments": { "path": "." } } ``` -------------------------------- ### Log Decision Response Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/mcp-protocol-specification.md Example JSON response for a successful decision logging operation. ```json { "status": "success", "message": "Decision logged successfully" } ``` -------------------------------- ### Example User Interactions with Memory Bank Status Prefixes Source: https://github.com/movibe/memory-bank-mcp/blob/main/docs/memory-bank-status-prefix.md Illustrates typical user interactions and the corresponding AI assistant responses, including different Memory Bank status prefixes. This shows how the system provides real-time operational feedback. ```text User: What's the current status of the authentication feature? [MEMORY BANK: ACTIVE] Based on the project history in the Memory Bank, the authentication feature is currently in development. According to the progress.md file, the team implemented basic user registration last week and is now working on the login functionality. The decision-log.md shows that JWT was selected as the authentication method over session-based authentication. ``` ```text User: What's the status of the Memory Bank? [MEMORY BANK: INACTIVE] I cannot access the Memory Bank at the moment. The Memory Bank directory or its core files may be missing. Would you like me to switch to Architect mode to initialize the Memory Bank? ``` ```text User: Update Memory Bank [MEMORY BANK: UPDATING] I'm now updating the Memory Bank based on our conversation. I'll add information about the authentication feature discussion to the progress.md file and update the active-context.md with the current tasks. [MEMORY BANK: ACTIVE] Memory Bank has been updated successfully. I've added our discussion about the authentication feature to the progress.md file and updated the active-context.md with the current tasks. ```