# cfonseca23/semantic-kernel-playwright-mcp architecture

> Architecture diagram of the GitHub repository cfonseca23/semantic-kernel-playwright-mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-05-01). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/cfonseca23/semantic-kernel-playwright-mcp
- Repository: https://github.com/cfonseca23/semantic-kernel-playwright-mcp

## Overview

##### Project type and purpose
- This is a .NET 8.0 console application (C#) that demos how to orchestrate AI-driven browsing and summarization.
- It combines Microsoft Semantic Kernel (for working with Azure OpenAI) with a Playwright-based Model Context Protocol (MCP) server to automate browser interactions (e.g., visiting Bing News, extracting and summarizing content).

##### File structure
- Top-level files:
- Program.cs – entry point; configures and runs the kernel + MCP flow
- SemanticKernelExtension.cs – contains helper methods (e.g., GetMCPClientForPlaywright, MapToFunctionsAsync)
- README.md – describes setup, features, architecture
- assets/ – contains documentation assets (demo GIF, readme)

##### Key architectural insights from the README
- Components: Semantic Kernel, Azure OpenAI, Playwright MCP server
- Workflow: Initialize kernel → launch MCP server → map MCP actions to SK functions → issue prompt → browser automation + summarization → output result

##### Elements
- Blue for AI components (Kernel, OpenAI)
- Green for browser automation (MCP, Playwright, Chromium)
- Gray for external services (Bing News)
- Orange for application code (Program.cs)
- Rectangles for processes/services

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Application Code
    subgraph "Application Code"
        Program["Program.cs\n(User CLI Interface)"]:::app
        SKext["SemanticKernelExtension.cs"]:::app
    end

    %% AI Components
    subgraph "AI Orchestration Layer"
        SemanticKernel["Semantic Kernel"]:::ai
        AzureOpenAI[(Azure OpenAI GPT-4)]:::ai
    end

    %% Browser Automation Layer
    subgraph "Browser Automation Layer"
        MCPClient["Playwright MCP Client"]:::automation
        MCPServer["Playwright MCP Server"]:::automation
        BrowserEngine["Chromium Browser Engine"]:::automation
    end

    %% External Resources
    ExternalWebsite["Bing News (External Website)"]:::external

    %% Documentation Assets
    subgraph "Documentation & Assets"
        README["README.md"]:::external
        Assets["assets/"]:::external
    end

    %% Workflow
    Program -->|"dotnet run & prompt"| SemanticKernel
    SemanticKernel -->|"ChatCompletion request"| AzureOpenAI
    SemanticKernel -->|"calls mapped functions"| MCPClient
    MCPClient -->|"MCP protocol (stdio/TCP)"| MCPServer
    MCPServer -->|"Playwright commands"| BrowserEngine
    BrowserEngine -->|"HTTP GET"| ExternalWebsite

    ExternalWebsite -->|"scraped HTML"| BrowserEngine
    BrowserEngine -->|"page data"| MCPServer
    MCPServer -->|"function response"| MCPClient
    MCPClient -->|"function result"| SemanticKernel
    SemanticKernel -->|"output result"| Program

    %% Documentation links
    Program --> README
    Program --> Assets

    %% Click Events
    click Program "https://github.com/cfonseca23/semantic-kernel-playwright-mcp/blob/main/Program.cs"
    click SKext "https://github.com/cfonseca23/semantic-kernel-playwright-mcp/blob/main/SemanticKernelExtension.cs"
    click README "https://github.com/cfonseca23/semantic-kernel-playwright-mcp/blob/main/README.md"
    click Assets "https://github.com/cfonseca23/semantic-kernel-playwright-mcp/tree/main/assets/"

    %% Styles
    classDef app fill:#f2a365,stroke:#333,stroke-width:1px;
    classDef ai fill:#75c0e0,stroke:#333,stroke-width:1px;
    classDef automation fill:#8bc34a,stroke:#333,stroke-width:1px;
    classDef external fill:#bdbdbd,stroke:#333,stroke-width:1px;
```
