Skip to content

Commit 3595d6f

Browse files
committed
feat: OAuth authentication and code cleanup
- Add OAuth 2.1 authentication support with multiple providers - Fix JWT audience validation - Simplify MCP server startup code - Remove redundant auth router - Add comprehensive release notes for v0.13.0 - Fix type errors and improve error handling - Clean up temporary test files
1 parent 4af77fa commit 3595d6f

28 files changed

Lines changed: 552 additions & 416 deletions

RELEASE_NOTES_v0.13.0.md

Lines changed: 223 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,223 @@
1+
# Release Notes v0.13.0
2+
3+
## Overview
4+
5+
This is a major release that introduces multi-project support, OAuth authentication, server-side templating, and numerous improvements to the MCP server implementation. The codebase has been significantly refactored to support a unified database architecture while maintaining backward compatibility.
6+
7+
## Major Features
8+
9+
### 1. Multi-Project Support 🎯
10+
- **Unified Database Architecture**: All projects now share a single SQLite database with proper isolation
11+
- **Project Management API**: New endpoints for creating, updating, and managing projects
12+
- **Project Configuration**: Projects can be defined in `config.json` and synced with the database
13+
- **Default Project**: Backward compatibility maintained with automatic default project creation
14+
- **Project Switching**: CLI commands and API endpoints now support project context
15+
16+
### 2. OAuth 2.1 Authentication 🔐
17+
- **Multiple Provider Support**:
18+
- Basic (in-memory) provider for development
19+
- Supabase provider for production deployments
20+
- External providers (GitHub, Google) framework
21+
- **JWT-based Access Tokens**: Secure token generation and validation
22+
- **PKCE Support**: Enhanced security for authorization code flow
23+
- **MCP Inspector Integration**: Full support for authenticated testing
24+
- **CLI Commands**: `basic-memory auth register-client` and `basic-memory auth test-auth`
25+
26+
### 3. Server-Side Template Engine 📝
27+
- **Handlebars Templates**: Server-side rendering of prompts and responses
28+
- **Custom Helpers**: Rich set of template helpers for formatting
29+
- **Structured Output**: XML-formatted responses for better LLM consumption
30+
- **Template Caching**: Improved performance with template compilation caching
31+
32+
### 4. Enhanced Import System 📥
33+
- **Unified Importer Framework**: Base class for all importers with consistent interface
34+
- **API Support**: New `/import` endpoints for triggering imports via API
35+
- **Progress Tracking**: Real-time progress updates during import operations
36+
- **Multiple Formats**:
37+
- ChatGPT conversations
38+
- Claude conversations
39+
- Claude projects
40+
- Memory JSON format
41+
42+
### 5. Directory Navigation 📁
43+
- **Directory Service**: Browse and navigate project file structure
44+
- **API Endpoints**: `/directory/tree` and `/directory/list` endpoints
45+
- **Hierarchical View**: Tree structure representation of knowledge base
46+
47+
## API Changes
48+
49+
### New Endpoints
50+
51+
#### Project Management
52+
- `GET /projects` - List all projects
53+
- `POST /projects` - Create new project
54+
- `GET /projects/{project_id}` - Get project details
55+
- `PUT /projects/{project_id}` - Update project
56+
- `DELETE /projects/{project_id}` - Delete project
57+
- `POST /projects/{project_id}/set-default` - Set default project
58+
59+
#### Import API
60+
- `GET /{project}/import/types` - List available importers
61+
- `POST /{project}/import/{importer_type}/analyze` - Analyze import source
62+
- `POST /{project}/import/{importer_type}/preview` - Preview import
63+
- `POST /{project}/import/{importer_type}/execute` - Execute import
64+
65+
#### Directory API
66+
- `GET /{project}/directory/tree` - Get directory tree
67+
- `GET /{project}/directory/list` - List directory contents
68+
69+
#### Prompt Templates
70+
- `POST /{project}/prompts/search` - Search with formatted output
71+
- `POST /{project}/prompts/continue-conversation` - Continue conversation with context
72+
73+
#### Management API
74+
- `GET /management/sync/status` - Get sync status
75+
- `POST /management/sync/start` - Start background sync
76+
- `POST /management/sync/stop` - Stop background sync
77+
78+
### Updated Endpoints
79+
80+
All knowledge-related endpoints now require project context:
81+
- `/{project}/entities`
82+
- `/{project}/observations`
83+
- `/{project}/search`
84+
- `/{project}/memory`
85+
86+
## CLI Changes
87+
88+
### New Commands
89+
- `basic-memory auth` - OAuth client management
90+
- `basic-memory project create` - Create new project
91+
- `basic-memory project list` - List all projects
92+
- `basic-memory project set-default` - Set default project
93+
- `basic-memory project delete` - Delete project
94+
- `basic-memory project info` - Show project statistics
95+
96+
### Updated Commands
97+
- Import commands now support `--project` flag
98+
- Sync commands operate on all active projects by default
99+
- MCP server defaults to stdio transport (use `--transport streamable-http` for HTTP)
100+
101+
## Configuration Changes
102+
103+
### config.json Structure
104+
```json
105+
{
106+
"projects": {
107+
"main": "~/basic-memory",
108+
"my-project": "~/my-notes",
109+
"work": "~/work/notes"
110+
},
111+
"default_project": "main",
112+
"sync_changes": true
113+
}
114+
```
115+
116+
### Environment Variables
117+
- `FASTMCP_AUTH_ENABLED` - Enable OAuth authentication
118+
- `FASTMCP_AUTH_SECRET_KEY` - JWT signing key
119+
- `FASTMCP_AUTH_PROVIDER` - OAuth provider type
120+
- `FASTMCP_AUTH_REQUIRED_SCOPES` - Required OAuth scopes
121+
122+
## Database Changes
123+
124+
### New Tables
125+
- `project` - Project definitions and metadata
126+
- Migration: `5fe1ab1ccebe_add_projects_table.py`
127+
128+
### Schema Updates
129+
- All knowledge tables now include `project_id` foreign key
130+
- Search index updated to support project filtering
131+
- Backward compatibility maintained via default project
132+
133+
## Performance Improvements
134+
135+
- **Concurrent Initialization**: Projects initialize in parallel
136+
- **Optimized Queries**: Better use of indexes and joins
137+
- **Template Caching**: Compiled templates cached in memory
138+
- **Batch Operations**: Reduced database round trips
139+
140+
## Bug Fixes
141+
142+
- Fixed duplicate initialization in MCP server startup
143+
- Fixed JWT audience validation for OAuth tokens
144+
- Fixed trailing slash requirement for MCP endpoints
145+
- Corrected OAuth endpoint paths
146+
- Fixed stdio transport initialization
147+
- Improved error handling in file sync operations
148+
- Fixed search result ranking and filtering
149+
150+
## Breaking Changes
151+
152+
- **Project Context Required**: API endpoints now require project context
153+
- **Database Location**: Unified database at `~/.basic-memory/memory.db`
154+
- **Import Module Restructure**: Import functionality moved to dedicated module
155+
156+
## Migration Guide
157+
158+
### For Existing Users
159+
160+
1. **Automatic Migration**: First run will migrate existing data to default project
161+
2. **Project Configuration**: Add projects to `config.json` if using multiple projects
162+
3. **API Updates**: Update API calls to include project context
163+
164+
### For API Consumers
165+
166+
```python
167+
# Old
168+
response = client.get("/entities")
169+
170+
# New
171+
response = client.get("/main/entities") # 'main' is default project
172+
```
173+
174+
### For OAuth Setup
175+
176+
```bash
177+
# Enable OAuth
178+
export FASTMCP_AUTH_ENABLED=true
179+
export FASTMCP_AUTH_SECRET_KEY="your-secret-key"
180+
181+
# Start server
182+
basic-memory mcp --transport streamable-http
183+
184+
# Get token
185+
basic-memory auth test-auth
186+
```
187+
188+
## Dependencies
189+
190+
### Added
191+
- `python-dotenv` - Environment variable management
192+
- `pydantic` >= 2.0 - Enhanced validation
193+
194+
### Updated
195+
- `fastmcp` to latest version
196+
- `mcp` to latest version
197+
- All development dependencies updated
198+
199+
## Documentation
200+
201+
- New: [OAuth Authentication Guide](docs/OAuth%20Authentication%20Guide.md)
202+
- New: [Supabase OAuth Setup](docs/Supabase%20OAuth%20Setup.md)
203+
- Updated: [Claude.ai Integration](docs/Claude.ai%20Integration.md)
204+
- Updated: Main README with project examples
205+
206+
## Testing
207+
208+
- Added comprehensive test coverage for new features
209+
- OAuth provider tests with full flow validation
210+
- Template engine tests with various scenarios
211+
- Project service integration tests
212+
- Import system unit tests
213+
214+
## Contributors
215+
216+
This release includes contributions from the Basic Machines team and the AI assistant Claude, demonstrating effective human-AI collaboration in software development.
217+
218+
## Next Steps
219+
220+
- Production deployment guide updates
221+
- Additional OAuth provider implementations
222+
- Performance profiling and optimization
223+
- Enhanced project analytics features

