Implementation:0x4m4 Hexstrike ai setup mcp server
| Knowledge Sources | |
|---|---|
| Domains | Security, MCP, Tool_Execution |
| Last Updated | 2026-10-10 00:00 GMT |
Overview
Wrapper that registers 80+ security tools as MCP-callable functions, bridging AI agents to the HexStrike server via the FastMCP protocol.
Description
The setup_mcp_server function creates a FastMCP instance and decorates 80+ tool functions with @mcp.tool(), exposing them to AI agents (Claude, GPT, Cursor) through the Model Context Protocol. Each decorated function is a thin passthrough that forwards requests to the HexStrike Flask server via HexStrikeClient.safe_post(). The decorator automatically generates the MCP tool schema from the function's type hints and docstring.
Usage
Import and call this function during MCP server startup to expose all HexStrike security tools to an AI agent:
- Standard tool exposure: Call setup_mcp_server(client) in main() to register all tools
- AI agent integration: Configure the MCP server URL in hexstrike-ai-mcp.json for Claude Desktop, Cursor, or VS Code Copilot
- Autonomous execution: Set alwaysAllow in the MCP config to permit tool execution without human confirmation
Code Reference
Source Location
- Repository: HexStrike AI
- File: hexstrike_mcp.py
- Lines: L267-5264 (setup_mcp_server function and all @mcp.tool() registrations)
Signature
def setup_mcp_server(hexstrike_client: HexStrikeClient) -> FastMCP:
"""
Set up the MCP server with all enhanced tool functions.
Args:
hexstrike_client: Initialized HexStrikeClient
Returns:
Configured FastMCP instance
"""
mcp = FastMCP("hexstrike-ai-mcp")
@mcp.tool()
def nmap_scan(target: str, scan_type: str = "-sV", ports: str = "", additional_args: str = "") -> Dict[str, Any]:
"""Execute an enhanced Nmap scan against a target with real-time logging."""
...
@mcp.tool()
def gobuster_scan(url: str, mode: str = "dir", wordlist: str = "...", additional_args: str = "") -> Dict[str, Any]:
"""Execute Gobuster to find directories, DNS subdomains, or virtual hosts."""
...
# 80+ additional @mcp.tool() decorated functions (L326-5264)
return mcp
Import
from hexstrike_mcp import setup_mcp_server, HexStrikeClient
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| hexstrike_client | HexStrikeClient | Yes | Initialized client with connection to HexStrike Flask server |
Outputs
| Name | Type | Description |
|---|---|---|
| return value | FastMCP | Configured MCP server instance with 80+ registered tools |
| MCP tool schema | Auto-generated | FastMCP reads type hints and docstrings to produce JSON schema for each tool |
Usage Examples
Standard MCP Server Setup
from hexstrike_mcp import setup_mcp_server, HexStrikeClient
# Initialize client connection to HexStrike server
client = HexStrikeClient(server_url="http://localhost:5000")
# Register all 80+ security tools as MCP-callable functions
mcp = setup_mcp_server(client)
# Start the MCP server (blocks until shutdown)
mcp.run()
MCP Client Config (hexstrike-ai-mcp.json)
{
"mcpServers": {
"hexstrike-ai-mcp": {
"command": "python3",
"args": ["/path/to/hexstrike_mcp.py"],
"env": {
"HEXSTRIKE_SERVER_URL": "http://localhost:5000"
},
"alwaysAllow": [
"nmap_scan",
"gobuster_scan",
"nuclei_scan"
]
}
}
}