# @cubicecho/graphql-mdns-discovery > Advertise and discover GraphQL APIs: a public services document at /.well-known/graphql-services.json, serving it over HTTP, and finding hosts on a LAN as _graphql._tcp over mDNS. Agent-facing docs for @cubicecho/graphql-mdns-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](_agents/docs/01-install.md): What to install, which entry point each function comes from, and when the optional mDNS peer is needed. - [Common mistakes](_agents/docs/common-mistakes.md): Mistakes in publishing, reading and announcing GraphQL APIs, most of which type-check and fail quietly or far from their cause, each with its fix. - [Discovering APIs over HTTP](_agents/docs/discovering.md): How a client reads the GraphQL APIs a known host lists, which fields to connect with, and where failures show up. - [mDNS on the LAN](_agents/docs/mdns.md): How to announce a host as `_graphql._tcp`, how to find and watch hosts and APIs on the network, what the TXT record holds, and what Docker needs. - [The services document](_agents/docs/services-document.md): The JSON a host serves at `/.well-known/graphql-services.json`: its format, how it is served, how readers treat it, and what must never go in it. - [Serving the document](_agents/docs/serving.md): How a host publishes its GraphQL APIs at `/.well-known/graphql-services.json`, and how the URLs in that document are worked out for each request. - [Beside mcp-discovery](_agents/docs/with-mcp-discovery.md): How one app uses this package and `@cubicecho/mcp-discovery` together, to announce a GraphQL API and an MCP endpoint at once, and why neither disturbs the other. ## Exports: @cubicecho/graphql-mdns-discovery Advertise and discover GraphQL APIs. - `DiscoveredGraphqlService` (type): A service found in a document, with how to reach it. - `discoverGraphql`: Discovers the GraphQL APIs a host advertises, from its `/.well-known/graphql-services.json`. - `discoverGraphqlDocument`: Discovers the GraphQL APIs a document lists, wherever it is served (e.g. an mDNS host's `documentUrl`). - `fetchGraphqlServicesDocument`: Fetches a GraphQL services document and checks its envelope. - `GraphqlDiscovery` (type): What a read of one document found. - `GraphqlDiscoveryFailure` (type): A document entry that could not be read. - `DEFAULT_GRAPHQL_PATH`: The endpoint path assumed when an mDNS record names none, and advertised when none is given. - `GRAPHQL_SERVICES_MEDIA_TYPE`: Media type of a GraphQL services document. - `GRAPHQL_SERVICES_WELL_KNOWN_PATH`: Where a host serves its GraphQL services document (RFC 8615). - `createGraphqlService`: Builds one service, validating it. - `createGraphqlServicesDocument`: Builds a GraphQL services document, adding its `specVersion` and validating the result. - `GRAPHQL_SERVICES_SPEC_VERSION`: The `specVersion` this package writes. - `GraphqlEndpoint` (type): Where a service takes queries and mutations. - `GraphqlHeader` (type): A header a client sends with every request; never its value. - `GraphqlMethod`: The HTTP methods a GraphQL endpoint can take queries on. - `GraphqlService` (type): One GraphQL API a host serves. - `GraphqlServiceConnection` (type): How to reach a service: absolute URLs, and the headers the caller must supply. - `GraphqlServiceDraft` (type): A service as a middleware's builder returns it: the endpoint may be left out, and is then the advertised path. - `GraphqlServiceFields` (type): What `createGraphqlService` takes. - `GraphqlServicesDocument` (type): A GraphQL services document with every service valid, as a host builds it. - `GraphqlServicesEnvelope` (type): A document as read from the network: the envelope valid, the services not yet checked. - `GraphqlSubscriptions` (type): Where a service takes subscriptions, and over which protocol. - `graphqlEndpointSchema`: Where queries and mutations go. - `graphqlHeaderSchema`: A header a client sends with every request; the value is never in the document. - `graphqlServiceConnection`: How to connect to a service, with every URL made absolute. - `graphqlServiceSchema`: One GraphQL API a host serves. - `graphqlServicesDocumentSchema`: The envelope of a GraphQL services document. - `graphqlSubscriptionsSchema`: Where subscriptions go, and over which protocol. - `parseGraphqlService`: Validates one service from a document. - `parseGraphqlServicesDocument`: Validates a whole document, every service included. - `parseGraphqlServicesEnvelope`: Validates a document's envelope, leaving its services to be read one by one. - `SubscriptionProtocol`: The subscription transports a service can offer. - `AdvertisedGraphqlApi` (type): One GraphQL API a host advertises. - `GraphqlApiSource` (type): Lists the APIs to advertise, asked per request so it can follow config changes. - `GraphqlServiceContext` (type): What a service builder is told about the request it answers. - `graphqlDiscoveryMiddleware`: Middleware that serves `/.well-known/graphql-services.json` and passes every other request to `next`. - `graphqlServicesHandler`: A handler that serves a GraphQL services document, for routing it yourself. - Re-exported unchanged from `@cubicecho/discovery-core`, which documents them: `DiscoveryError`, `DocumentFetchError`, `FETCH_DEFAULTS`, `FetchOptions`, `FetchSettings`, `hostSlug`, `InvalidDocumentError`, `SERVE_DEFAULTS`, `ServeSettings`. ## Exports: @cubicecho/graphql-mdns-discovery/mdns LAN advertising and browsing for GraphQL hosts over mDNS / DNS-SD, as `_graphql._tcp` services. - `AdvertiseGraphqlOptions` (type): What to advertise. - `advertiseGraphql`: Advertises a GraphQL host as `_graphql._tcp`, resolving once the announcement has gone out. - `createGraphqlAdvertiser`: A GraphQL advertiser that follows a setting which can change while the process runs; announces nothing until the first `sync`. - `GraphqlAdvertiserDeps` (type): What a GraphQL advertiser needs from its host; `start` is `advertiseGraphql` unless replaced. - `findGraphqlHosts`: Listens for GraphQL hosts for a while, then lists what answered. - `GRAPHQL_BROWSE`: What to browse for: `_graphql._tcp`, read as GraphQL hosts. - `GraphqlHost` (type): A GraphQL host found on the network, with the URLs to reach it. - `toGraphqlHost`: Turns a found `_graphql._tcp` service into the URLs a client needs. - `watchGraphqlHosts`: Browses for GraphQL hosts until stopped, reporting each as it comes and goes. - `buildGraphqlTxtRecord`: The TXT record for an advertised GraphQL host. - `GRAPHQL_SERVICE_TYPE`: The DNS-SD service type, which bonjour-service turns into `_graphql._tcp`. - `GraphqlTxtRecord` (type): Where on an advertised host its GraphQL endpoint and document are. - `parseGraphqlTxtRecord`: Reads a `_graphql._tcp` TXT record from the network, falling back to defaults for missing or unsafe values. - `createGraphqlServiceTracker`: A tracker that reports GraphQL services through `handlers`, for driving it from something other than mDNS. - `GraphqlDocumentReader` (type): Reads the document at a URL; `discoverGraphqlDocument` with the caller's fetch settings. - `GraphqlServiceWatch` (type): A running GraphQL service watch. - `GraphqlServiceWatchHandlers` (type): What a GraphQL service watch tells its caller. - `graphqlServiceSource`: How the entry tracker reads a GraphQL host: its document's services, keyed `/`. - `LanGraphqlService` (type): A GraphQL API found on the network. - `watchGraphqlServices`: Watches the network for GraphQL APIs, 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`, `ServiceWatch`, `ServiceWatchHandlers`.