Skip to content

Commit 85788ed

Browse files
committed
Update README.md and server.py documentation for clarity and consistency. Revise installation instructions, enhance usage examples, and improve memory file guidelines.
1 parent 43e3dee commit 85788ed

File tree

2 files changed

+94
-61
lines changed

2 files changed

+94
-61
lines changed

README.md

Lines changed: 89 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Project Memory MCP
22

3-
An MCP Server to store and retrieve project information from memory files. This allows AI agents (like Claude) to maintain persistent memory about projects between conversations.
3+
An MCP Server to store and retrieve project information from memory file. This allows AI agents (like Claude) to maintain persistent memory about projects between conversations.
44

55
## Overview
66

@@ -13,38 +13,17 @@ The memory is stored in a `MEMORY.md` file in each project directory.
1313

1414
## Installation
1515

16-
### Local installation
16+
### Using uvx
1717

18-
#### Prerequisites
19-
20-
- Python 3.11 or higher
21-
- Pip package manager
22-
23-
#### Install from PyPI
24-
25-
```bash
26-
pip install project-mem-mcp
27-
```
28-
29-
#### Install from Source
30-
31-
```bash
32-
git clone https://github.com/your-username/project-mem-mcp.git
33-
cd project-mem-mcp
34-
pip install -e .
35-
```
36-
37-
## Usage
38-
39-
The MCP server is started by the client (e.g., Claude Desktop) based on the configuration you provide. You don't need to start the server manually.
18+
This method uses `uvx` (from the `uv` Python package manager) to run the server without permanent installation:
4019

41-
### Integration with Claude Desktop
20+
#### Prerequisites
4221

