# Scala Support in Maguyva: Code Graphs for JVM Services and Spark

Canonical source: https://maguyva.ai/languages/scala

License: text under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); code samples under [MIT-0](https://opensource.org/license/mit-0); the Maguyva name, logos, brand assets and other code are not covered. Details: [maguyva.ai/license](https://maguyva.ai/license).

Maguyva parses Scala with AST, symbol, and graph support, so AI agents can follow traits, objects, case classes, and typed calls across JVM and Spark code.

## Support snapshot

- Tier: AST and symbol support
- Programming
- Extensions: .sc, .scala
- Real AST parsing for syntax-aware search and structural context.
- Named symbols feed semantic lookup and cross-reference. Graph navigation is available when relationship extraction is enabled.
- This language contributes symbols and relationships to graph-aware search; supported edge types vary with its native constructs.
- AST parsing and symbol extraction are both available.

## Best fit

- JVM services written in Scala, where traits, companion objects, and case classes spread one concept across many files.
- Spark and data-engineering jobs that agents need to read alongside the shared libraries they call.
- Mixed Scala and Java repositories that agents need to search as one codebase.

## Agent workflows

- Find every caller of a service method before changing its signature.
- List which classes and objects extend a trait before adding an abstract member.
- Trace how a request moves from an HTTP route through services into the data layer.

## Where Scala trips up shallow AI tools

Scala lets one name carry a lot. A trait, its companion object, and a case class can share one concept. Pattern matches bind new names inside `case` clauses, and a method called without a receiver inside a class is a call on `this`. An agent that reads one file at a time sees the names but not what they resolve to.

Maguyva resolves more of that at index time, so an agent can ask who calls a method and get an answer it can act on.

## What Maguyva extracts in Scala

Maguyva covers `.scala` and `.sc` files. Classes, objects, and traits are extracted as types, and the `functions` preset in `structural_search` covers `def` declarations, definitions, and lambdas. Signatures record repeated (`*`) parameters, and imports drop the `_root_` prefix.

Call relationships keep class-qualified names, and a bare call inside a class resolves to that class's own method. Receiver typing follows parameters, class parameters, `val` and `var` definitions, typed and case-class patterns inside `case` clauses, the return types of methods on classes, objects, and traits, type aliases, and `extends` clauses. `new` on a capitalised type counts as instantiation.

No relationship type is marked not applicable for Scala, so the graph also records inheritance, overrides, type references, reads and writes, control flow, and exception edges.

## Example agent prompts

- "Who calls `PaymentService.capture`, and from which routes?" (`find_symbol`, then `dependency_search` incoming)
- "Which classes and objects extend `EventHandler`?" (`dependency_search`)
- "Trace how an order event reaches the ledger writer." (`get_task_context`)

## Known limits

- About 320 standard-library names are filtered from relationships: collection operations such as `map`, `flatMap`, and `foldLeft`, plus `Option`, `Either`, `Try`, `Future`, and `Predef` helpers. A call on `this`, or on a value whose type resolves to one of your classes, is kept even when its name is on that list. Use `text_pattern_search` when a caller still seems missing.
- Short type parameters such as `A`, `F`, and `CC`, and root types such as `Any`, `Unit`, and `Nothing`, are filtered from type references.

## Next steps

Connect a repository with the [quickstart](/docs/quickstart), then check the support matrix on the [compatibility page](/docs/compatibility). For mixed JVM codebases, read the [Java guide](/languages/java) and the [Kotlin guide](/languages/kotlin) too.

## Engine details

- Scala support covers `.scala` and `.sc`. Classes, objects, and traits are types, and bare calls inside a class resolve to its own methods.
- Receiver typing follows parameters, class parameters, `val` and `var` definitions, `case` patterns, method return types, and `extends` clauses.
- Calls keep class-qualified names, `new` counts as instantiation, and about 320 standard-library names are filtered from relationships.

## Useful MCP entry points

- `find_symbol`: Use it for a trait, object, or service method when you need the definition and references.
- `dependency_search`: Use incoming traversal on a trait or method to see implementers and callers before a signature change.
- `get_task_context`: Use it for prompts like “trace how an order event reaches the ledger writer.”
