# code-express-ai/trading-mcp-dotnet architecture

> Architecture diagram of the GitHub repository code-express-ai/trading-mcp-dotnet, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code-express-ai/trading-mcp-dotnet
- Repository: https://github.com/code-express-ai/trading-mcp-dotnet

## Overview

This repository provides a read-only MCP interface to a fictional trading database, plus a data generator that seeds that database. The user workflow is: an assistant host sends tool requests to the server; the server authenticates and checks requests, runs fixed trading tools, and returns results queried from SQL Server. Tool calls are audited. The generator creates synthetic trading data and loads it into SQL Server. The README documents layered database protections and optional Entra authentication; some internal wiring is not shown in the sampled excerpts, so uncertain links are omitted or marked dashed.

Main entry points: [`McpServer/McpServerApplication.cs`](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/McpServerApplication.cs) (MCP application), [`McpServer/Tools/TradingTools.cs`](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Tools/TradingTools.cs) (Eight read-only tools), [`DataGenerator/Generation/SyntheticData.cs`](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Generation/SyntheticData.cs) (Synthetic dataset), [`McpServer/Repository/TradingRepository.cs`](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Repository/TradingRepository.cs) (Trading repository)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_server["MCP server"]
  node_mcp["MCP application"]
  node_audit["Tool-call audit<br/>[AuditService.cs]"]
end

subgraph group_security["Request security"]
  node_auth["Authentication and checks"]
  node_rate["Caller rate limits"]
end

subgraph group_trading["Trading access"]
  node_tools["Eight read-only tools<br/>[TradingTools.cs]"]
  node_arguments["Argument validation<br/>[ToolArguments.cs]"]
  node_repository["Trading repository"]
  node_models["Trading result models"]
end

subgraph group_generator["Data generation"]
  node_generator["Generator entry<br/>[Program.cs]"]
  node_options["Generator options"]
  node_synthetic["Synthetic dataset<br/>[SyntheticData.cs]"]
  node_seeddata["Seed examples<br/>[SeedData.cs]"]
  node_generation["Trading data generators"]
  node_generated["Generated data models<br/>[GeneratedData.cs]"]
  node_loader["Database loader<br/>[DataLoader.cs]"]
  node_seeder["Transactional seeder<br/>[DatabaseSeeder.cs]"]
end

node_assistant(("Assistant host"))
node_database[("SQL Server")]
node_entra["Microsoft Entra ID"]

node_assistant -->|"sends MCP requests"| node_mcp
node_mcp -->|"checks requests"| node_auth
node_mcp -->|"limits callers"| node_rate
node_mcp -->|"registers tools"| node_tools
node_tools -.->|"validates inputs"| node_arguments
node_tools -.->|"runs through"| node_audit
node_audit -->|"writes audit"| node_repository
node_tools -.->|"queries trading data"| node_repository
node_repository -->|"executes procedures"| node_database
node_repository -->|"returns rows"| node_models
node_mcp -.->|"supports authentication"| node_entra
node_generator -.->|"reads settings"| node_options
node_generator -->|"generates dataset"| node_synthetic
node_synthetic -->|"uses examples"| node_seeddata
node_synthetic -.->|"combines generators"| node_generation
node_synthetic -.->|"produces data"| node_generated
node_generator -->|"loads dataset"| node_loader
node_loader -->|"seeds database"| node_seeder
node_seeder -->|"bulk loads rows"| node_database