43-
To use this MCP server with Claude Desktop, you need to add it to your `claude_desktop_config.json` file:
22+
Install `uvx` from [uv](https://docs.astral.sh/uv/installation/) if you don't have it already.
4423

45-
#### Using uvx (Recommended)
24+
#### Set up MCP Client (Claude Desktop, Cursor, etc.)
4625

47-
This method uses `uvx` (from the `uv` Python package manager) to run the server without permanent installation:
26+
Merge the following config with your existing config file (e.g. `claude_desktop_config.json`):
4827

4928
```json
5029
{
@@ -61,15 +40,33 @@ This method uses `uvx` (from the `uv` Python package manager) to run the server
6140
}
6241
```
6342

64-
#### Using pip installed version
43+
> **Note:** Replace `/Users/your-username` with the actual path to your own projects and code directories.
6544
66-
If you've installed the package with pip:
45+
### Install from Source
46+
47+
#### Prerequisites
48+
49+
- Python 3.11 or higher
50+
- Pip package manager
51+
52+
#### Clone the repository
53+
54+
```bash
55+
git clone https://github.com/your-username/project-mem-mcp.git
56+
python -m venv venv
57+
source venv/bin/activate
58+
pip install -e .
59+
```
60+
61+
#### Set up MCP Client (Claude Desktop, Cursor, etc.)
62+
63+
Merge the following config with your existing config file (e.g. `claude_desktop_config.json`):
6764

6865
```json
6966
{
7067
"mcpServers": {
7168
"project-memory": {
72-
"command": "project-mem-mcp",
69+
"command": "path/to/your/venv/bin/project-mem-mcp",
7370
"args": [
7471
"--allowed-dir", "/Users/your-username/projects",
7572
"--allowed-dir", "/Users/your-username/Documents/code"
@@ -79,48 +76,85 @@ If you've installed the package with pip:
7976
}
8077
```
8178

82-
### Configuring Claude Desktop
79+
> **Note:** Replace `/Users/your-username` with the actual path to your own projects and code directories.
8380
84-
1. Install Claude Desktop from the [official website](https://claude.ai/desktop)
85-
2. Open Claude Desktop
86-
3. From the menu, select Settings → Developer → Edit Config
87-
4. Replace the config with one of the examples above (modify paths as needed)
88-
5. Save and restart Claude Desktop
81+
## Arguments
8982

90-
## Tools
83+
The `--allowed-dir` argument is used to specify the directories that the server has access to. You can use it multiple times to allow access to multiple directories. All directories inside the allowed directories are also allowed.
84+
It is optional. If not provided, the server will only have access to the home directory of the user running the server.
85+
86+
87+
## Usage
88+
89+
The MCP server is started by the client (e.g., Claude Desktop) based on the configuration you provide. You don't need to start the server manually.
90+
91+
### Tools
9192

9293
Project Memory MCP provides three tools:
9394

94-
### get_project_memory
95+
#### get_project_memory
9596

96-
Retrieves the entire project memory. Should be used at the beginning of every conversation.
97+
Retrieves the entire project memory in Markdown format. Should be used at the beginning of every conversation about a project.
9798

98-
```
99+
```python
99100
get_project_memory(project_path: str) -> str
100101
```
102+
- **project_path**: Full path to the project directory.
103+
- Returns the content of the MEMORY.md file as a string.
104+
- Raises `FileNotFoundError` if the project or memory file does not exist.
105+
- Raises `PermissionError` if the project path is not in allowed directories.
101106

102-
### set_project_memory
107+
#### set_project_memory
103108

104-
Sets the entire project memory. Use when creating a new memory file or when updates fail.
109+
Sets (overwrites) the entire project memory. Use this when creating a new memory file, replacing the whole memory, or if `update_project_memory` fails.
105110

106-
```
111+
```python
107112
set_project_memory(project_path: str, project_info: str)
108113
```
114+
- **project_path**: Full path to the project directory.
115+
- **project_info**: Complete project information in Markdown format.
116+
- Overwrites the MEMORY.md file with the provided content.
117+
- Raises `FileNotFoundError` if the project path does not exist.
118+
- Raises `PermissionError` if the project path is not in allowed directories.
109119

110-
### update_project_memory
120+
#### update_project_memory
111121

112-
Updates the project memory by applying a unified diff/patch. More efficient for small changes.
122+
Updates the project memory by applying one or more block-based patches to the memory file. This is more efficient for small changes.
113123

124+
```python
125+
update_project_memory(project_path: str, patch_content: str)
114126
```
115-
update_project_memory(project_path: str, project_info: str)
116-
```
117-
118-
## Example Workflow
119-
120-
1. Begin a conversation with Claude about a project
121-
2. Claude uses `get_project_memory` to retrieve project information
122-
3. Throughout the conversation, Claude uses `update_project_memory` to persist new information
123-
4. If the update fails, Claude can use `set_project_memory` instead
127+
- **project_path**: Full path to the project directory.
128+
- **patch_content**: Block-based patch content using SEARCH/REPLACE markers (see below).
129+
- Each patch block must have the following format:
130+
131+
```
132+
<<<<<<< SEARCH
133+
Text to find in the memory file
134+
=======
135+
Text to replace it with
136+
>>>>>>> REPLACE
137+
```
138+
Multiple blocks can be included in a single request.
139+
- Each search text must appear **exactly once** in the file, otherwise an error is raised.
140+
- Raises `FileNotFoundError` if the project or memory file does not exist.
141+
- Raises `ValueError` if the patch format is invalid or the search text is not unique.
142+
- Raises `RuntimeError` if patch application fails for any reason.
143+
144+
### Example Workflow
145+
146+
1. Begin a conversation with LLM about a project
147+
2. LLM uses `get_project_memory` to retrieve project information
148+
3. Throughout the conversation, LLM uses `update_project_memory` to persist new information
149+
4. If the update fails, LLM can use `set_project_memory` instead
150+
151+
#### Claude Desktop
152+
153+
if you use Claude Desktop, it is best to use the project feature.
154+
155+
Edit the project instructions:
156+
- Add a line like this: "The path of the project is <project_path>"
157+
- If it does not always use the memory, you can add a line like this: "Always use the project memory, it is not optional"
124158

125159
## Security Considerations
126160

@@ -131,7 +165,6 @@ update_project_memory(project_path: str, project_info: str)
131165
## Dependencies
132166

133167
- fastmcp (>=2.2.0, <3.0.0)
134-
- patch-ng (>=1.18.0, <2.0.0)
135168

136169
## License
137170

src/project_mem_mcp/server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@
1515
mcp = FastMCP(
1616
name="Project Memory MCP",
1717
instructions=f"""
18-
This MCP is for storing and retrieving project information to/from an English memory file.
18+
This MCP is for storing and retrieving project information to/from an English memory file, named
19+
`{MEMORY_FILE}` in the project directory.
1920
2021
The memory file should store all information about the project in short and concise manner. It should be
2122
good for humans and AI agents to catch up on the project status and progress quickly. Should contain descriptions,
22-
ongoing tasks, tasks to do, references to files and other project resources, even URLs where to get more information.
23-
24-
The memory file is a Markdown file named `{MEMORY_FILE}` in the project directory.
23+
ongoing tasks, tasks to do, discoveries, references to files and other project resources, URLs where to get more
24+
information, etc.
2525
2626
Rules:
2727
- This must be read by `get_project_memory` tool in the beginning of the first request of every conversation
@@ -32,7 +32,7 @@
3232
- The `set_project_memory` tool must be used to set the whole project memory if `update_project_memory`
3333
failed or there is no project memory yet.
3434
- Never store any sensitive information in the memory file, e.g. personal information, company
35-
information, passwords, access tokens, email addresses, etc. !
35+
information, passwords, access tokens, email addresses, etc!
3636
- The memory file **must be in English**!
3737
- You can sometimes make it shorter, always remove any information that is no longer relevant.
3838
- Always remove any information that is no longer relevant from the memory file.

0 commit comments

Comments
 (0)