Expose space lua query as REST API

Right now we have a standard REST api which can access and write notes: HTTP API

It would be great if we could also query backlinks for a given note since that is available in the UI but not via the API. I wonder how hard it would be to expose the query function as an endpoint (e.g. http://my_sb_instance/query?..) to use the index. We could serach backlinks or tags. For context I was playing with Claude MCP and it works pretty well, it’s just a bit wasteful to open all files one by one to get relevance.

In “the old” 0.x builds this would actually be quite doable, because there was a space lua interpreter also running on the server side.

n v2 this won’t be possible because the backend has almost no logic, it only serves and stores files. It’s a “dumb” data store effectively. Everything interesting (including indexing) now happens 100% client side only. To expose Lua via an HTTP endpoint would require an architerural pivot back to the much more complicated implementation we had before where all Lua and Plug code would run both on the server and client, and honestly I don’t want to do that.

1 Like

I see, I wonder if it is possible to access the local client (via some API) instead of the webserver but I am not really sure how it would work. Essentially there is a slight mismatch between what I see on my client (widgets, queries) and what MCP sees (markdown with the query syntax). Maybe it would be feasible to make an MCP-client with no UI but with lua interpreter and sync?