create_memory_project
Create a new knowledge management project with a unique name and file path to organize and store semantic data from AI conversations in Markdown format.
Instructions
Create a new Basic Memory project.
Creates a new project with the specified name and path. The project directory will be created if it doesn't exist. Optionally sets the new project as default.
Args: project_name: Name for the new project (must be unique) project_path: File system path where the project will be stored set_default: Whether to set this project as the default (optional, defaults to False)
Returns: Confirmation message with project details
Example: create_memory_project("my-research", "~/Documents/research") create_memory_project("work-notes", "/home/user/work", set_default=True)
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project_name | Yes | ||
| project_path | Yes | ||
| set_default | No |
Implementation Reference
- The core handler function for the 'create_memory_project' tool, including the @mcp.tool decorator for registration. It validates constraints, creates a ProjectInfoRequest, calls the POST /projects/projects API endpoint, and formats a response using ProjectStatusResponse.@mcp.tool("create_memory_project") async def create_memory_project( project_name: str, project_path: str, set_default: bool = False, context: Context | None = None ) -> str: """Create a new Basic Memory project. Creates a new project with the specified name and path. The project directory will be created if it doesn't exist. Optionally sets the new project as default. Args: project_name: Name for the new project (must be unique) project_path: File system path where the project will be stored set_default: Whether to set this project as the default (optional, defaults to False) Returns: Confirmation message with project details Example: create_memory_project("my-research", "~/Documents/research") create_memory_project("work-notes", "/home/user/work", set_default=True) """ async with get_client() as client: # Check if server is constrained to a specific project constrained_project = os.environ.get("BASIC_MEMORY_MCP_PROJECT") if constrained_project: return f'# Error\n\nProject creation disabled - MCP server is constrained to project \'{constrained_project}\'.\nUse the CLI to create projects: `basic-memory project add "{project_name}" "{project_path}"`' if context: # pragma: no cover await context.info(f"Creating project: {project_name} at {project_path}") # Create the project request project_request = ProjectInfoRequest( name=project_name, path=project_path, set_default=set_default ) # Call API to create project response = await call_post(client, "/projects/projects", json=project_request.model_dump()) status_response = ProjectStatusResponse.model_validate(response.json()) result = f"✓ {status_response.message}\n\n" if status_response.new_project: result += "Project Details:\n" result += f"• Name: {status_response.new_project.name}\n" result += f"• Path: {status_response.new_project.path}\n" if set_default: result += "• Set as default project\n" result += "\nProject is now available for use in tool calls.\n" result += f"Use '{project_name}' as the project parameter in MCP tool calls.\n" return result
- Pydantic input schema (ProjectInfoRequest) used by the create_memory_project handler to structure the project creation request: project name, path, and set_default flag.class ProjectInfoRequest(BaseModel): """Request model for switching projects.""" name: str = Field(..., description="Name of the project to switch to") path: str = Field(..., description="Path to the project directory") set_default: bool = Field(..., description="Set the project as the default")
- Pydantic output schema (ProjectStatusResponse) parsed from the API response in create_memory_project, containing status message, new project details, etc.class ProjectStatusResponse(BaseModel): """Response model for switching projects.""" message: str = Field(..., description="Status message about the project switch") status: str = Field(..., description="Status of the switch (success or error)") default: bool = Field(..., description="True if the project was set as the default") old_project: Optional[ProjectItem] = Field( None, description="Information about the project being switched from" ) new_project: Optional[ProjectItem] = Field( None, description="Information about the project being switched to" )