My agent already uses LSP plugins, and the protocol supports querying by symbol:

https://microsoft.github.io/language-server-protocol/specifi...

https://microsoft.github.io/language-server-protocol/specifi...

Thanks - I wasn't aware of that, although it still doesn't seem to be what would be most useful to an AI agent.

For example, if the agent wants to modify a function, it may want to know all the places the function is called, which AFAIK Treesitter can provide directly, but it seems with LSP you'd have to use that DocumentSymbol API to process every source file to find the usages, since you're really searching by source file, not by symbol.

For that I believe you could use textDocument/references:

https://microsoft.github.io/language-server-protocol/specifi...

Yes, but that one is position-based rather than name-based - I believe it's basically for an editor to ask about whatever is under the cursor.