Skip to content

Commit ac08a8d

Browse files
phernandezclaude
andcommitted
fix: update FastMCP initialization for API changes
- Remove deprecated auth_server_provider parameter - Use auth parameter correctly with OAuthProvider instead of AuthSettings - Fixes type error after dependency updates 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent c13d4b1 commit ac08a8d

22 files changed

+135
-90
lines changed

src/basic_memory/alembic/versions/cc7172b46608_update_search_index_schema.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ def upgrade() -> None:
5757
""")
5858

5959

60-
6160
def downgrade() -> None:
6261
"""Downgrade database schema to use old search index."""
6362
# Drop the updated search_index table

src/basic_memory/api/routers/knowledge_router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,4 +274,4 @@ async def delete_entities(
274274
background_tasks.add_task(search_service.delete_by_permalink, permalink)
275275

276276
result = DeleteEntitiesResponse(deleted=deleted)
277-
return result
277+
return result

src/basic_memory/api/routers/project_router.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,9 @@ async def remove_project(
145145
try:
146146
old_project = await project_service.get_project(name)
147147
if not old_project: # pragma: no cover
148-
raise HTTPException(status_code=404, detail=f"Project: '{name}' does not exist") # pragma: no cover
148+
raise HTTPException(
149+
status_code=404, detail=f"Project: '{name}' does not exist"
150+
) # pragma: no cover
149151

150152
await project_service.remove_project(name)
151153

@@ -186,7 +188,9 @@ async def set_default_project(
186188
# get the new project
187189
new_default_project = await project_service.get_project(name)
188190
if not new_default_project: # pragma: no cover
189-
raise HTTPException(status_code=404, detail=f"Project: '{name}' does not exist") # pragma: no cover
191+
raise HTTPException(
192+
status_code=404, detail=f"Project: '{name}' does not exist"
193+
) # pragma: no cover
190194

191195
await project_service.set_default_project(name)
192196

src/basic_memory/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def load_config(self) -> BasicMemoryConfig:
179179

180180
def save_config(self, config: BasicMemoryConfig) -> None:
181181
"""Save configuration to file."""
182-
try:
182+
try:
183183
self.config_file.write_text(json.dumps(config.model_dump(), indent=2))
184184
except Exception as e: # pragma: no cover
185185
logger.error(f"Failed to save config: {e}")

src/basic_memory/mcp/server.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,5 @@ def create_auth_config() -> tuple[AuthSettings | None, Any | None]:
106106
mcp = FastMCP(
107107
name="Basic Memory",
108108
log_level="DEBUG",
109-
auth_server_provider=auth_provider,
110-
auth=auth_settings,
109+
auth=auth_provider,
111110
)

src/basic_memory/mcp/tools/move_note.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ async def move_note(
3131
3232
Examples:
3333
- Move to new folder: move_note("My Note", "work/notes/my-note.md")
34-
- Move by permalink: move_note("my-note-permalink", "archive/old-notes/my-note.md")
34+
- Move by permalink: move_note("my-note-permalink", "archive/old-notes/my-note.md")
3535
- Specify project: move_note("My Note", "archive/my-note.md", project="work-project")
3636
3737
Note: This operation moves notes within the specified project only. Moving notes

src/basic_memory/services/project_service.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
from basic_memory.utils import generate_permalink
2323
from basic_memory.config import config_manager
2424

25+
2526
class ProjectService:
2627
"""Service for managing Basic Memory projects."""
2728

@@ -545,4 +546,4 @@ def get_system_status(self) -> SystemStatus:
545546
database_size=db_size_readable,
546547
watch_status=watch_status,
547548
timestamp=datetime.now(),
548-
)
549+
)

src/basic_memory/services/search_service.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ def _extract_entity_tags(self, entity: Entity) -> List[str]:
148148
# If parsing fails, treat as single tag
149149
return [tags] if tags.strip() else []
150150

151-
return [] # pragma: no cover
151+
return [] # pragma: no cover
152152

153153
async def index_entity(
154154
self,

src/basic_memory/sync/sync_service.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ async def handle_move(self, old_path, new_path):
379379
updates = {"file_path": new_path}
380380

381381
# If configured, also update permalink to match new path
382-
if self.app_config.update_permalinks_on_move and self.file_service.is_markdown(new_path):
382+
if self.app_config.update_permalinks_on_move and self.file_service.is_markdown(
383+
new_path
384+
):
383385
# generate new permalink value
384386
new_permalink = await self.entity_service.resolve_permalink(new_path)
385387

@@ -505,4 +507,4 @@ async def scan_directory(self, directory: Path) -> ScanResult:
505507
f"duration_ms={duration_ms}"
506508
)
507509

508-
return result
510+
return result

test-int/conftest.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ async def test_my_mcp_tool(mcp_server, app):
4949
The `app` fixture ensures FastAPI dependency overrides are active, and
5050
`mcp_server` provides the MCP server with proper project session initialization.
5151
"""
52-
import os
52+
5353
from typing import AsyncGenerator
54-
from unittest import mock
55-
from unittest.mock import patch
5654

5755
import pytest
5856
import pytest_asyncio
@@ -110,21 +108,29 @@ async def test_project(tmp_path, engine_factory) -> Project:
110108
project = await project_repository.create(project_data)
111109
return project
112110

111+
113112
@pytest.fixture
114113
def config_home(tmp_path, monkeypatch) -> Path:
115114
monkeypatch.setenv("HOME", str(tmp_path))
116115
return tmp_path
117116

117+
118118
@pytest.fixture(scope="function")
119119
def app_config(config_home, test_project, tmp_path, monkeypatch) -> BasicMemoryConfig:
120120
"""Create test app configuration."""
121121
projects = {test_project.name: str(test_project.path)}
122-
app_config = BasicMemoryConfig(env="test", projects=projects, default_project=test_project.name, update_permalinks_on_move=True)
122+
app_config = BasicMemoryConfig(
123+
env="test",
124+
projects=projects,
125+
default_project=test_project.name,
126+
update_permalinks_on_move=True,
127+
)
123128

124129
# Set the module app_config instance project list (like regular tests)
125130
monkeypatch.setattr("basic_memory.config.app_config", app_config)
126131
return app_config
127132

133+
128134
@pytest.fixture
129135
def config_manager(app_config: BasicMemoryConfig, config_home, monkeypatch) -> ConfigManager:
130136
config_manager = ConfigManager()
@@ -145,6 +151,7 @@ def config_manager(app_config: BasicMemoryConfig, config_home, monkeypatch) -> C
145151

146152
return config_manager
147153

154+
148155
@pytest.fixture
149156
def project_session(test_project: Project):
150157
# initialize the project session with the test project
@@ -166,9 +173,10 @@ def project_config(test_project, monkeypatch):
166173
return project_config
167174

168175

169-
170176
@pytest.fixture(scope="function")
171-
def app(app_config, project_config, engine_factory, test_project, project_session, config_manager) -> FastAPI:
177+
def app(
178+
app_config, project_config, engine_factory, test_project, project_session, config_manager
179+
) -> FastAPI:
172180
"""Create test FastAPI application with single project."""
173181

174182
app = fastapi_app
@@ -228,4 +236,4 @@ def mcp_server(app_config, search_service):
228236
async def client(app: FastAPI) -> AsyncGenerator[AsyncClient, None]:
229237
"""Create test client that both MCP and tests will use."""
230238
async with AsyncClient(transport=ASGITransport(app=app), base_url="http://test") as client:
231-
yield client
239+
yield client

0 commit comments

Comments
 (0)