Skip to content

Commit 6f3fe08

Browse files
committed
fix(mcp): return empty working memory instead of none for missing sessions
the mcp get_working_memory handler imported the fastapi route handler from api.py which has a starlette Header() default parameter for x_client_version. when called from mcp (not http), the Header object is passed as-is to re.match() causing "expected string or bytes-like object, got 'Header'". fix: call working_memory.get_working_memory (the core function) directly instead of the api route handler, and guard the None return with an empty WorkingMemory.
1 parent 2ea6ca4 commit 6f3fe08

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

agent_memory_server/config.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,7 @@ class Settings(BaseSettings):
358358
"gpt-5-mini" # Faster, smaller model for quick tasks like query optimization
359359
)
360360
port: int = 8000
361+
mcp_host: str = "0.0.0.0"
361362
mcp_port: int = 9000
362363

363364
# Vector store factory configuration

agent_memory_server/mcp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
create_long_term_memory as core_create_long_term_memory,
1010
delete_long_term_memory as core_delete_long_term_memory,
1111
get_long_term_memory as core_get_long_term_memory,
12-
get_working_memory as core_get_working_memory,
1312
memory_prompt as core_memory_prompt,
1413
put_working_memory_core as core_put_working_memory,
1514
search_long_term_memory as core_search_long_term_memory,
1615
update_long_term_memory as core_update_long_term_memory,
1716
)
17+
from agent_memory_server import working_memory as working_memory_core
1818
from agent_memory_server.config import settings
1919
from agent_memory_server.dependencies import get_background_tasks
2020
from agent_memory_server.filters import (
@@ -199,6 +199,7 @@ async def run_stdio_async(self):
199199

200200
mcp_app = FastMCP(
201201
"Redis Agent Memory Server",
202+
host=settings.mcp_host,
202203
port=settings.mcp_port,
203204
instructions=INSTRUCTIONS,
204205
default_namespace=settings.default_mcp_namespace,
@@ -910,7 +911,7 @@ async def get_working_memory(
910911
Returns:
911912
Working memory containing messages, context, and structured memory records
912913
"""
913-
result = await core_get_working_memory(
914+
result = await working_memory_core.get_working_memory(
914915
session_id=session_id, recent_messages_limit=recent_messages_limit
915916
)
916917
if result is None:

0 commit comments

Comments
 (0)