src/basic_memory/api/app.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""FastAPI application for basic-memory knowledge graph API."""
2+
23
import asyncio
34
from contextlib import asynccontextmanager
45

@@ -31,7 +32,7 @@ async def lifespan(app: FastAPI): # pragma: no cover
3132
await initialize_app(app_config)
3233

3334
logger.info(f"Sync changes enabled: {app_config.sync_changes}")
34-
if app_config.sync_changes:
35+
if app_config.sync_changes:
3536
# start file sync task in background
3637
app.state.sync_task = asyncio.create_task(initialize_file_sync(app_config))
3738
else:
@@ -82,4 +83,4 @@ async def exception_handler(request, exc): # pragma: no cover
8283
error_type=type(exc).__name__,
8384
error=str(exc),
8485
)
85-
return await http_exception_handler(request, HTTPException(status_code=500, detail=str(exc)))
86+
return await http_exception_handler(request, HTTPException(status_code=500, detail=str(exc)))

src/basic_memory/api/routers/prompt_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,4 +251,4 @@ async def search_prompt(
251251
raise HTTPException(
252252
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
253253
detail=f"Error rendering prompt template: {str(e)}",
254-
)
254+
)

src/basic_memory/api/template_loader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,4 +289,4 @@ def clear_cache(self) -> None:
289289

290290

291291
# Global template loader instance
292-
template_loader = TemplateLoader()
292+
template_loader = TemplateLoader()

0 commit comments

Comments
 (0)