Package com.tnsai.mcp.registry
Class OfficialRegistryClient
java.lang.Object
com.tnsai.mcp.registry.OfficialRegistryClient
- All Implemented Interfaces:
McpRegistrySource
Registry client for the official MCP registry at registry.modelcontextprotocol.io.
Fetches MCP server metadata from the official Model Context Protocol
registry using its HTTP API. Responses are parsed from JSON into
McpServerEntry records.
The HTTP fetch is performed via a protected method (fetchJson(String))
that can be overridden in tests to return canned responses.
-
Constructor Summary
ConstructorsConstructorDescriptionCreates an OfficialRegistryClient with default HTTP client.OfficialRegistryClient(HttpClient httpClient) Creates an OfficialRegistryClient with a custom HTTP client. -
Method Summary
Modifier and TypeMethodDescriptionLooks up a specific server by name.Returns the name of this registry source.listAll()Lists all available servers from this registry.Searches the registry for servers matching the given query.
-
Constructor Details
-
OfficialRegistryClient
public OfficialRegistryClient()Creates an OfficialRegistryClient with default HTTP client. -
OfficialRegistryClient
Creates an OfficialRegistryClient with a custom HTTP client.- Parameters:
httpClient- the HTTP client to use
-
-
Method Details
-
getSourceName
Description copied from interface:McpRegistrySourceReturns the name of this registry source.- Specified by:
getSourceNamein interfaceMcpRegistrySource- Returns:
- source name (e.g. "official", "smithery", "mcpservers.org", "camel")
-
search
Description copied from interface:McpRegistrySourceSearches the registry for servers matching the given query.- Specified by:
searchin interfaceMcpRegistrySource- Parameters:
query- search query string- Returns:
- list of matching server entries
- Throws:
IOException- if the registry cannot be reached
-
getServer
Description copied from interface:McpRegistrySourceLooks up a specific server by name.- Specified by:
getServerin interfaceMcpRegistrySource- Parameters:
name- the server name- Returns:
- the server entry if found
- Throws:
IOException- if the registry cannot be reached
-
listAll
Description copied from interface:McpRegistrySourceLists all available servers from this registry.- Specified by:
listAllin interfaceMcpRegistrySource- Returns:
- list of all server entries
- Throws:
IOException- if the registry cannot be reached
-