Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions src/nat/front_ends/mcp/mcp_front_end_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ class MCPFrontEndConfig(FrontEndBaseConfig, name="mcp"):
port: int = Field(default=9901, description="Port to bind the server to (default: 9901)", ge=0, le=65535)
debug: bool = Field(default=False, description="Enable debug mode (default: False)")
log_level: str = Field(default="INFO", description="Log level for the MCP server (default: INFO)")
tool_names: list[str] = Field(default_factory=list,
description="The list of tools MCP server will expose (default: all tools)")
tool_names: list[str] = Field(
default_factory=list,
description="The list of tools MCP server will expose (default: all tools)."
"Tool names can be functions or function groups",
)
transport: Literal["sse", "streamable-http"] = Field(
default="streamable-http",
description="Transport type for the MCP server (default: streamable-http, backwards compatible with sse)")
Expand Down
4 changes: 4 additions & 0 deletions src/nat/front_ends/mcp/mcp_front_end_plugin_worker.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,10 @@ async def add_routes(self, mcp: FastMCP, builder: WorkflowBuilder):
filtered_functions: dict[str, Function] = {}
for function_name, function in functions.items():
if function_name in self.front_end_config.tool_names:
# Treat current tool_names as function names, so check if the function name is in the list
filtered_functions[function_name] = function
elif any(function_name.startswith(f"{group_name}.") for group_name in self.front_end_config.tool_names):
# Treat tool_names as function group names, so check if the function name starts with the group name
filtered_functions[function_name] = function
else:
logger.debug("Skipping function %s as it's not in tool_names", function_name)
Expand Down