# jguimera/securitycopilotmcpserver architecture

> Architecture diagram of the GitHub repository jguimera/securitycopilotmcpserver, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-14). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jguimera/securitycopilotmcpserver
- Repository: https://github.com/jguimera/securitycopilotmcpserver

## Overview

##### Main Components
- Server (server.py): This is the core MCP server that listens for incoming requests and orchestrates operations.
- Sentinel Client (SentinelClient.py): Handles the execution of KQL queries against Microsoft Sentinel.
- Security Copilot Client (SecurityCopilotClient.py): Manages the uploading/updating of skillsets/plugins and running prompts.
- External Dependencies: Azure Identity for authentication, Microsoft Sentinel workspace, and Microsoft Security Copilot services.
- Client Configuration (.cursor folder): Contains configuration (mcp.json) and custom rules (securitycopilotdev.mdc) that let a Cursor client connect to and utilize the MCP server.

##### Relationships & Interactions
- A client (for example, a Cursor instance) connects to the MCP server (using configurations from .cursor).
- The server receives commands (such as /run_prompt, /upload_plugin, /run_sentinel_query) and then dispatches these requests internally.
- When a Sentinel query is needed, server.py uses SentinelClient.py to interact with the Microsoft Sentinel workspace.
- Operations related to Security Copilot (like uploading a plugin or running a skill) are handled by SecurityCopilotClient.py.
- Authentication flows are managed within the server using Azure Identity, with configuration provided via the .env file.
- The communication layer uses SSE as transport, which should be shown as a bidirectional data flow between the client and the server.

##### Architectural Patterns & Design Principles
- Modular Architecture: Each capability (Sentinel integration, Security Copilot management) is encapsulated in separate modules/clients, promoting separation of concerns.
- Configuration-Driven: The use of environment files (.env) and dedicated client configuration files (.cursor/mcp.json) indicates that much of the integration behavior is driven by external configuration.
- Integration/Bridging Pattern: The MCP server acts as a bridge between the development/testing environment (clients like Cursor) and external services (Sentinel and Security Copilot).

##### Relevant Technologies, Frameworks, and Libraries
- FastMCP library is central to server implementation.
- Python as the core language.
- Azure Identity for handling authentication.
- Server-Sent Events (SSE) for transport.
- Any libraries specified in the requirements.txt (likely including FastMCP and Azure SDKs).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Client & Configuration Layer
    subgraph "Client & Configuration"
        Client("Cursor Client"):::client
        Config("MCP Config (.cursor/mcp.json)"):::config
        Rules("Custom SC Rules (.cursor/securitycopilotdev.mdc)"):::config
    end

    %% MCP Server Layer
    subgraph "MCP Server Layer"
        Server("MCP Server (server.py)"):::server
        subgraph "Internal Modules"
            Sentinel("Sentinel Client (SentinelClient.py)"):::internal
            Copilot("Security Copilot Client (SecurityCopilotClient.py)"):::internal
        end
    end

    %% External Services Layer
    subgraph "External Services"
        Azure("Azure Authentication (Azure Identity)"):::external
        SentinelWorkspace("Microsoft Sentinel Workspace"):::external
        CopilotService("Microsoft Security Copilot Service"):::external
        Libs("Library Dependencies (requirements.txt)"):::external
    end

    %% Connections from Client to Server via SSE
    Client -->|"SSE"| Server
    Config --> Server
    Rules --> Server

    %% Server dispatches operations to internal modules
    Server -->|"run_sentinel_query"| Sentinel
    Server -->|"run_prompt"| Copilot
    Server -->|"upload_plugin"| Copilot

    %% Internal modules interact with external services
    Sentinel -->|"executes query"| SentinelWorkspace
    Copilot -->|"executes prompt/plugin"| CopilotService

    %% Authentication with Azure Identity (bidirectional)
    Server <-->|"authenticate"| Azure

    %% Server uses external libraries
    Server -->|"uses"| Libs

    %% Click Events
    click Server "https://github.com/jguimera/securitycopilotmcpserver/blob/main/server.py"
    click Sentinel "https://github.com/jguimera/securitycopilotmcpserver/blob/main/SentinelClient.py"
    click Copilot "https://github.com/jguimera/securitycopilotmcpserver/blob/main/SecurityCopilotClient.py"
    click Config "https://github.com/jguimera/securitycopilotmcpserver/blob/main/.cursor/mcp.json"
    click Rules "https://github.com/jguimera/securitycopilotmcpserver/blob/main/.cursor/rules/securitycopilotdev.mdc"
    click Libs "https://github.com/jguimera/securitycopilotmcpserver/blob/main/requirements.txt"

    %% Styles
    classDef client fill:#a3d8f4,stroke:#333,stroke-width:2px;
    classDef config fill:#e3f2fd,stroke:#333,stroke-width:2px;
    classDef server fill:#ffcc80,stroke:#333,stroke-width:2px;
    classDef internal fill:#fff176,stroke:#333,stroke-width:2px;
    classDef external fill:#c5e1a5,stroke:#333,stroke-width:2px;
```
