# @cubicecho/mcp-discovery > Advertise and discover MCP servers: Server Cards, AI Catalogs, serving them over HTTP, and finding them from a client. Agent-facing docs for @cubicecho/mcp-discovery: one task or concept per page, then what each package.json "exports" entry exports. Generated from _agents/docs/ and the doc comments in src/ by @cubicecho/agent-docs; edit those, not this file. Requires Node >=22. Peer dependencies: `bonjour-service` >=1.4 (optional), `zod` >=4.1. ## Docs - [Install and choose an entry point](_agents/docs/01-install.md): Which packages to install, which of the two entry points to import from, and what a container needs before mDNS works. - [Build and read AI catalogs](_agents/docs/ai-catalogs.md): An AI Catalog is a host's list of artifacts, read at `/.well-known/ai-catalog.json`, and it is how a client finds the host's Server Cards. Build one by hand only when `discoveryMiddleware` doesn't fit, since the middleware builds it for you. - [Use it beside graphql-mdns-discovery](_agents/docs/beside-graphql-mdns-discovery.md): One app can advertise MCP servers with this package and a GraphQL API with `@cubicecho/graphql-mdns-discovery`. Mount both middlewares, in either order, and run both advertisements. - [Common mistakes](_agents/docs/common-mistakes.md): Mistakes that type-check and mostly fail silently, each with what happens and the fix. - [Discover the servers on a known host](_agents/docs/discovering.md): Reads a host's AI Catalog and every Server Card in it, with a typed error for each card that couldn't be read. - [Advertise and find hosts on the LAN](_agents/docs/mdns.md): Announces an MCP host over mDNS as an `_mcp._tcp` service, and finds the hosts others announce. mDNS says where a host is, and the host's AI Catalog says what it serves. - [Build and read server cards](_agents/docs/server-cards.md): A Server Card describes one MCP server: its name, its version, and the URLs and headers to connect with. This page builds one, names it, reads one, and turns one into a connection. - [Serve cards and a catalog over HTTP](_agents/docs/serving.md): Makes a server discoverable: one middleware that serves the AI Catalog and every endpoint's card, or single handlers when the public URL is fixed. - [Watch the LAN for servers](_agents/docs/watching-servers.md): `watchServers` browses for hosts, reads each one's AI Catalog, and reports MCP servers as they appear, change and go. Which of them to connect to is the caller's policy. ## Exports: @cubicecho/mcp-discovery Advertise and discover MCP servers. - `isSameEndpoint`: Whether two URLs are the same endpoint however they were written, so one typed by hand matches one found. - `CardConnection` (type): How to connect to a server from its card: the URL, and which headers the caller must supply. - `cardConnection`: The first streamable-HTTP remote on a card that can be used as it stands. - `createServerCard`: Builds a Server Card, adding its `$schema` and validating the result. - `Icon` (type): An icon a client may show for the server. - `Input` (type): A user-supplied or pre-set value for a remote's URL variable or header. - `iconSchema`: An icon a client may show for the server. - `inputSchema`: A user-supplied or pre-set value for a remote's URL variable or header. - `KeyValueInput` (type): A named input: an HTTP header a client sends to the remote. - `keyValueInputSchema`: A named input: an HTTP header a client sends to the remote. - `parseServerCard`: Validates a document as a Server Card. - `Remote` (type): One HTTP endpoint the server can be reached at. - `Repository` (type): Where the server's source code lives. - `remoteSchema`: One HTTP endpoint the server can be reached at. - `repositorySchema`: Where the server's source code lives. - `SERVER_CARD_PATH`: What is appended to a streamable-HTTP URL to reach its card, the location MCP reserves. - `SERVER_CARD_SCHEMA_URL`: The `$schema` every v1 Server Card carries. - `ServerCard` (type): An MCP Server Card. - `ServerCardFields` (type): What `createServerCard` takes: a card without its `$schema`. - `serverCardSchema`: An MCP Server Card. - `serverCardUrl`: The URL a server's card is served at by default: its streamable-HTTP URL plus `/server-card`. - `TRANSPORT_SSE`: The legacy HTTP+SSE transport. - `TRANSPORT_STREAMABLE_HTTP`: The streamable-HTTP transport. - `AI_CATALOG_SPEC_VERSION`: The `specVersion` this package writes. - `AiCatalog` (type): An AI Catalog. - `AiCatalogFields` (type): What `createAiCatalog` takes. - `aiCatalogLinkHeader`: A `Link` header value that points at an AI Catalog, for a site's other responses to carry. - `aiCatalogSchema`: An AI Catalog. - `airIdentifier`: A `urn:air:{publisher}:mcp:{name}` identifier for an MCP server. - `CatalogEntry` (type): One artifact in a catalog. - `catalogEntrySchema`: One artifact in a catalog, carried by `url` or inline as `data`, never both. - `createAiCatalog`: Builds an AI Catalog, adding its `specVersion` and validating the result. - `HostInfo` (type): The operator of a catalog. - `hostInfoSchema`: The operator of a catalog. - `inlineServerCardEntry`: An entry that carries a Server Card inline. - `parseAiCatalog`: Validates a document as an AI Catalog. - `parseInlineServerCard`: Validates a card entry's inline card. - `ServerCardEntry` (type): A catalog entry that holds a Server Card, by URL or inline. - `serverCardEntries`: The entries in a catalog that hold Server Cards; every other artifact type is left out. - `serverCardEntry`: An entry that points at a Server Card by URL. - `DiscoveredServer` (type): A server found in a catalog, with the card that describes it. - `Discovery` (type): What `discover` found on a host. - `DiscoveryFailure` (type): A catalog entry whose card could not be read. - `discover`: Discovers the MCP servers a host advertises, from its `/.well-known/ai-catalog.json`. - `discoverCatalog`: Discovers the MCP servers an AI Catalog lists, wherever the catalog is served (e.g. an mDNS host's `catalogUrl`). - `fetchAiCatalog`: Fetches and validates an AI Catalog. - `fetchServerCard`: Fetches and validates a Server Card. - `AI_CATALOG_MEDIA_TYPE`: Media type of an AI Catalog. - `AI_CATALOG_WELL_KNOWN_PATH`: Where a host serves its AI Catalog for domain-level discovery (RFC 8615). - `SERVER_CARD_MEDIA_TYPE`: Media type of an MCP Server Card. - `AdvertisedEndpoint` (type): One MCP endpoint a server advertises. - `CardContext` (type): What a card builder is told about the request it answers. - `DiscoveryMiddleware` (type): Express-style middleware: it answers discovery requests and passes every other request to `next`. - `discoveryMiddleware`: Middleware that serves `/.well-known/ai-catalog.json` and each endpoint's `/server-card`. - `EndpointSource` (type): Lists the endpoints to advertise, asked per request so it can follow config changes. - `aiCatalogHandler`: A handler that serves an AI Catalog, for `/.well-known/ai-catalog.json`. - `serverCardHandler`: A handler that serves a Server Card, for `/server-card`. - Re-exported unchanged from `@cubicecho/discovery-core`, which documents them: `DiscoveryError`, `DocumentFetchError`, `DocumentHandler`, `DocumentRequest`, `DocumentResponse`, `DocumentSource`, `documentHandler`, `documentResponse`, `FETCH_DEFAULTS`, `FetchOptions`, `FetchSettings`, `hostSlug`, `InvalidDocumentError`, `requestOrigin`, `SERVE_DEFAULTS`, `ServeSettings`, `writeDocument`. ## Exports: @cubicecho/mcp-discovery/mdns LAN advertising and browsing for MCP hosts over mDNS / DNS-SD, as `_mcp._tcp` services. - `AdvertiseOptions` (type): What to advertise. - `advertise`: Advertises an MCP host as `_mcp._tcp`, resolving once the announcement has gone out. - `AdvertiserDeps` (type): What the advertiser needs from its host. - `createAdvertiser`: An advertiser that announces nothing until the first `sync`. - `findHosts`: Listens for MCP hosts for a while, then lists what answered. - `HostWatch` (type): A running watch. - `HostWatchHandlers` (type): What `watchHosts` tells its caller. - `MCP_BROWSE`: What to browse for: `_mcp._tcp`, read as MCP hosts. - `McpHost` (type): An MCP host found on the network, with the URLs to reach it. - `toMcpHost`: Turns a found `_mcp._tcp` service into the URLs a client needs. - `watchHosts`: Browses for MCP hosts until stopped, reporting each as it comes and goes. - `createServerFinder`: A finder that watches nothing until the first `sync`. - `FoundServer` (type): A server on the network that can be connected to. - `ServerFinder` (type): Keeps the watch in step with `isWanted()`, and holds what it finds. - `ServerFinderDeps` (type): What the finder needs from its host. - `CatalogReader` (type): Reads the catalog at a URL; `discoverCatalog` with the caller's fetch settings. - `createServerTracker`: A tracker that reports servers through `handlers`. - `LanServer` (type): An MCP server found on the network. - `ServerTracker` (type): Tracks the servers on a set of hosts. - `ServerWatchHandlers` (type): What a server watch tells its caller. - `buildTxtRecord`: The TXT record for an advertised host. - `DEFAULT_ENDPOINT_PATH`: The endpoint path assumed when a record names none, and advertised when none is given. - `MCP_SERVICE_TYPE`: The DNS-SD service type, which bonjour-service turns into `_mcp._tcp`. - `McpTxtRecord` (type): Where on an advertised host its MCP documents are. - `parseTxtRecord`: Reads a TXT record from the network, falling back to defaults for missing or unsafe values. - `ServerWatch` (type): A running server watch. - `watchServers`: Watches the network for MCP servers, reporting each as it appears, changes and goes. - Re-exported unchanged from `@cubicecho/discovery-core`, which documents them: `MDNS_DEFAULTS`, `MdnsSettings`. - Re-exported unchanged from `@cubicecho/discovery-core/mdns`, which documents them: `AdvertiseError`, `Advertisement`, `Advertiser`, `FoundService`.