MCP server: how to search within a community-specific scope?

Title: MCP server: how to search within a community-specific scope?

Hi all,

We’re beta-testing the LLM MCP server (0.10) on WaihonaPedia, a federation platform for families affected by rare genetic conditions. Content is organised in communities per condition (e.g. CdLS), and each community has its own search scope.

That scope isn’t a single space. It’s derived from data: from a condition key we collect several related spaces, plus public Q&A pages tagged with that key. Our search page builds this into a Solr filter query, so a visitor only finds what belongs to their community.

With the MCP server, an agent searches more broadly than our visitors do, and we’d like it to work within the same scope.

How would you approach this? Is it something the MCP server could support, or is there a better way to handle it on the wiki side?

Thanks!

I think the simplest solution would be to tell the agent to add the respective filter query to every search (as part of the main query, this should work I think, possibly with slight modifications of the query). Either as a custom instruction inside the agent, or by telling the agent to read it from some page in the community that exists in some central location.

Apart from that, you could in principle add custom code as an extension in XWiki that adds all communities a page is relevant for in a field on every page during indexing, which would collapse the filter query to a very simple expression (like community:community_name), which would simplify the instructions for the agent. The extension point for this SolrEntityMetadataExtractor. The index of a document is normally only updated when that document is updated, though, so you might also need to trigger the re-indexing of some or all documents when the search scopes change.

In principle, the MCP server is designed to be extensible, but we haven’t really defined a stable API for this yet. If we had a stable API, you could also implement your own search tool that adds the custom filter query (possibly giving the agent a “community” parameter) and disable the built-in search tool in favor of the custom one. As far as I’m aware, a stable tool extension API is currently not our priority, but it’s something we definitely want to have at some point.

If we go one step further, one could also imagine the possibility to define several MCP servers - at the moment, we have one per subwiki - that would give you the possibility to restrict that MCP server to the relevant spaces or configure the search tool with a filter query, so you have one MCP server per community. That’s currently not on our roadmap, but I don’t see why it wouldn’t be possible.