Codebase indexing and MCP — Carry a map before reading.
In a large repository, the first problem is choosing where to look. swift-skeleton extracts declarations and source locations so agents and people can navigate back to implementation.
Choose the reading scope before loading full source.
File names alone hide responsibilities; loading everything expands the reading scope. Types, inheritance, properties, method signatures, paths and line numbers provide an overview from which to select the original implementation.
An index also needs a scope contract. Unrelated generated output or languages in a monorepo change what the map means, not just its size. Core retains the opened scope and checks isIndexable and selected parsers during updates. Narrowing the view defines which implementation this map actually describes.
An index does not replace the source.
Implementation markers are investigation clues derived from AST evidence and project context. A method that looks empty may have a valid purpose. The map directs attention to source ranges, callers and tests; it does not make the final judgment.
Text search locates strings directly, while the reader constructs responsibility and type relationships. Structural indexing supplies declaration-based entry points, but does not replace compiler semantics or implementation that exists only after generation. Use the index to choose locations, then search and read the original source to verify them.
Parse the project, then select the scope.
SkeletonIndexCore.build validates roots, languages and targets, parses source and creates ProjectIndex. SwiftPM target mode includes the selected target and the visible surface of directly imported local dependencies. The CLI calls the core and prints declarations and locations. A strict directory path and a target selection define different scopes.
- ProjectSource files
- ParserTree-sitter
- SkeletonIndexCoreProjectIndex
- Agent interfaceCLI / JSON-RPC
- ReaderOriginal source
let index = try core.build(
projectRoot: projectRoot,
languages: languages,
targetName: target
)
try core.validateRender(index: index, accessBoundary: access)Update the map without widening its scope.
IndexScopeTests starts with Keep.swift, then submits Added.swift, a .build file, another-language file and an outside-root file as update candidates. Only Keep.swift and Added.swift remain, matching a fresh build of the same scope. When target imports change, Core recalculates selected local dependencies instead of retaining the old connections.
.build/Hidden.swiftexcludedAdded.swiftindexed
MCP is an integration boundary.
Exposing a tool over MCP and constructing a useful index are separate responsibilities. The inspected Package.swift provides libraries, a CLI and a JSON-RPC daemon; it has no bundled MCP server target. MCP use requires an adapter to those interfaces. The index does not prove name resolution, semantic correctness or successful execution, and no token reduction is measured here.
When sharing an index with AI, keep roots, languages, targets and diagnostics explicit. An absent declaration does not prove absence from the project. Distinguish out-of-scope code, unsupported parsers and parse errors before returning to source. An MCP adapter owns exposing CLI or JSON-RPC while preserving those reading boundaries.
Read the evidence
Source reading date:
An explanation based on reading public design, implementation and test bodies. It is not a report of executing upstream tests or measuring device performance.