Serena — Semantic Code Agent via MCP
Serena is a coding agent MCP server with semantic code retrieval and editing. 22K+ stars. Understands classes, functions, symbols for precise context-aware edits. MIT.
What it is
Serena is a coding agent that operates as an MCP (Model Context Protocol) server, providing semantic code retrieval and editing capabilities. It understands your codebase at the symbol level: classes, functions, methods, and their relationships.
Serena targets developers using AI coding assistants who want more precise code understanding than simple text search. By leveraging language server protocol data, Serena provides context-aware edits that respect your code's semantic structure.
The project is actively maintained and suitable for both individual developers and teams looking to integrate it into their existing toolchain. Documentation and community support are available for onboarding.
How it saves time or tokens
Traditional code search finds text matches. Serena finds semantic matches: all callers of a function, all implementations of an interface, all subclasses of a base class. This precision means your AI assistant gets exactly the right context for edits, reducing token waste from irrelevant search results. The estimated token budget is around 450 tokens per query.
How to use
- Install Serena as an MCP server in your AI coding assistant's configuration.
- Point Serena at your project directory so it can index the codebase.
- Use your AI assistant normally. Serena provides semantic code context through MCP tools.
- Ask for refactoring, analysis, or edits that require understanding code relationships.
Example
{
"mcpServers": {
"serena": {
"command": "uvx",
"args": ["serena", "--workspace", "/path/to/project"],
"env": {}
}
}
}
# Install and run Serena
pip install serena
serena --workspace /path/to/your/project
# Serena exposes MCP tools like:
# - find_symbol: find definition of a class/function
# - find_references: find all usages of a symbol
# - semantic_edit: edit code with symbol awareness
# - get_context: retrieve semantic context for a code location
Related on TokRepo
- AI Tools for Coding — AI coding assistants and development tools.
- MCP Integrations — Browse MCP server integrations for development workflows.
Common pitfalls
- Running Serena on a very large monorepo without filtering. Indexing the entire repository takes time and memory. Limit the workspace to the relevant subdirectory.
- Expecting full language support from day one. Serena works best with Python, TypeScript, and Go. Support for other languages depends on the underlying language server availability.
- Not restarting Serena after major code changes. The index can become stale. Restart the MCP server or trigger a re-index after large refactors.
- Running the workflow in a restricted environment without verifying permissions. Missing file system or network access causes silent failures that are hard to diagnose.
Frequently Asked Questions
MCP is a protocol that allows AI assistants to interact with external tools and data sources. Serena implements an MCP server that provides semantic code understanding as tools that the AI assistant can call.
Serena provides strong support for Python, TypeScript, JavaScript, and Go. Additional language support depends on available language servers. Check the Serena documentation for the current language compatibility matrix.
Yes. Serena is designed to work as an MCP server with Claude Code and other AI coding assistants that support the MCP protocol. Add Serena to your MCP server configuration to enable it.
Regular search finds text matches. Serena understands code structure: it can find all callers of a function, all implementations of an interface, or all places where a type is used. This semantic understanding enables more precise code navigation and refactoring.
Yes. Serena is open-source under the MIT license. The project accepts community contributions for additional language server integrations and new MCP tools.
Citations (3)
- Serena GitHub— Semantic code agent via MCP with symbol-level understanding
- MCP Specification— MCP protocol for AI tool integration
- LSP Specification— Language Server Protocol for code intelligence
Related on TokRepo
Source & Thanks
- GitHub: https://github.com/oraios/serena (22K+ stars)
- License: MIT
- Docs: https://serena.dev