click node_mcp "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/McpServerApplication.cs"
click node_auth "https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/McpServer/Auth"
click node_rate "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Auth/CallerRateLimiter.cs"
click node_tools "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Tools/TradingTools.cs"
click node_arguments "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Tools/ToolArguments.cs"
click node_audit "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Audit/AuditService.cs"
click node_repository "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Repository/TradingRepository.cs"
click node_models "https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/McpServer/Model"
click node_generator "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Program.cs"
click node_options "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/GeneratorOptions.cs"
click node_synthetic "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Generation/SyntheticData.cs"
click node_seeddata "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Generation/SeedData.cs"
click node_generation "https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/DataGenerator/Generation"
click node_generated "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Models/GeneratedData.cs"
click node_loader "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/DataLoader.cs"
click node_seeder "https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Database/DatabaseSeeder.cs"

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_mcp,node_audit toneBlue
class node_auth,node_rate,node_database toneAmber
class node_tools,node_arguments,node_repository,node_models toneMint
class node_generator,node_options,node_synthetic,node_seeddata,node_generation,node_generated,node_loader,node_seeder toneRose
class node_assistant,node_entra toneIndigo
```

## Components

### MCP server

- [MCP application](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/McpServerApplication.cs): `McpServer/McpServerApplication.cs`
- [Tool-call audit](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Audit/AuditService.cs): `McpServer/Audit/AuditService.cs`

### Request security

- [Authentication and checks](https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/McpServer/Auth): `McpServer/Auth`
- [Caller rate limits](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Auth/CallerRateLimiter.cs): `McpServer/Auth/CallerRateLimiter.cs`

### Trading access

- [Eight read-only tools](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Tools/TradingTools.cs): `McpServer/Tools/TradingTools.cs`
- [Argument validation](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Tools/ToolArguments.cs): `McpServer/Tools/ToolArguments.cs`
- [Trading repository](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/McpServer/Repository/TradingRepository.cs): `McpServer/Repository/TradingRepository.cs`
- [Trading result models](https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/McpServer/Model): `McpServer/Model`

### Data generation

- [Generator entry](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Program.cs): `DataGenerator/Program.cs`
- [Generator options](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/GeneratorOptions.cs): `DataGenerator/GeneratorOptions.cs`
- [Synthetic dataset](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Generation/SyntheticData.cs): `DataGenerator/Generation/SyntheticData.cs`
- [Seed examples](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Generation/SeedData.cs): `DataGenerator/Generation/SeedData.cs`
- [Trading data generators](https://github.com/code-express-ai/trading-mcp-dotnet/tree/main/DataGenerator/Generation): `DataGenerator/Generation`
- [Generated data models](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Models/GeneratedData.cs): `DataGenerator/Models/GeneratedData.cs`
- [Database loader](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/DataLoader.cs): `DataGenerator/DataLoader.cs`
- [Transactional seeder](https://github.com/code-express-ai/trading-mcp-dotnet/blob/main/DataGenerator/Database/DatabaseSeeder.cs): `DataGenerator/Database/DatabaseSeeder.cs`

### Other components

- **Assistant host**
- **SQL Server**
- **Microsoft Entra ID**

## Connections

- Assistant host → MCP application: sends MCP requests (evidence: `README.md`)
- MCP application → Authentication and checks: checks requests (evidence: `McpServer/McpServerApplication.cs`)
- MCP application → Caller rate limits: limits callers (evidence: `McpServer/McpServerApplication.cs`)
- MCP application → Eight read-only tools: registers tools (evidence: `McpServer/McpServerApplication.cs`)
- Eight read-only tools → Argument validation: validates inputs (evidence: `McpServer/Tools/TradingTools.cs`)
- Eight read-only tools → Tool-call audit: runs through
- Tool-call audit → Trading repository: writes audit (evidence: `McpServer/Audit/AuditService.cs`)
- Eight read-only tools → Trading repository: queries trading data
- Trading repository → SQL Server: executes procedures (evidence: `README.md`)
- Trading repository → Trading result models: returns rows (evidence: `McpServer/Repository/TradingRepository.cs`)
- MCP application → Microsoft Entra ID: supports authentication (evidence: `README.md`)
- Generator entry → Generator options: reads settings
- Generator entry → Synthetic dataset: generates dataset
- Synthetic dataset → Seed examples: uses examples
- Synthetic dataset → Trading data generators: combines generators (evidence: `DataGenerator/Generation/SyntheticData.cs`)
- Synthetic dataset → Generated data models: produces data (evidence: `DataGenerator/Generation/SyntheticData.cs`)
- Generator entry → Database loader: loads dataset (evidence: `DataGenerator/Program.cs`)
- Database loader → Transactional seeder: seeds database (evidence: `DataGenerator/DataLoader.cs`)
- Transactional seeder → SQL Server: bulk loads rows (evidence: `DataGenerator/Database/DatabaseSeeder.cs`)
