From ea53bddbb8fb584b7e3046c10f9f32c3f041cf86 Mon Sep 17 00:00:00 2001 From: "Christian M. Todie" Date: Wed, 25 Mar 2026 03:34:45 -0400 Subject: [PATCH] fix(mcp): handle string-typed numeric params in intArg The intArg helper only type-asserted to float64, which silently failed when the MCP transport sent numeric params as strings. This caused "id is required" errors on mem_update, mem_delete, and mem_timeline. Add strconv.Atoi fallback via type switch so both float64 and string representations are handled correctly. Co-Authored-By: Claude Opus 4.6 (1M context) --- internal/mcp/mcp.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/internal/mcp/mcp.go b/internal/mcp/mcp.go index 1be33c9..235a1ba 100644 --- a/internal/mcp/mcp.go +++ b/internal/mcp/mcp.go @@ -16,6 +16,7 @@ package mcp import ( "context" "fmt" + "strconv" "strings" "github.com/Gentleman-Programming/engram/internal/store" @@ -1039,11 +1040,19 @@ func defaultSessionID(project string) string { } func intArg(req mcp.CallToolRequest, key string, defaultVal int) int { - v, ok := req.GetArguments()[key].(float64) - if !ok { + v := req.GetArguments()[key] + switch val := v.(type) { + case float64: + return int(val) + case string: + n, err := strconv.Atoi(val) + if err != nil { + return defaultVal + } + return n + default: return defaultVal } - return int(v) } func boolArg(req mcp.CallToolRequest, key string, defaultVal bool) bool {