@@ -85,6 +85,22 @@ def _canonicalize_project_name(
8585 return project_name
8686
8787
88+ def _configured_project_name (
89+ project_name : Optional [str ],
90+ config : BasicMemoryConfig ,
91+ ) -> Optional [str ]:
92+ """Return the configured project name when the identifier matches a known project."""
93+ if project_name is None :
94+ return None
95+
96+ requested_permalink = generate_permalink (project_name )
97+ for configured_name in config .projects :
98+ if generate_permalink (configured_name ) == requested_permalink :
99+ return configured_name
100+
101+ return None
102+
103+
88104async def resolve_project_parameter (
89105 project : Optional [str ] = None ,
90106 allow_discovery : bool = False ,
@@ -363,7 +379,8 @@ async def resolve_project_and_path(
363379 Tuple of (active_project, normalized_path, is_memory_url)
364380 """
365381 is_memory_url = identifier .strip ().startswith ("memory://" )
366- include_project = ConfigManager ().config .permalinks_include_project if is_memory_url else None
382+ config = ConfigManager ().config
383+ include_project = config .permalinks_include_project if is_memory_url else None
367384 with telemetry .scope (
368385 "routing.resolve_memory_url" ,
369386 is_memory_url = is_memory_url ,
@@ -376,12 +393,20 @@ async def resolve_project_and_path(
376393
377394 normalized_path = normalize_project_reference (memory_url_path (identifier ))
378395 project_prefix , remainder = _split_project_prefix (normalized_path )
379- include_project = ConfigManager ().config .permalinks_include_project
396+ include_project = config .permalinks_include_project
397+ configured_prefix = _configured_project_name (project_prefix , config )
380398
381399 # Trigger: memory URL begins with a potential project segment
382400 # Why: allow project-scoped memory URLs without requiring a separate project parameter
383401 # Outcome: attempt to resolve the prefix as a project and route to it
384- if project_prefix :
402+ #
403+ # Trigger: the active project is already fixed and the first path segment is not
404+ # a configured project name
405+ # Why: in memory URLs like memory://notes/topic, "notes" is a directory, not a
406+ # project. Resolving it through /v2/projects/resolve creates noisy false-negative
407+ # logs before the tool recovers with the active project anyway.
408+ # Outcome: skip project resolution and keep the path within the active project.
409+ if project_prefix and (configured_prefix is not None or project is None ):
385410 try :
386411 from basic_memory .mcp .tools .utils import call_post
387412
0 commit comments