summaryrefslogtreecommitdiff
path: root/src/ollama_web/tools
diff options
context:
space:
mode:
authortanaka takashi <isazaka@gmail.com>2026-06-27 01:09:00 +0900
committertanaka takashi <isazaka@gmail.com>2026-06-27 01:09:00 +0900
commitfce9dc1b2940ee6699d2acf0c9e56456d9899581 (patch)
tree6bb0cfd1b220b7a37f77d55348803dd46ea30e45 /src/ollama_web/tools
parent3a9e8e18df4c596360da54000f65e1bebc6039c2 (diff)
MCP server機能をセキュア化
Diffstat (limited to 'src/ollama_web/tools')
-rw-r--r--src/ollama_web/tools/registry.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/ollama_web/tools/registry.py b/src/ollama_web/tools/registry.py
index 17c755d..e3b7824 100644
--- a/src/ollama_web/tools/registry.py
+++ b/src/ollama_web/tools/registry.py
@@ -40,10 +40,14 @@ class ToolRegistry:
executor: A callable that accepts ``(full_name, arguments)`` and
returns a JSON-encoded result string.
"""
+ if name in self._tools:
+ raise ValueError(f"Duplicate tool name: {name}")
self._tools[name] = executor
self._mcp_tool_names.add(name)
# Avoid duplicate definitions if a registry is rebuilt.
- self._ollama_tool_defs = [d for d in self._ollama_tool_defs if d.get("name") != name]
+ self._ollama_tool_defs = [
+ d for d in self._ollama_tool_defs if d.get("function", {}).get("name") != name
+ ]
self._ollama_tool_defs.append(tool_def)
return executor
@@ -123,4 +127,4 @@ def default_registry() -> ToolRegistry:
def all_tool_callables(registry: ToolRegistry | None = None) -> Sequence[Callable[..., object]]:
"""Return the list of callables suitable for ``ollama`` ``tools`` argument."""
reg = registry or default_registry()
- return reg.callables \ No newline at end of file
+ return reg.callables