|
13 | 13 | from .tools.decode import register_decode_tools |
14 | 14 | from .tools.extract import register_extract_tools |
15 | 15 | from .tools.files import register_files_tools |
16 | | -from .tools.protocol import register_protocol_tools |
17 | | -from .tools.security import register_security_tools |
| 16 | +from .tools.agents import register_agent_tools |
| 17 | +from .tools.registry import ToolRegistry, register_open_file_tool |
18 | 18 | from .tools.stats import register_stats_tools |
19 | | -from .tools.threat import register_threat_tools |
20 | 19 | from .tools.visualize import register_visualize_tools |
21 | 20 |
|
22 | 21 | logger = logging.getLogger("wireshark_mcp") |
23 | 22 |
|
24 | 23 |
|
25 | 24 | def _build_server() -> FastMCP: |
26 | | - """Build and configure the MCP server with all tools registered.""" |
| 25 | + """Build and configure the MCP server with progressive discovery.""" |
27 | 26 | # Read allowed directories from environment |
28 | 27 | allowed_dirs_env = os.environ.get("WIRESHARK_MCP_ALLOWED_DIRS", "") |
29 | 28 | allowed_dirs = [d.strip() for d in allowed_dirs_env.split(",") if d.strip()] or None |
30 | 29 |
|
31 | 30 | mcp = FastMCP("Wireshark MCP", dependencies=["tshark"]) |
32 | 31 | client = TSharkClient(allowed_dirs=allowed_dirs) |
33 | 32 |
|
34 | | - # Register all tool modules |
| 33 | + # ── Core tools (always registered) ────────────────────────────────── |
35 | 34 | register_capture_tools(mcp, client) |
36 | 35 | register_stats_tools(mcp, client) |
37 | 36 | register_extract_tools(mcp, client) |
38 | 37 | register_files_tools(mcp, client) |
39 | | - register_security_tools(mcp, client) |
40 | 38 | register_decode_tools(mcp) |
41 | 39 | register_visualize_tools(mcp, client) |
42 | | - register_protocol_tools(mcp, client) |
43 | | - register_threat_tools(mcp, client) |
| 40 | + register_agent_tools(mcp, client) |
44 | 41 |
|
45 | | - # Register Resources and Prompts |
| 42 | + # ── Progressive Discovery ─────────────────────────────────────────── |
| 43 | + # Build the contextual tool catalog (not registered yet) |
| 44 | + registry = ToolRegistry(mcp, client) |
| 45 | + registry.build_catalog() |
| 46 | + |
| 47 | + # Register the entry-point tool that activates contextual tools |
| 48 | + register_open_file_tool(mcp, client, registry) |
| 49 | + |
| 50 | + # ── Resources and Prompts ─────────────────────────────────────────── |
46 | 51 | register_resources(mcp) |
47 | 52 | register_prompts(mcp) |
48 | 53 |
|
@@ -97,3 +102,4 @@ def main() -> None: |
97 | 102 |
|
98 | 103 | if __name__ == "__main__": |
99 | 104 | main() |
| 105 | + |
0 commit comments