diff --git a/repl.lua b/repl.lua index b5f33f8..4041171 100644 --- a/repl.lua +++ b/repl.lua @@ -142,6 +142,22 @@ function M.run(config) if sess.version_warning then renderer.status("mcp " .. alias .. ": " .. sess.version_warning) end + -- Tool-name validation (issue #32): Anthropic via Bedrock enforces + -- ^[a-zA-Z0-9_-]{1,128}$. We use "__" as the alias separator, so the + -- emitted name is alias__tool. Warn at startup; emit anyway so local + -- llama.cpp users aren't penalized for lenient downstreams. + if alias:find("__", 1, true) then + renderer.status(("mcp %s: alias contains '__' (used as separator); " + .. "tool dispatch will misparse"):format(alias)) + end + for _, t in ipairs(sess:list_tools()) do + local full = alias .. "__" .. (t.name or "") + if #full > 128 or full:find("[^%w_-]") then + renderer.status(("mcp %s: tool name '%s' violates " + .. "^[a-zA-Z0-9_-]{1,128}$ (will fail with strict providers " + .. "e.g. anthropic via Bedrock)"):format(alias, full)) + end + end return true, #sess:list_tools() end