Skip to content

Commit 9ca5c3f

Browse files
authored
[GMLP-5459] Add tool restrictions (#6)
1 parent 0206b4d commit 9ca5c3f

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "gumloop-mcp"
3-
version = "0.1.6"
3+
version = "0.1.8"
44
description = "guMCP (Gumloop Model Context Protocol) SDK"
55
readme = "README.md"
66
requires-python = ">=3.10"

src/mcp/server/lowlevel/server.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,14 @@ async def handler(req: types.ListToolsRequest):
519519
# Filter deprecated properties from all tools
520520
tools = [filter_deprecated_properties_from_tool(tool) for tool in tools]
521521

522+
# Filter restricted tools
523+
if hasattr(self, "config") and self.config is not None:
524+
restricted_tools = self.config.get("restricted_tools", [])
525+
if restricted_tools:
526+
tools = [
527+
tool for tool in tools if tool.name not in restricted_tools
528+
]
529+
522530
# Filter for external clients
523531
if hasattr(self, "config") and self.config is not None:
524532
if self.config.get("external_client", False):
@@ -606,6 +614,14 @@ async def handler(req: types.CallToolRequest):
606614
f"Input validation error: {e.message}"
607615
)
608616

617+
# Check if tool is restricted
618+
if hasattr(self, "config") and self.config is not None:
619+
restricted_tools = self.config.get("restricted_tools", [])
620+
if tool_name in restricted_tools:
621+
return self._make_error_result(
622+
f"Tool '{tool_name}' is restricted and cannot be used"
623+
)
624+
609625
# tool call
610626
results = await func(tool_name, arguments)
611627
content = list(results)

0 commit comments

Comments
 (0)