langgraph-clean-arch

langgraph-clean-arch

MCP server implementing clean architecture with LangGraph for building and managing agent workflows.

Category
Visit Server

README

Clean Architecture LangGraph MCP Server

A Model Context Protocol (MCP) server written in Python from scratch using LangGraph for orchestration, structured around the principles of Clean Architecture.


🏛️ Architecture Overview

This project is divided into four concentric layers to enforce the Dependency Inversion Principle (outer layers can import inner layers, but inner layers must NEVER know about outer layers):

[Domain] <-- [Use Cases] <-- [Adapters] <-- [Frameworks]
  1. Domain (src/domain/): Contains core entity dataclasses (Message, ConversationState). Entirely framework-free.
  2. Use Cases (src/usecases/): Application business rules (RunAgentUseCase) and abstract gateway interfaces (AgentGateway, HistoryRepository).
  3. Interface Adapters (src/adapters/): Gateway implementations (InMemoryHistoryRepository) and interface bindings for external communication (McpController).
  4. Frameworks & Drivers (src/frameworks/): External libraries and composition root (LangGraphAgent, config.py, main.py).

🚀 Getting Started

1. Requirements

  • Python >= 3.13

2. Set Up Virtual Environment (Already Done)

The virtual environment has already been created in this folder at .venv. To activate it:

Windows PowerShell:

.venv\Scripts\Activate.ps1

Windows CMD:

.venv\Scripts\activate.bat

Bash / Git Bash:

source .venv/bin/activate

3. Configure API Key

Create a .env file in the project root:

OPENAI_API_KEY=your_openai_api_key_here

Note: If no API key is specified, the application will fallback to Simulation Mode, which lets you test the execution pipeline locally without incurring cost or requiring keys.

4. Running the Verification Test

Verify the layers and data flow run properly inside the virtual environment:

python test_app.py

5. Running the MCP Server

To execute the server via the stdio transport protocol:

python src/main.py

Note: Normal logs are written to sys.stderr to avoid corrupting the protocol communication channel on stdout.


🔌 Connecting to Host Clients

Claude Desktop

Add this server to your Claude Desktop config file (located at %APPDATA%\Claude\claude_desktop_config.json):

{
  "mcpServers": {
    "langgraph-clean-arch": {
      "command": "C:\\Users\\faria\\.gemini\\antigravity-ide\\scratch\\mcp-langgraph-clean-arch\\.venv\\Scripts\\python.exe",
      "args": ["C:\\Users\\faria\\.gemini\\antigravity-ide\\scratch\\mcp-langgraph-clean-arch\\src\\main.py"]
    }
  }
}

Cursor

Go to Settings > Features > MCP:

  1. Click + Add New MCP Server.
  2. Set Name to langgraph-clean-arch.
  3. Set Type to command.
  4. Set Command to:
    C:\Users\faria\.gemini\antigravity-ide\scratch\mcp-langgraph-clean-arch\.venv\Scripts\python.exe C:\Users\faria\.gemini\antigravity-ide\scratch\mcp-langgraph-clean-arch\src\main.py
    
  5. Click Save and verify the status shows active green.

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured