Skip to content
cd /languages
  • Typed JVM
  • Programming
  • AST and symbol support

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

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.

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, then check the support matrix on the compatibility page. For mixed JVM codebases, read the Java guide and the Kotlin guide too.

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.

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.”