# dongsenzhang/msb architecture

> Architecture diagram of the GitHub repository dongsenzhang/msb, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dongsenzhang/msb
- Repository: https://github.com/dongsenzhang/msb
- Video tour (about a minute): https://gitdiagram.com/dongsenzhang/msb/video

## Overview

MSB evaluates whether LLM agents resist MCP attacks: a run selects an attack, task, model, and scenario; the agent plans and invokes MCP tools, handles their responses, and produces a result. The benchmark includes attack-server scenarios and records execution/environment state for metrics. The shared mcp_use layer provides server sessions, connectors, tool adaptation, and agent orchestration. Several scenario implementations and runtime modules are unsampled, so their internal links are omitted; documented benchmark stages and capabilities are retained.

Main entry points: [`main.py`](https://github.com/dongsenzhang/msb/blob/main/main.py) (Run orchestration), [`data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py`](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py) (Word MCP server), [`data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py`](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py) (Document content), [`data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py`](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py) (Document formatting)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_bench["Benchmark workflow"]
  node_run["Run orchestration<br/>[main.py]"]
  node_attack_config["Attack setup<br/>[agent_attack.py]"]
  node_templates["Attack prompts<br/>[prompt_template.py]"]
  node_metrics["Result metrics<br/>[metrics.py]"]
end

subgraph group_attacks["Attack scenarios"]
  node_attack_catalog["Attack tools<br/>[main.py]"]
  node_academic["Academic search"]
  node_web_search["Web search"]
  node_terminal["Terminal control"]
  node_memory["Memory tool"]
  node_image["Image generation"]
end

subgraph group_agent["Agent runtime"]
  node_agent["MCP agent<br/>[mcpagent.py]"]
  node_server_manager["Server selection<br/>[server_manager.py]"]
  node_adapter["LangChain adapter"]
end

subgraph group_transport["MCP connectivity"]
  node_client["MCP client<br/>[client.py]"]
  node_session["MCP session<br/>[session.py]"]
  node_connector["MCP connector<br/>[base.py]"]
  node_sandbox["Sandbox options<br/>[sandbox.py]"]
end

subgraph group_word["Word server"]
  node_word_server["Word MCP server<br/>[main.py]"]
  node_word_content["Document content<br/>[content_tools.py]"]
  node_word_format["Document formatting<br/>[format_tools.py]"]
  node_word_footnotes["Footnote operations<br/>[footnotes.py]"]
  node_word_styles["Document styles<br/>[styles.py]"]
  node_word_tables["Document tables<br/>[tables.py]"]
  node_word_utils["Document utilities<br/>[document_utils.py]"]
  node_word_files["File utilities<br/>[file_utils.py]"]
  node_word_comments["Comment operations<br/>[comment_tools.py]"]
end

node_user(("Benchmark operator"))

node_user -->|"starts run"| node_run
node_run -->|"runs task"| node_agent
node_run -->|"imports prompts"| node_templates
node_run -.->|"supports evaluation"| node_attack_config
node_attack_config -.->|"selects tools"| node_attack_catalog
node_run -->|"evaluates results"| node_metrics
node_metrics -->|"analyzes logs"| node_run
node_metrics -->|"analyzes environment state"| node_attack_config
node_agent -->|"uses client"| node_client
node_agent -->|"delegates server management"| node_server_manager
node_server_manager -->|"creates sessions"| node_client
node_server_manager -->|"converts connector tools"| node_adapter
node_client -->|"creates session"| node_session
node_session -->|"connects through"| node_connector
node_adapter -->|"calls MCP tools"| node_connector
node_client -->|"accepts options"| node_sandbox
node_word_server -->|"registers tools"| node_word_content
node_word_server -->|"registers tools"| node_word_format
node_word_server -.->|"exposes operations"| node_word_footnotes
node_word_content -->|"uses styles"| node_word_styles
node_word_content -->|"uses utilities"| node_word_utils
node_word_content -->|"uses utilities"| node_word_files
node_word_format -->|"uses styles"| node_word_styles
node_word_format -->|"uses tables"| node_word_tables
node_word_format -->|"uses utilities"| node_word_files
node_word_server -->|"registers tools"| node_word_comments

click node_run "https://github.com/dongsenzhang/msb/blob/main/main.py"
click node_attack_config "https://github.com/dongsenzhang/msb/blob/main/agent_attack.py"
click node_templates "https://github.com/dongsenzhang/msb/blob/main/data/prompt_template.py"
click node_metrics "https://github.com/dongsenzhang/msb/blob/main/metrics.py"
click node_attack_catalog "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/main.py"
click node_academic "https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/academic_search/PubMed_MCP_Server"
click node_web_search "https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/information_gathering/DuckDuckGo_Search_Server"
click node_terminal "https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/it_development_management/Terminal_Controller"
click node_memory "https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/llm_enhancement/Memory_Tool"
click node_image "https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/image_generation/Flux_ImageGen_Server"
click node_agent "https://github.com/dongsenzhang/msb/blob/main/mcp_use/agents/mcpagent.py"
click node_server_manager "https://github.com/dongsenzhang/msb/blob/main/mcp_use/managers/server_manager.py"
click node_adapter "https://github.com/dongsenzhang/msb/blob/main/mcp_use/adapters/langchain_adapter.py"
click node_client "https://github.com/dongsenzhang/msb/blob/main/mcp_use/client.py"
click node_session "https://github.com/dongsenzhang/msb/blob/main/mcp_use/session.py"
click node_connector "https://github.com/dongsenzhang/msb/blob/main/mcp_use/connectors/base.py"
click node_sandbox "https://github.com/dongsenzhang/msb/blob/main/mcp_use/types/sandbox.py"
click node_word_server "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py"
click node_word_content "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py"
click node_word_format "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py"
click node_word_footnotes "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/footnotes.py"
click node_word_styles "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/styles.py"
click node_word_tables "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/tables.py"
click node_word_utils "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/document_utils.py"
click node_word_files "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/file_utils.py"
click node_word_comments "https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/comment_tools.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_run,node_attack_config,node_templates,node_metrics toneBlue
class node_attack_catalog,node_academic,node_web_search,node_terminal,node_memory,node_image toneAmber
class node_agent,node_server_manager,node_adapter toneMint
class node_client,node_session,node_connector,node_sandbox toneRose
class node_word_server,node_word_content,node_word_format,node_word_footnotes,node_word_styles,node_word_tables,node_word_utils,node_word_files,node_word_comments,node_user toneIndigo
```

## Components

### Benchmark workflow

- [Run orchestration](https://github.com/dongsenzhang/msb/blob/main/main.py): `main.py`
- [Attack setup](https://github.com/dongsenzhang/msb/blob/main/agent_attack.py): `agent_attack.py`
- [Attack prompts](https://github.com/dongsenzhang/msb/blob/main/data/prompt_template.py): `data/prompt_template.py`
- [Result metrics](https://github.com/dongsenzhang/msb/blob/main/metrics.py): `metrics.py`

### Attack scenarios

- [Attack tools](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/main.py): `data/tools/attack_tools/main.py`
- [Academic search](https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/academic_search/PubMed_MCP_Server): `data/tools/attack_tools/academic_search/PubMed_MCP_Server`
- [Web search](https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/information_gathering/DuckDuckGo_Search_Server): `data/tools/attack_tools/information_gathering/DuckDuckGo_Search_Server`
- [Terminal control](https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/it_development_management/Terminal_Controller): `data/tools/attack_tools/it_development_management/Terminal_Controller`
- [Memory tool](https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/llm_enhancement/Memory_Tool): `data/tools/attack_tools/llm_enhancement/Memory_Tool`
- [Image generation](https://github.com/dongsenzhang/msb/tree/main/data/tools/attack_tools/image_generation/Flux_ImageGen_Server): `data/tools/attack_tools/image_generation/Flux_ImageGen_Server`

### Agent runtime

- [MCP agent](https://github.com/dongsenzhang/msb/blob/main/mcp_use/agents/mcpagent.py): `mcp_use/agents/mcpagent.py`
- [Server selection](https://github.com/dongsenzhang/msb/blob/main/mcp_use/managers/server_manager.py): `mcp_use/managers/server_manager.py`
- [LangChain adapter](https://github.com/dongsenzhang/msb/blob/main/mcp_use/adapters/langchain_adapter.py): `mcp_use/adapters/langchain_adapter.py`

### MCP connectivity

- [MCP client](https://github.com/dongsenzhang/msb/blob/main/mcp_use/client.py): `mcp_use/client.py`
- [MCP session](https://github.com/dongsenzhang/msb/blob/main/mcp_use/session.py): `mcp_use/session.py`
- [MCP connector](https://github.com/dongsenzhang/msb/blob/main/mcp_use/connectors/base.py): `mcp_use/connectors/base.py`
- [Sandbox options](https://github.com/dongsenzhang/msb/blob/main/mcp_use/types/sandbox.py): `mcp_use/types/sandbox.py`

### Word server

- [Word MCP server](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py`
- [Document content](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py`
- [Document formatting](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py`
- [Footnote operations](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/footnotes.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/footnotes.py`
- [Document styles](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/styles.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/styles.py`
- [Document tables](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/tables.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/core/tables.py`
- [Document utilities](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/document_utils.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/document_utils.py`
- [File utilities](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/file_utils.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/utils/file_utils.py`
- [Comment operations](https://github.com/dongsenzhang/msb/blob/main/data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/comment_tools.py): `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/comment_tools.py`

### Other components

- **Benchmark operator**

## Connections

- Benchmark operator → Run orchestration: starts run (evidence: `README.md`)
- Run orchestration → MCP agent: runs task (evidence: `main.py`)
- Run orchestration → Attack prompts: imports prompts (evidence: `main.py`)
- Run orchestration → Attack setup: supports evaluation
- Attack setup → Attack tools: selects tools
- Run orchestration → Result metrics: evaluates results (evidence: `README.md`)
- Result metrics → Run orchestration: analyzes logs (evidence: `README.md`)
- Result metrics → Attack setup: analyzes environment state (evidence: `README.md`)
- MCP agent → MCP client: uses client (evidence: `mcp_use/agents/mcpagent.py`)
- MCP agent → Server selection: delegates server management (evidence: `mcp_use/agents/mcpagent.py`)
- Server selection → MCP client: creates sessions (evidence: `mcp_use/managers/server_manager.py`)
- Server selection → LangChain adapter: converts connector tools (evidence: `mcp_use/managers/server_manager.py`)
- MCP client → MCP session: creates session (evidence: `mcp_use/client.py`)
- MCP session → MCP connector: connects through (evidence: `mcp_use/session.py`)
- LangChain adapter → MCP connector: calls MCP tools (evidence: `mcp_use/adapters/langchain_adapter.py`)
- MCP client → Sandbox options: accepts options (evidence: `mcp_use/client.py`)
- Word MCP server → Document content: registers tools (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py`)
- Word MCP server → Document formatting: registers tools (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py`)
- Word MCP server → Footnote operations: exposes operations
- Document content → Document styles: uses styles (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py`)
- Document content → Document utilities: uses utilities (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py`)
- Document content → File utilities: uses utilities (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/content_tools.py`)
- Document formatting → Document styles: uses styles (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py`)
- Document formatting → Document tables: uses tables (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py`)
- Document formatting → File utilities: uses utilities (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/tools/format_tools.py`)
- Word MCP server → Comment operations: registers tools (evidence: `data/tools/attack_tools/office_assistance/Office_Word_Document_Server/word_document_server/main.py`)
