Skip to content

Commit 848aff2

Browse files
committed
Zed MCP Server Basic Memory. Signed-off-by: Ossfellow <ossfellow@users.noreply.github.com>
Signed-off-by: ossfellow <masoudbahar@gmail.com>
0 parents  commit 848aff2

7 files changed

Lines changed: 263 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
on:
2+
push:
3+
tags:
4+
- "v*"
5+
6+
jobs:
7+
release:
8+
name: Release Zed Extension
9+
runs-on: ubuntu-24.04
10+
steps:
11+
- uses: huacnlee/zed-extension-action@v1
12+
with:
13+
extension-name: mcp-server-basic-memory
14+
# extension-path: extensions/${{ extension-name }}
15+
push-to: ossfellow/zed-mcp-server-basic-memory
16+
env:
17+
# the personal access token should have "repo" & "workflow" scopes
18+
COMMITTER_TOKEN: ${{ secrets.COMMITTER_TOKEN }}

.gitignore

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Generated by Cargo
2+
# will have compiled files and executables
3+
debug/
4+
target/
5+
6+
# These are backup files generated by rustfmt
7+
**/*.rs.bk
8+
9+
# MSVC Windows builds of rustc generate these, which store debugging information
10+
*.pdb
11+
12+
# Helper files
13+
git-push.sh

Cargo.toml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
[package]
2+
name = "mcp_server_basic_memory"
3+
version = "0.0.1"
4+
edition = "2021"
5+
publish = false
6+
license = "Apache-2.0"
7+
description = "A Zed Editor extension that provides Basic Memory integration via MCP"
8+
authors = ["Ossfellow <ossfellow@users.noreply.github.com>"]
9+
repository = "https://github.com/ossfellow/zed-mcp-server-basic-memory"
10+
11+
[lib]
12+
path = "src/mcp_server_basic_memory.rs"
13+
crate-type = ["cdylib"]
14+
15+
[dependencies]
16+
serde = "1.0"
17+
zed_extension_api = "0.4.0"

README.md

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Basic Memory MCP Server Extension for Zed
2+
3+
This extension integrates [Basic Memory](https://github.com/basicmachines-co/basic-memory) as a context server for [Zed's](https://zed.dev) [Assistant](https://zed.dev/docs/assistant/assistant).
4+
5+
Basic Memory lets you build persistent knowledge through natural conversations with Large Language Models, while keeping everything in simple Markdown files on your computer.
6+
7+
## Prerequisites
8+
9+
- Python 3.12+
10+
- [uv](https://github.com/astral-sh/uv) installed
11+
12+
> **⚠️ Important Note**: This extension currently requires Zed to support MCP tools, which is still in development. While you can install the extension now, its functionality will become available once Zed adds MCP tools support in a future update. Follow [Zed's releases](https://github.com/zed-industries/zed/releases) for updates.
13+
14+
## Installation
15+
16+
### 1. Install uv and Basic Memory
17+
18+
```bash
19+
pip install uv
20+
uv tool install basic-memory
21+
```
22+
23+
### 2. Install the extension
24+
25+
Navigate to: **Zed** > **Extensions**. Or use the command palette to search for "extensions".
26+
27+
### 3. Configure the extension
28+
29+
Add the following to your Zed settings:
30+
31+
```json
32+
{
33+
"context_servers": {
34+
"mcp-server-basic-memory": {
35+
"settings": {
36+
"project": "optional-project-name"
37+
}
38+
}
39+
}
40+
}
41+
```
42+
43+
The `project` setting is optional:
44+
45+
- If specified, Basic Memory will use the named project for storing and accessing notes
46+
- If omitted, Basic Memory will use its default project (typically stored in `~/basic-memory/config.json`, or set in the `BASIC_MEMORY_PROJECT` environment variable)
47+
48+
You can configure these settings either:
49+
50+
- Globally in your Zed settings.json
51+
- Per-project in your project settings
52+
- Or omit them to use Basic Memory's default project
53+
54+
## Usage
55+
56+
Once configured, Basic Memory will be available in the Zed Assistant. You can use prompts like:
57+
58+
- "Create a note about software architecture patterns"
59+
- "What do I know about functional programming?"
60+
- "Search my notes for information about React hooks"
61+
62+
## Multiple Projects
63+
64+
Basic Memory supports multiple projects to separate different kinds of notes. If you work on different codebases or subjects, you might want to maintain separate knowledge bases for each.
65+
66+
## Building the Extension
67+
68+
This extension needs to be compiled to WebAssembly (WASM):
69+
70+
1. **Add the WASM target to your Rust toolchain:**
71+
72+
```
73+
rustup target add wasm32-wasip1
74+
```
75+
76+
2. **Build the extension:**
77+
78+
```
79+
cargo build --target wasm32-wasip1 --release
80+
```
81+
82+
### Local Testing
83+
84+
For testing locally:
85+
86+
1. Build the extension as described above
87+
2. In Zed, open Extensions (⌘ + Shift + E)
88+
3. Click "Install Dev Extension" and select the extension directory
89+
4. Your dev extension will override any published version with the same name
90+
91+
> Note: When installing as a dev extension, Zed will automatically use the build artifacts from your target directory.
92+
93+
## Basic Memory Resources
94+
95+
For more detailed information about Basic Memory, visit:
96+
97+
- [Basic Memory Documentation](https://memory.basicmachines.co/)
98+
- [GitHub Repository](https://github.com/basicmachines-co/basic-memory)
99+
100+
## License
101+
102+
This project is licensed under the Apache License, Version 2.0 (the "License"). You may obtain a copy of the License at:
103+
104+
http://www.apache.org/licenses/LICENSE-2.0
105+
106+
This extension interfaces with the `basic-memory` MCP server, which is a separate product developed by [Basic Machines](https://github.com/basicmachines-co) and is licensed under the GNU Affero General Public License, Version 3.0 (AGPL-3.0). The `basic-memory` MCP server's license can be found at:
107+
108+
https://www.gnu.org/licenses/agpl-3.0.html
109+
110+
Please note that while this extension is distributed under the Apache 2.0 License, if you use the `basic-memory` MCP server through this extension, you must comply with its AGPL-3.0 license terms. This extension itself does not incorporate any code from the `basic-memory` MCP server; it only provides an interface to communicate with it as an external service.

extension.toml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
id = "mcp-server-basic-memory"
2+
name = "Basic Memory MCP Server"
3+
description = "Model Context Protocol Server for building persistent knowledge with Basic Memory"
4+
version = "0.0.1"
5+
schema_version = 1
6+
authors = ["Ossfellow <ossfellow@users.noreply.github.com>"]
7+
repository = "https://github.com/ossfellow/zed-mcp-server-basic-memory"
8+
9+
[context_servers.mcp-server-basic-memory]
10+
name = "Basic Memory MCP Server"

extension.wasm

968 KB
Binary file not shown.

src/mcp_server_basic_memory.rs

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
//! Basic Memory MCP Server Extension for Zed
2+
//!
3+
//! This extension integrates Basic Memory's context server with Zed editor through the MCP protocol.
4+
//! It provides project-aware context and memory capabilities by managing the communication between
5+
//! Zed and the Basic Memory server.
6+
//!
7+
//! # Features
8+
//! - Project-specific context management
9+
//! - Integration with Basic Memory through `uvx` command
10+
//! - Configurable project settings
11+
//!
12+
//! # Configuration
13+
//! The extension can be configured through Zed's settings.json or project settings:
14+
//! ```json
15+
//! {
16+
//! "context_servers": {
17+
//! "mcp-server-basic-memory": {
18+
//! "settings": {
19+
//! "project": "optional-project-name" // Optional: Specify a project name for context isolation
20+
//! }
21+
//! }
22+
//! }
23+
//! }
24+
//! ```
25+
//!
26+
//! # Requirements
27+
//! - `uvx` command-line tool must be installed (`pip install uv`)
28+
29+
use serde::Deserialize;
30+
use std::process::Command as ProcessCommand;
31+
use zed::settings::ContextServerSettings;
32+
use zed_extension_api::{self as zed, serde_json, Command, ContextServerId, Project, Result};
33+
34+
// Project is a valid setting for Basic Memory
35+
#[derive(Debug, Deserialize)]
36+
struct BasicMemoryContextServerSettings {
37+
// Optional project name
38+
project: Option<String>,
39+
}
40+
41+
// Basic Memory context server extension
42+
struct BasicMemoryModelContextExtension;
43+
44+
impl zed::Extension for BasicMemoryModelContextExtension {
45+
fn new() -> Self {
46+
Self
47+
}
48+
49+
// Returns the command to run the Basic Memory context server
50+
fn context_server_command(
51+
&mut self,
52+
_context_server_id: &ContextServerId,
53+
project: &Project,
54+
) -> Result<Command> {
55+
// First, verify that uvx is available
56+
if !is_uvx_available() {
57+
return Err("'uvx' command not found. Please install uv: 'pip install uv'".into());
58+
}
59+
60+
// Get settings from Zed project configuration
61+
let settings = ContextServerSettings::for_project("mcp-server-basic-memory", project)?;
62+
63+
// Create command with standard args structure
64+
// Important: `--project` must come BEFORE "mcp" in the args list
65+
let mut args = vec!["basic-memory".to_string()];
66+
67+
// Add project flag if specified - it must go BEFORE the "mcp" command
68+
if let Some(settings_value) = settings.settings {
69+
let settings: BasicMemoryContextServerSettings =
70+
serde_json::from_value(settings_value).map_err(|e| e.to_string())?;
71+
72+
if let Some(project_name) = settings.project {
73+
args.push("--project".to_string());
74+
args.push(project_name);
75+
}
76+
}
77+
78+
// Add the mcp command AFTER any project specification
79+
args.push("mcp".to_string());
80+
81+
// Return the command configuration
82+
Ok(Command {
83+
command: "uvx".to_string(),
84+
args,
85+
env: vec![], // No environment variables needed in the standard config
86+
})
87+
}
88+
}
89+
90+
// Helper function to check if uvx is available
91+
fn is_uvx_available() -> bool {
92+
ProcessCommand::new("uvx").arg("--version").output().is_ok()
93+
}
94+
95+
zed::register_extension!(BasicMemoryModelContextExtension);

0 commit comments

Comments
 (0)