Member-only story

How the team combined Model Context Protocol with LSP to create intelligent coding workflows

When I first discovered Serena, I thought I was looking at just another coding assistant. But after diving deep into their codebase, I realized I was witnessing something much more significant: a masterclass in architectural design that solves the fundamental problems of AI-powered coding tools.

Press enter or click to view image in full size

Table of Content

· The Problem They Set Out to Solve
· The Genius of MCP + LSP Integration
∘ Language Server Protocol (LSP) — The Brain
∘ Model Context Protocol (MCP) — The Bridge
· Architectural Deep Dive — How They Built It
∘ 1. The Multi-Layer Tool System
∘ 2. The Language Server Wrapper
∘ 3. The Memory System Architecture
· Real-World Implementation Examples
∘ Symbol-Level Code Navigation
∘ Cross-File Refactoring
· The Multi-Model Strategy
∘ MCP Server Mode (Free Tier Friendly)
∘ Agno Agent Mode (Universal Compatibility)
∘ Framework Integration (Developer Flexibility)
· What Makes This Architecture Special
∘ 1. Symbolic vs. Textual Understanding
∘ 2. Protocol-First Design
∘ 3. Separation of Concerns
· Lessons for Building AI Tools
∘ Leverage Existing Protocols
∘ Design for Model Agnosticism
∘ Invest in Memory Systems
∘ Embrace Open Source Standards
· The Technical Implementation Details That Matter
∘ Async Language Server Management
∘ Tool Registration System
∘ Configuration Management
· Performance and Scalability Insights
· Future-Proofing Through Standards
· Getting Started — Practical Next Steps
∘ For Exploration:
∘ For Building Similar Tools:
∘ For Contributing:
· The Bigger Picture

The Problem They Set Out to Solve

  • Model Lock-in: Most tools tie you to specific AI providers
  • Subscription Fatigue: $20–200/month for each tool adds up quickly
  • Surface-Level Understanding: Many tools treat code as text, missing semantic relationships
  • IDE Dependency: Powerful features only work within specific editors

The Serena team asked a brilliant question: “What if we could give any language model the same symbolic understanding of code that IDEs have?”

The Genius of MCP + LSP Integration

Here’s where Serena’s architecture gets fascinating. They identified two powerful but underutilized technologies:

Language Server Protocol (LSP) — The Brain

LSP is what makes your IDE so smart. When you hover over a function and see its definition, or when you rename a variable across an entire codebase, that’s LSP at work. It provides:

  • Symbolic Understanding: Knows what each piece of code actually means
  • Relationship Mapping: Understands how functions, classes, and variables connect
  • Cross-Reference Analysis: Can find all usages of any symbol instantly

Model Context Protocol (MCP) — The Bridge

MCP is Anthropic’s relatively new protocol that lets AI models use external tools. Think of it as a standardized way for AIs to “call functions” in the real world.

The breakthrough insight: What if we expose LSP’s symbolic code understanding through MCP tools?

Architectural Deep Dive — How They Built It

Let me walk you through the key architectural decisions that make Serena so powerful:

1. The Multi-Layer Tool System

Serena implements over 30 specialized tools, each serving a specific purpose:

Semantic Analysis Tools:

  • find_symbol: Global symbol search with type filtering
  • get_symbols_overview: High-level code structure analysis
  • find_referencing_symbols: Trace symbol relationships

Intelligent Editing Tools:

  • replace_symbol_body: Modify functions while preserving signatures
  • insert_before_symbol: Add code with perfect positioning
  • delete_lines: Precise line-based editing

Context Management Tools:

  • : Persistent project knowledge
  • onboarding: Automated project familiarization
  • think_about_task_adherence: Self-reflection capabilities

2. The Language Server Wrapper

This is where the real magic happens. Serena builds on Microsoft’s multilspy library but extends it significantly:

# Simplified example of how Serena wraps LSP functionality
class SerenaLanguageServer:
def find_symbol_definitions(self, symbol_name, file_path):
# Uses LSP to get precise symbol locations
# Returns structured data about code entities
def get_symbol_references(self, position):
# Leverages LSP's reference finding
# Maps all usages across the codebase

The brilliant part? They made LSP operations available as simple tool calls that any language model can understand and use.

3. The Memory System Architecture

One of Serena’s most innovative features is its persistent memory system:

  • Project Onboarding: Automatically creates initial understanding of codebases
  • Memory Files: Stores insights in .serena/memories/ as readable text files
  • Context Continuity: Maintains understanding across conversation sessions
“We found the memories to significantly improve the user experience with Serena. By itself, Serena is instructed to create new memories whenever appropriate.” — Serena Documentation

Real-World Implementation Examples

Let me show you how this architecture works in practice:

Symbol-Level Code Navigation

Instead of searching for text patterns like “function getUserData”, Serena can:

  1. Find the actual function definition using LSP’s symbol resolution
  2. Trace all references to understand usage patterns
  3. Modify the function body while preserving its interface
  4. Update related tests by following symbolic relationships

Cross-File Refactoring

When you ask Serena to rename a variable, it doesn’t do find-and-replace. Instead:

  • Uses LSP to identify the symbol’s scope and type
  • Maps all legitimate references across files
  • Preserves variable names in comments and strings where appropriate
  • Updates related documentation automatically

The Multi-Model Strategy

Here’s what really sets Serena apart: true model agnosticism. The architecture supports three integration patterns:

MCP Server Mode (Free Tier Friendly)

  • Works with Claude Desktop’s free tier
  • No API costs beyond what you already pay
  • Full tool integration through MCP protocol

Agno Agent Mode (Universal Compatibility)

  • Supports Google’s Gemini, OpenAI’s models, open-source alternatives
  • Web-based GUI for easy interaction
  • Programmatic access for advanced use cases

Framework Integration (Developer Flexibility)

  • Easy adaptation to existing agent frameworks
  • Clean tool abstractions for custom implementations

What Makes This Architecture Special

After studying dozens of coding tools, here’s what makes Serena’s approach unique:

1. Symbolic vs. Textual Understanding

Traditional Approach: “Find functions that contain the word ‘authenticate’” Serena’s Approach: “Find all authentication-related symbols and their relationships”

2. Protocol-First Design

Instead of building yet another proprietary API, they leveraged existing standards:

  • LSP for code understanding (used by VS Code, IntelliJ, etc.)
  • MCP for AI tool integration (standardized by Anthropic)

3. Separation of Concerns

The architecture cleanly separates:

  • Code Analysis (LSP layer)
  • Tool Execution (Serena’s tool system)
  • AI Orchestration (MCP/Agno integration)
  • User Interface (Client-agnostic)

Lessons for Building AI Tools

Studying Serena’s architecture revealed several key insights for anyone building AI-powered development tools:

Leverage Existing Protocols

Don’t reinvent the wheel. LSP already solves code understanding, and MCP standardizes AI tool integration.

Design for Model Agnosticism

The AI landscape changes rapidly. Build tools that work with multiple providers and models.

Invest in Memory Systems

Persistent context and project understanding dramatically improve user experience over time.

Embrace Open Source Standards

Using established protocols makes your tool more compatible and adoption-friendly.

The Technical Implementation Details That Matter

Async Language Server Management

# Serena handles LSP servers as separate processes
# This prevents crashes from affecting the main agent
await language_server.start()
await language_server.initialize(project_path)

Tool Registration System

Each Serena tool inherits from a base Tool class, making the system easily extensible:

class FindSymbolTool(Tool):
def apply(self, symbol_name: str, filter_type: str = None):
# Implementation using LSP
return structured_symbol_data

Configuration Management

Project-specific YAML files control tool availability and behavior:

# myproject.yml
read_only: false # Enable/disable editing tools
enable_gui_logging: true # Debug assistance
onboarding_enabled: true # Auto-familiarization

Performance and Scalability Insights

The team made several smart architectural choices for performance:

  • Lazy Loading: Language servers start only when needed
  • Context Frugality: Tools are designed to minimize token usage
  • Process Isolation: LSP servers run independently to prevent crashes
  • Caching Strategy: Symbol information is cached for faster repeated access

Future-Proofing Through Standards

What impressed me most about Serena’s architecture is how future-proof it is:

MCP Adoption: As more AI providers adopt MCP (ChatGPT support coming soon), Serena will work everywhere

LSP Evolution: New language support comes automatically as LSP implementations improve

Framework Flexibility: The tool system can adapt to new agent frameworks easily

Getting Started — Practical Next Steps

If you want to explore or build on Serena’s architecture:

For Exploration:

  • Clone the repo and examine the tool implementations in src/serena/agent/
  • Study how they wrap LSP functionality in src/serena/lsp/
  • Look at the MCP server implementation in src/serena/mcp/

For Building Similar Tools:

  • Start with LSP — understand your language’s language server capabilities
  • Design tool interfaces before implementation
  • Consider memory/persistence from day one
  • Plan for multi-model support early

For Contributing:

  • Add support for new programming languages
  • Implement additional semantic analysis tools
  • Improve the memory system with better categorization

The Bigger Picture

Serena represents something bigger than just another coding tool. It’s a proof of concept for the future of AI-assisted development:

  • Open standards over proprietary lock-in
  • Semantic understanding over text processing
  • Universal compatibility over vendor restriction
  • Community-driven development over corporate control

The team at Oraios AI didn’t just solve their own problem of expensive coding subscriptions. They created a blueprint for how AI tools should be built: leveraging existing standards, designing for openness, and focusing on real semantic understanding rather than surface-level text manipulation.

What’s your take on this architectural approach? Have you experimented with MCP or LSP in your own projects? I’d love to hear about your experiences with coding agents and what features you think are missing from current tools.

The future of AI-assisted coding isn’t about which company builds the best chatbot — it’s about which approaches create the most powerful, open, and accessible tools for developers. Serena’s architecture points the way forward.

GitHub - oraios/serena: A powerful coding agent toolkit providing semantic retrieval and editing...

A powerful coding agent toolkit providing semantic retrieval and editing capabilities (MCP server & Agno integration) ...

github.com

AI

Artificial Intelligence

Technology

Mcp Server

No responses yet

What are your thoughts?

More from Souradip Pal

In

Towards AI

by

Souradip Pal

DSPy Pipelines & Compilers in Depth

Unlocking Self-Improving AI Systems, End to End

Aug 9

83

In

Towards AI

by

Souradip Pal

Why DSPy is More Than Just Prompting

Stop babysitting prompts. Start programming Language Model systems.

Aug 5

21

In

Towards AI

by

Souradip Pal

Few-Shot Optimization at Scale in DSPy

From Smart Example Selection to Self-Learning Systems

Aug 16

86

In

Towards AI

by

Souradip Pal

How I Hooked Google’s ADK to My Frontend Without Breaking Everything

Lessons learned while building a responsive frontend that talks smoothly with ADK’s agent stack.

Jun 25

1

See all from Souradip Pal

Recommended from Medium

Orami

I Tested Every AI Code Generator — Here’s theWinner

After 6 months and 500+ hours of rigorous testing, the results may surprise you

Aug 8

1.5K61

In

Coding Nexus

by

Civil Learning

Google’s New LLM Runs on Just 0.5 GB RAM — Here’s How to Fine-Tune It Locally”

A few days ago, Google quietly released a little AI model called Gemma 3 270M.

Aug 16

1.1K17

Mohammed Tawfik

10 Claude Code Power Hacks They Don’t Tell You (But Should)

How to Make Claude Your Favorite Teammate — That Never Sleeps, Whines, or Misses a Deadline

Jul 20

48

In

Artificial Corner

by

The PyCoach

You’re using GPT-5 wrong! Here’s how to be ahead of 99% of users

Here’s how to make the most out of GPT-5

Aug 20

73618

In

UX Collective

by

Michael McWatters

Three hours of vibe design

Thoughts on process, problems, and possibilities.

6d ago

1.3K41

In

Neo4j Developer Blog

by

Alex Gilmore

Quickly Build a ReAct Agent With LangGraph and MCP

Learn how to incorporate local and MCP-hosted tools into your agents

Aug 19

33

See more recommendations

Help

Status

About

Careers

Press

Blog

Privacy

Rules

Terms

Text to speech